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_impl.h" | 5 #include "components/gcm_driver/instance_id/instance_id_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
13 #include "components/gcm_driver/gcm_driver_desktop.h" | 14 #include "components/gcm_driver/gcm_driver_desktop.h" |
14 #include "crypto/random.h" | 15 #include "crypto/random.h" |
15 | 16 |
16 namespace instance_id { | 17 namespace instance_id { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 InstanceID::Result GCMClientResultToInstanceIDResult( | 21 InstanceID::Result GCMClientResultToInstanceIDResult( |
(...skipping 16 matching lines...) Expand all Loading... |
37 default: | 38 default: |
38 NOTREACHED() << "Unexpected value of result cannot be converted: " | 39 NOTREACHED() << "Unexpected value of result cannot be converted: " |
39 << result; | 40 << result; |
40 } | 41 } |
41 return InstanceID::UNKNOWN_ERROR; | 42 return InstanceID::UNKNOWN_ERROR; |
42 } | 43 } |
43 | 44 |
44 } // namespace | 45 } // namespace |
45 | 46 |
46 // static | 47 // static |
47 InstanceID* InstanceID::Create(const std::string& app_id, | 48 scoped_ptr<InstanceID> InstanceID::Create(const std::string& app_id, |
48 gcm::GCMDriver* gcm_driver) { | 49 gcm::GCMDriver* gcm_driver) { |
49 return new InstanceIDImpl(app_id, gcm_driver); | 50 return make_scoped_ptr(new InstanceIDImpl(app_id, gcm_driver)); |
50 } | 51 } |
51 | 52 |
52 InstanceIDImpl::InstanceIDImpl(const std::string& app_id, | 53 InstanceIDImpl::InstanceIDImpl(const std::string& app_id, |
53 gcm::GCMDriver* gcm_driver) | 54 gcm::GCMDriver* gcm_driver) |
54 : InstanceID(app_id), | 55 : InstanceID(app_id), |
55 gcm_driver_(gcm_driver), | 56 gcm_driver_(gcm_driver), |
56 load_from_store_(false), | 57 load_from_store_(false), |
57 weak_ptr_factory_(this) { | 58 weak_ptr_factory_(this) { |
58 GetInstanceIDHandler()->GetInstanceIDData( | 59 GetInstanceIDHandler()->GetInstanceIDData( |
59 app_id, | 60 app_id, |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 creation_time_ = base::Time::Now(); | 280 creation_time_ = base::Time::Now(); |
280 | 281 |
281 // Save to the persistent store. | 282 // Save to the persistent store. |
282 GetInstanceIDHandler()->AddInstanceIDData( | 283 GetInstanceIDHandler()->AddInstanceIDData( |
283 app_id(), | 284 app_id(), |
284 id_, | 285 id_, |
285 base::Int64ToString(creation_time_.ToInternalValue())); | 286 base::Int64ToString(creation_time_.ToInternalValue())); |
286 } | 287 } |
287 | 288 |
288 } // namespace instance_id | 289 } // namespace instance_id |
OLD | NEW |