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

Side by Side Diff: chrome/browser/gcm/fake_gcm_profile_service.cc

Issue 2825003002: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/{a,b,c,d,e,f,g}* (Closed)
Patch Set: split rest of changes to 3 CLs Created 3 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/gcm/fake_gcm_profile_service.h" 5 #include "chrome/browser/gcm/fake_gcm_profile_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return; // Drop request. 97 return; // Drop request.
98 98
99 // Generate fake registration IDs, encoding the number of sender IDs (used by 99 // Generate fake registration IDs, encoding the number of sender IDs (used by
100 // GcmApiTest.RegisterValidation), then an incrementing count (even for the 100 // GcmApiTest.RegisterValidation), then an incrementing count (even for the
101 // same app_id - there's no caching) so tests can distinguish registrations. 101 // same app_id - there's no caching) so tests can distinguish registrations.
102 std::string registration_id = base::StringPrintf( 102 std::string registration_id = base::StringPrintf(
103 "%" PRIuS "-%d", sender_ids.size(), registration_count_); 103 "%" PRIuS "-%d", sender_ids.size(), registration_count_);
104 ++registration_count_; 104 ++registration_count_;
105 105
106 base::ThreadTaskRunnerHandle::Get()->PostTask( 106 base::ThreadTaskRunnerHandle::Get()->PostTask(
107 FROM_HERE, 107 FROM_HERE, base::BindOnce(&CustomFakeGCMDriver::DoRegister,
108 base::Bind(&CustomFakeGCMDriver::DoRegister, weak_factory_.GetWeakPtr(), 108 weak_factory_.GetWeakPtr(), app_id, sender_ids,
109 app_id, sender_ids, registration_id)); 109 registration_id));
110 } 110 }
111 111
112 void FakeGCMProfileService::CustomFakeGCMDriver::DoRegister( 112 void FakeGCMProfileService::CustomFakeGCMDriver::DoRegister(
113 const std::string& app_id, 113 const std::string& app_id,
114 const std::vector<std::string>& sender_ids, 114 const std::vector<std::string>& sender_ids,
115 const std::string& registration_id) { 115 const std::string& registration_id) {
116 if (service_->collect_) { 116 if (service_->collect_) {
117 service_->last_registered_app_id_ = app_id; 117 service_->last_registered_app_id_ = app_id;
118 service_->last_registered_sender_ids_ = sender_ids; 118 service_->last_registered_sender_ids_ = sender_ids;
119 } 119 }
120 RegisterFinished(app_id, registration_id, GCMClient::SUCCESS); 120 RegisterFinished(app_id, registration_id, GCMClient::SUCCESS);
121 } 121 }
122 122
123 void FakeGCMProfileService::CustomFakeGCMDriver::UnregisterImpl( 123 void FakeGCMProfileService::CustomFakeGCMDriver::UnregisterImpl(
124 const std::string& app_id) { 124 const std::string& app_id) {
125 if (service_->is_offline_) 125 if (service_->is_offline_)
126 return; // Drop request. 126 return; // Drop request.
127 127
128 GCMClient::Result result = GCMClient::SUCCESS; 128 GCMClient::Result result = GCMClient::SUCCESS;
129 if (!service_->unregister_responses_.empty()) { 129 if (!service_->unregister_responses_.empty()) {
130 result = service_->unregister_responses_.front(); 130 result = service_->unregister_responses_.front();
131 service_->unregister_responses_.pop_front(); 131 service_->unregister_responses_.pop_front();
132 } 132 }
133 base::ThreadTaskRunnerHandle::Get()->PostTask( 133 base::ThreadTaskRunnerHandle::Get()->PostTask(
134 FROM_HERE, base::Bind(&CustomFakeGCMDriver::UnregisterFinished, 134 FROM_HERE, base::BindOnce(&CustomFakeGCMDriver::UnregisterFinished,
135 weak_factory_.GetWeakPtr(), app_id, result)); 135 weak_factory_.GetWeakPtr(), app_id, result));
136 } 136 }
137 137
138 void FakeGCMProfileService::CustomFakeGCMDriver::UnregisterWithSenderIdImpl( 138 void FakeGCMProfileService::CustomFakeGCMDriver::UnregisterWithSenderIdImpl(
139 const std::string& app_id, 139 const std::string& app_id,
140 const std::string& sender_id) { 140 const std::string& sender_id) {
141 NOTREACHED() << "This Android-specific method is not yet faked."; 141 NOTREACHED() << "This Android-specific method is not yet faked.";
142 } 142 }
143 143
144 void FakeGCMProfileService::CustomFakeGCMDriver::SendImpl( 144 void FakeGCMProfileService::CustomFakeGCMDriver::SendImpl(
145 const std::string& app_id, 145 const std::string& app_id,
146 const std::string& receiver_id, 146 const std::string& receiver_id,
147 const OutgoingMessage& message) { 147 const OutgoingMessage& message) {
148 if (service_->is_offline_) 148 if (service_->is_offline_)
149 return; // Drop request. 149 return; // Drop request.
150 150
151 base::ThreadTaskRunnerHandle::Get()->PostTask( 151 base::ThreadTaskRunnerHandle::Get()->PostTask(
152 FROM_HERE, 152 FROM_HERE,
153 base::Bind(&CustomFakeGCMDriver::DoSend, weak_factory_.GetWeakPtr(), 153 base::BindOnce(&CustomFakeGCMDriver::DoSend, weak_factory_.GetWeakPtr(),
154 app_id, receiver_id, message)); 154 app_id, receiver_id, message));
155 } 155 }
156 156
157 void FakeGCMProfileService::CustomFakeGCMDriver::DoSend( 157 void FakeGCMProfileService::CustomFakeGCMDriver::DoSend(
158 const std::string& app_id, 158 const std::string& app_id,
159 const std::string& receiver_id, 159 const std::string& receiver_id,
160 const OutgoingMessage& message) { 160 const OutgoingMessage& message) {
161 if (service_->collect_) { 161 if (service_->collect_) {
162 service_->last_sent_message_ = message; 162 service_->last_sent_message_ = message;
163 service_->last_receiver_id_ = receiver_id; 163 service_->last_receiver_id_ = receiver_id;
164 } 164 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 216 }
217 217
218 void FakeGCMProfileService::DispatchMessage(const std::string& app_id, 218 void FakeGCMProfileService::DispatchMessage(const std::string& app_id,
219 const IncomingMessage& message) { 219 const IncomingMessage& message) {
220 CustomFakeGCMDriver* custom_driver = 220 CustomFakeGCMDriver* custom_driver =
221 static_cast<CustomFakeGCMDriver*>(driver()); 221 static_cast<CustomFakeGCMDriver*>(driver());
222 custom_driver->OnDispatchMessage(app_id, message); 222 custom_driver->OnDispatchMessage(app_id, message);
223 } 223 }
224 224
225 } // namespace gcm 225 } // namespace gcm
OLDNEW
« no previous file with comments | « chrome/browser/file_select_helper.cc ('k') | chrome/browser/geolocation/access_token_store_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698