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

Side by Side Diff: components/gcm_driver/fake_gcm_client.cc

Issue 1137463003: Support getting and deleting token for Instance ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch to land 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
« no previous file with comments | « components/gcm_driver/fake_gcm_client.h ('k') | components/gcm_driver/fake_gcm_driver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/fake_gcm_client.h" 5 #include "components/gcm_driver/fake_gcm_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 base::Bind(&FakeGCMClient::Started, 67 base::Bind(&FakeGCMClient::Started,
68 weak_ptr_factory_.GetWeakPtr())); 68 weak_ptr_factory_.GetWeakPtr()));
69 } 69 }
70 70
71 void FakeGCMClient::Stop() { 71 void FakeGCMClient::Stop() {
72 DCHECK(io_thread_->RunsTasksOnCurrentThread()); 72 DCHECK(io_thread_->RunsTasksOnCurrentThread());
73 started_ = false; 73 started_ = false;
74 delegate_->OnDisconnected(); 74 delegate_->OnDisconnected();
75 } 75 }
76 76
77 void FakeGCMClient::Register(const std::string& app_id, 77 void FakeGCMClient::Register(
78 const std::vector<std::string>& sender_ids) { 78 const linked_ptr<RegistrationInfo>& registration_info) {
79 DCHECK(io_thread_->RunsTasksOnCurrentThread()); 79 DCHECK(io_thread_->RunsTasksOnCurrentThread());
80 80
81 std::string registration_id = GetRegistrationIdFromSenderIds(sender_ids); 81 GCMRegistrationInfo* gcm_registration_info =
82 GCMRegistrationInfo::FromRegistrationInfo(registration_info.get());
83 DCHECK(gcm_registration_info);
84
85 std::string registration_id = GetRegistrationIdFromSenderIds(
86 gcm_registration_info->sender_ids);
82 base::MessageLoop::current()->PostTask( 87 base::MessageLoop::current()->PostTask(
83 FROM_HERE, 88 FROM_HERE,
84 base::Bind(&FakeGCMClient::RegisterFinished, 89 base::Bind(&FakeGCMClient::RegisterFinished,
85 weak_ptr_factory_.GetWeakPtr(), 90 weak_ptr_factory_.GetWeakPtr(),
86 app_id, 91 registration_info,
87 registration_id)); 92 registration_id));
88 } 93 }
89 94
90 void FakeGCMClient::Unregister(const std::string& app_id) { 95 void FakeGCMClient::Unregister(
96 const linked_ptr<RegistrationInfo>& registration_info) {
91 DCHECK(io_thread_->RunsTasksOnCurrentThread()); 97 DCHECK(io_thread_->RunsTasksOnCurrentThread());
92 98
93 base::MessageLoop::current()->PostTask( 99 base::MessageLoop::current()->PostTask(
94 FROM_HERE, 100 FROM_HERE,
95 base::Bind(&FakeGCMClient::UnregisterFinished, 101 base::Bind(&FakeGCMClient::UnregisterFinished,
96 weak_ptr_factory_.GetWeakPtr(), 102 weak_ptr_factory_.GetWeakPtr(),
97 app_id)); 103 registration_info));
98 } 104 }
99 105
100 void FakeGCMClient::Send(const std::string& app_id, 106 void FakeGCMClient::Send(const std::string& app_id,
101 const std::string& receiver_id, 107 const std::string& receiver_id,
102 const OutgoingMessage& message) { 108 const OutgoingMessage& message) {
103 DCHECK(io_thread_->RunsTasksOnCurrentThread()); 109 DCHECK(io_thread_->RunsTasksOnCurrentThread());
104 110
105 base::MessageLoop::current()->PostTask( 111 base::MessageLoop::current()->PostTask(
106 FROM_HERE, 112 FROM_HERE,
107 base::Bind(&FakeGCMClient::SendFinished, 113 base::Bind(&FakeGCMClient::SendFinished,
(...skipping 23 matching lines...) Expand all
131 void FakeGCMClient::RemoveAccountMapping(const std::string& account_id) { 137 void FakeGCMClient::RemoveAccountMapping(const std::string& account_id) {
132 } 138 }
133 139
134 void FakeGCMClient::SetLastTokenFetchTime(const base::Time& time) { 140 void FakeGCMClient::SetLastTokenFetchTime(const base::Time& time) {
135 } 141 }
136 142
137 void FakeGCMClient::UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) { 143 void FakeGCMClient::UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) {
138 } 144 }
139 145
140 void FakeGCMClient::AddInstanceIDData(const std::string& app_id, 146 void FakeGCMClient::AddInstanceIDData(const std::string& app_id,
141 const std::string& instance_id_data) { 147 const std::string& instance_id,
148 const std::string& extra_data) {
142 } 149 }
143 150
144 void FakeGCMClient::RemoveInstanceIDData(const std::string& app_id) { 151 void FakeGCMClient::RemoveInstanceIDData(const std::string& app_id) {
145 } 152 }
146 153
147 std::string FakeGCMClient::GetInstanceIDData(const std::string& app_id) { 154 void FakeGCMClient::GetInstanceIDData(const std::string& app_id,
148 return std::string(); 155 std::string* instance_id,
156 std::string* extra_data) {
149 } 157 }
150 158
151 void FakeGCMClient::AddHeartbeatInterval(const std::string& scope, 159 void FakeGCMClient::AddHeartbeatInterval(const std::string& scope,
152 int interval_ms) { 160 int interval_ms) {
153 } 161 }
154 162
155 void FakeGCMClient::RemoveHeartbeatInterval(const std::string& scope) { 163 void FakeGCMClient::RemoveHeartbeatInterval(const std::string& scope) {
156 } 164 }
157 165
158 void FakeGCMClient::PerformDelayedStart() { 166 void FakeGCMClient::PerformDelayedStart() {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 212 }
205 } 213 }
206 return registration_id; 214 return registration_id;
207 } 215 }
208 216
209 void FakeGCMClient::Started() { 217 void FakeGCMClient::Started() {
210 delegate_->OnGCMReady(std::vector<AccountMapping>(), base::Time()); 218 delegate_->OnGCMReady(std::vector<AccountMapping>(), base::Time());
211 delegate_->OnConnected(net::IPEndPoint()); 219 delegate_->OnConnected(net::IPEndPoint());
212 } 220 }
213 221
214 void FakeGCMClient::RegisterFinished(const std::string& app_id, 222 void FakeGCMClient::RegisterFinished(
215 const std::string& registrion_id) { 223 const linked_ptr<RegistrationInfo>& registration_info,
224 const std::string& registrion_id) {
216 delegate_->OnRegisterFinished( 225 delegate_->OnRegisterFinished(
217 app_id, registrion_id, registrion_id.empty() ? SERVER_ERROR : SUCCESS); 226 registration_info,
227 registrion_id,
228 registrion_id.empty() ? SERVER_ERROR : SUCCESS);
218 } 229 }
219 230
220 void FakeGCMClient::UnregisterFinished(const std::string& app_id) { 231 void FakeGCMClient::UnregisterFinished(
221 delegate_->OnUnregisterFinished(app_id, GCMClient::SUCCESS); 232 const linked_ptr<RegistrationInfo>& registration_info) {
233 delegate_->OnUnregisterFinished(registration_info, GCMClient::SUCCESS);
222 } 234 }
223 235
224 void FakeGCMClient::SendFinished(const std::string& app_id, 236 void FakeGCMClient::SendFinished(const std::string& app_id,
225 const OutgoingMessage& message) { 237 const OutgoingMessage& message) {
226 delegate_->OnSendFinished(app_id, message.id, SUCCESS); 238 delegate_->OnSendFinished(app_id, message.id, SUCCESS);
227 239
228 // Simulate send error if message id contains a hint. 240 // Simulate send error if message id contains a hint.
229 if (message.id.find("error") != std::string::npos) { 241 if (message.id.find("error") != std::string::npos) {
230 SendErrorDetails send_error_details; 242 SendErrorDetails send_error_details;
231 send_error_details.message_id = message.id; 243 send_error_details.message_id = message.id;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 delegate_->OnMessageSendError(app_id, send_error_details); 280 delegate_->OnMessageSendError(app_id, send_error_details);
269 } 281 }
270 282
271 void FakeGCMClient::SendAcknowledgement(const std::string& app_id, 283 void FakeGCMClient::SendAcknowledgement(const std::string& app_id,
272 const std::string& message_id) { 284 const std::string& message_id) {
273 if (delegate_) 285 if (delegate_)
274 delegate_->OnSendAcknowledged(app_id, message_id); 286 delegate_->OnSendAcknowledged(app_id, message_id);
275 } 287 }
276 288
277 } // namespace gcm 289 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/fake_gcm_client.h ('k') | components/gcm_driver/fake_gcm_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698