| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/gcm_driver/instance_id/instance_id_driver.h" | 5 #include "components/gcm_driver/instance_id/instance_id_driver.h" |
| 6 | 6 |
| 7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "components/gcm_driver/gcm_driver.h" |
| 9 #include "components/gcm_driver/instance_id/instance_id.h" | 10 #include "components/gcm_driver/instance_id/instance_id.h" |
| 10 | 11 |
| 11 namespace instance_id { | 12 namespace instance_id { |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 #if !defined(OS_ANDROID) | 15 #if !defined(OS_ANDROID) |
| 15 const char kInstanceIDFieldTrialName[] = "InstanceID"; | 16 const char kInstanceIDFieldTrialName[] = "InstanceID"; |
| 16 const char kInstanceIDFieldTrialEnabledGroupName[] = "Enabled"; | 17 const char kInstanceIDFieldTrialEnabledGroupName[] = "Enabled"; |
| 17 #endif // !defined(OS_ANDROID) | 18 #endif // !defined(OS_ANDROID) |
| 18 } // namespace | 19 } // namespace |
| (...skipping 15 matching lines...) Expand all Loading... |
| 34 } | 35 } |
| 35 | 36 |
| 36 InstanceIDDriver::~InstanceIDDriver() { | 37 InstanceIDDriver::~InstanceIDDriver() { |
| 37 } | 38 } |
| 38 | 39 |
| 39 InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) { | 40 InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) { |
| 40 auto iter = instance_id_map_.find(app_id); | 41 auto iter = instance_id_map_.find(app_id); |
| 41 if (iter != instance_id_map_.end()) | 42 if (iter != instance_id_map_.end()) |
| 42 return iter->second.get(); | 43 return iter->second.get(); |
| 43 | 44 |
| 44 scoped_ptr<InstanceID> instance_id = InstanceID::Create(app_id, gcm_driver_); | 45 gcm::InstanceIDHandler* handler = gcm_driver_->GetInstanceIDHandlerInternal(); |
| 46 |
| 47 scoped_ptr<InstanceID> instance_id = InstanceID::Create(app_id, handler); |
| 45 InstanceID* instance_id_ptr = instance_id.get(); | 48 InstanceID* instance_id_ptr = instance_id.get(); |
| 46 instance_id_map_.insert(std::make_pair(app_id, std::move(instance_id))); | 49 instance_id_map_.insert(std::make_pair(app_id, std::move(instance_id))); |
| 47 return instance_id_ptr; | 50 return instance_id_ptr; |
| 48 } | 51 } |
| 49 | 52 |
| 50 void InstanceIDDriver::RemoveInstanceID(const std::string& app_id) { | 53 void InstanceIDDriver::RemoveInstanceID(const std::string& app_id) { |
| 51 instance_id_map_.erase(app_id); | 54 instance_id_map_.erase(app_id); |
| 52 } | 55 } |
| 53 | 56 |
| 54 bool InstanceIDDriver::ExistsInstanceID(const std::string& app_id) const { | 57 bool InstanceIDDriver::ExistsInstanceID(const std::string& app_id) const { |
| 55 return instance_id_map_.find(app_id) != instance_id_map_.end(); | 58 return instance_id_map_.find(app_id) != instance_id_map_.end(); |
| 56 } | 59 } |
| 57 | 60 |
| 58 } // namespace instance_id | 61 } // namespace instance_id |
| OLD | NEW |