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

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

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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/fake_gcm_driver_for_instance_id.h" 5 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/location.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/thread_task_runner_handle.h"
11 #include "components/gcm_driver/gcm_client.h" 13 #include "components/gcm_driver/gcm_client.h"
12 14
13 namespace instance_id { 15 namespace instance_id {
14 16
15 FakeGCMDriverForInstanceID::FakeGCMDriverForInstanceID() { 17 FakeGCMDriverForInstanceID::FakeGCMDriverForInstanceID() {
16 } 18 }
17 19
18 FakeGCMDriverForInstanceID::~FakeGCMDriverForInstanceID() { 20 FakeGCMDriverForInstanceID::~FakeGCMDriverForInstanceID() {
19 } 21 }
20 22
(...skipping 16 matching lines...) Expand all
37 void FakeGCMDriverForInstanceID::GetInstanceIDData( 39 void FakeGCMDriverForInstanceID::GetInstanceIDData(
38 const std::string& app_id, 40 const std::string& app_id,
39 const GetInstanceIDDataCallback& callback) { 41 const GetInstanceIDDataCallback& callback) {
40 auto iter = instance_id_data_.find(app_id); 42 auto iter = instance_id_data_.find(app_id);
41 std::string instance_id; 43 std::string instance_id;
42 std::string extra_data; 44 std::string extra_data;
43 if (iter != instance_id_data_.end()) { 45 if (iter != instance_id_data_.end()) {
44 instance_id = iter->second.first; 46 instance_id = iter->second.first;
45 extra_data = iter->second.second; 47 extra_data = iter->second.second;
46 } 48 }
47 base::MessageLoop::current()->PostTask( 49 base::ThreadTaskRunnerHandle::Get()->PostTask(
48 FROM_HERE, 50 FROM_HERE, base::Bind(callback, instance_id, extra_data));
49 base::Bind(callback, instance_id, extra_data));
50 } 51 }
51 52
52 void FakeGCMDriverForInstanceID::GetToken( 53 void FakeGCMDriverForInstanceID::GetToken(
53 const std::string& app_id, 54 const std::string& app_id,
54 const std::string& authorized_entity, 55 const std::string& authorized_entity,
55 const std::string& scope, 56 const std::string& scope,
56 const std::map<std::string, std::string>& options, 57 const std::map<std::string, std::string>& options,
57 const GetTokenCallback& callback) { 58 const GetTokenCallback& callback) {
58 std::string token; 59 std::string token;
59 std::string key = app_id + authorized_entity + scope; 60 std::string key = app_id + authorized_entity + scope;
60 auto iter = tokens_.find(key); 61 auto iter = tokens_.find(key);
61 if (iter != tokens_.end()) { 62 if (iter != tokens_.end()) {
62 token = iter->second; 63 token = iter->second;
63 } else { 64 } else {
64 token = base::Uint64ToString(base::RandUint64()); 65 token = base::Uint64ToString(base::RandUint64());
65 tokens_[key] = token; 66 tokens_[key] = token;
66 } 67 }
67 68
68 base::MessageLoop::current()->PostTask( 69 base::ThreadTaskRunnerHandle::Get()->PostTask(
69 FROM_HERE, 70 FROM_HERE, base::Bind(callback, token, gcm::GCMClient::SUCCESS));
70 base::Bind(callback, token, gcm::GCMClient::SUCCESS));
71 } 71 }
72 72
73 void FakeGCMDriverForInstanceID::DeleteToken( 73 void FakeGCMDriverForInstanceID::DeleteToken(
74 const std::string& app_id, 74 const std::string& app_id,
75 const std::string& authorized_entity, 75 const std::string& authorized_entity,
76 const std::string& scope, 76 const std::string& scope,
77 const DeleteTokenCallback& callback) { 77 const DeleteTokenCallback& callback) {
78 std::string key = app_id + authorized_entity + scope; 78 std::string key = app_id + authorized_entity + scope;
79 tokens_.erase(key); 79 tokens_.erase(key);
80 base::MessageLoop::current()->PostTask( 80 base::ThreadTaskRunnerHandle::Get()->PostTask(
81 FROM_HERE, 81 FROM_HERE, base::Bind(callback, gcm::GCMClient::SUCCESS));
82 base::Bind(callback, gcm::GCMClient::SUCCESS));
83 } 82 }
84 83
85 } // namespace instance_id 84 } // namespace instance_id
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_driver_desktop_unittest.cc ('k') | components/google/core/browser/google_url_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698