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 "components/gcm_driver/instance_id/instance_id.h" | 8 #include "components/gcm_driver/instance_id/instance_id.h" |
9 | 9 |
10 namespace instance_id { | 10 namespace instance_id { |
(...skipping 20 matching lines...) Expand all Loading... |
31 InstanceIDDriver::InstanceIDDriver(gcm::GCMDriver* gcm_driver) | 31 InstanceIDDriver::InstanceIDDriver(gcm::GCMDriver* gcm_driver) |
32 : gcm_driver_(gcm_driver) { | 32 : gcm_driver_(gcm_driver) { |
33 } | 33 } |
34 | 34 |
35 InstanceIDDriver::~InstanceIDDriver() { | 35 InstanceIDDriver::~InstanceIDDriver() { |
36 } | 36 } |
37 | 37 |
38 InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) { | 38 InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) { |
39 auto iter = instance_id_map_.find(app_id); | 39 auto iter = instance_id_map_.find(app_id); |
40 if (iter != instance_id_map_.end()) | 40 if (iter != instance_id_map_.end()) |
41 return iter->second; | 41 return iter->second.get(); |
42 | 42 |
43 scoped_ptr<InstanceID> instance_id = InstanceID::Create(app_id, gcm_driver_); | 43 scoped_ptr<InstanceID> instance_id = InstanceID::Create(app_id, gcm_driver_); |
44 InstanceID* instance_id_ptr = instance_id.get(); | 44 InstanceID* instance_id_ptr = instance_id.get(); |
45 instance_id_map_.insert(app_id, instance_id.Pass()); | 45 instance_id_map_.insert(std::make_pair(app_id, std::move(instance_id))); |
46 return instance_id_ptr; | 46 return instance_id_ptr; |
47 } | 47 } |
48 | 48 |
49 void InstanceIDDriver::RemoveInstanceID(const std::string& app_id) { | 49 void InstanceIDDriver::RemoveInstanceID(const std::string& app_id) { |
50 instance_id_map_.erase(app_id); | 50 instance_id_map_.erase(app_id); |
51 } | 51 } |
52 | 52 |
53 bool InstanceIDDriver::ExistsInstanceID(const std::string& app_id) const { | 53 bool InstanceIDDriver::ExistsInstanceID(const std::string& app_id) const { |
54 return instance_id_map_.find(app_id) != instance_id_map_.end(); | 54 return instance_id_map_.find(app_id) != instance_id_map_.end(); |
55 } | 55 } |
56 | 56 |
57 } // namespace instance_id | 57 } // namespace instance_id |
OLD | NEW |