Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: components/gcm_driver/instance_id/instance_id_impl.cc

Issue 2847923002: [Chromecast] Add method to CastCdm for the session expiration updating. (Closed)
Patch Set: Add InstanceIDFactory class to help with testing. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/gcm_driver/instance_id/instance_id_factory.h ('k') | components/gcm_driver/instance_id/instance_id_impl_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698