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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/base64.h" | 12 #include "base/base64.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/ptr_util.h" | |
16 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
17 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
19 #include "components/gcm_driver/gcm_driver.h" | 18 #include "components/gcm_driver/gcm_driver.h" |
20 #include "crypto/random.h" | 19 #include "crypto/random.h" |
21 | 20 |
22 namespace instance_id { | 21 namespace instance_id { |
23 | 22 |
24 namespace { | 23 namespace { |
25 | 24 |
(...skipping 16 matching lines...) Expand all Loading... |
42 return InstanceID::UNKNOWN_ERROR; | 41 return InstanceID::UNKNOWN_ERROR; |
43 case gcm::GCMClient::TTL_EXCEEDED: | 42 case gcm::GCMClient::TTL_EXCEEDED: |
44 NOTREACHED(); | 43 NOTREACHED(); |
45 break; | 44 break; |
46 } | 45 } |
47 return InstanceID::UNKNOWN_ERROR; | 46 return InstanceID::UNKNOWN_ERROR; |
48 } | 47 } |
49 | 48 |
50 } // namespace | 49 } // namespace |
51 | 50 |
52 // static | |
53 std::unique_ptr<InstanceID> InstanceID::CreateInternal( | |
54 const std::string& app_id, | |
55 gcm::GCMDriver* gcm_driver) { | |
56 return base::WrapUnique(new InstanceIDImpl(app_id, gcm_driver)); | |
57 } | |
58 | |
59 InstanceIDImpl::InstanceIDImpl(const std::string& app_id, | 51 InstanceIDImpl::InstanceIDImpl(const std::string& app_id, |
60 gcm::GCMDriver* gcm_driver) | 52 gcm::GCMDriver* gcm_driver) |
61 : InstanceID(app_id, gcm_driver), weak_ptr_factory_(this) { | 53 : InstanceID(app_id, gcm_driver), weak_ptr_factory_(this) { |
62 Handler()->GetInstanceIDData( | 54 Handler()->GetInstanceIDData( |
63 app_id, base::Bind(&InstanceIDImpl::GetInstanceIDDataCompleted, | 55 app_id, base::Bind(&InstanceIDImpl::GetInstanceIDDataCompleted, |
64 weak_ptr_factory_.GetWeakPtr())); | 56 weak_ptr_factory_.GetWeakPtr())); |
65 } | 57 } |
66 | 58 |
67 InstanceIDImpl::~InstanceIDImpl() { | 59 InstanceIDImpl::~InstanceIDImpl() { |
68 } | 60 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 256 } |
265 | 257 |
266 void InstanceIDImpl::RunWhenReady(base::Closure task) { | 258 void InstanceIDImpl::RunWhenReady(base::Closure task) { |
267 if (!delayed_task_controller_.CanRunTaskWithoutDelay()) | 259 if (!delayed_task_controller_.CanRunTaskWithoutDelay()) |
268 delayed_task_controller_.AddTask(task); | 260 delayed_task_controller_.AddTask(task); |
269 else | 261 else |
270 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); | 262 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); |
271 } | 263 } |
272 | 264 |
273 } // namespace instance_id | 265 } // namespace instance_id |
OLD | NEW |