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

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

Issue 2578583002: Provide a mechanism for the GCM driver to send message receipts to GCM.
Patch Set: Created 4 years 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 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/gcm_driver_desktop.h" 5 #include "components/gcm_driver/gcm_driver_desktop.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 const std::string& registration_id, 48 const std::string& registration_id,
49 GCMClient::Result result) override; 49 GCMClient::Result result) override;
50 void OnUnregisterFinished( 50 void OnUnregisterFinished(
51 const linked_ptr<RegistrationInfo>& registration_info, 51 const linked_ptr<RegistrationInfo>& registration_info,
52 GCMClient::Result result) override; 52 GCMClient::Result result) override;
53 void OnSendFinished(const std::string& app_id, 53 void OnSendFinished(const std::string& app_id,
54 const std::string& message_id, 54 const std::string& message_id,
55 GCMClient::Result result) override; 55 GCMClient::Result result) override;
56 void OnMessageReceived(const std::string& app_id, 56 void OnMessageReceived(const std::string& app_id,
57 const IncomingMessage& message) override; 57 const IncomingMessage& message) override;
58 void OnMessageReceivedError(const std::string& app_id,
59 const std::string& message_id,
60 int status) override;
58 void OnMessagesDeleted(const std::string& app_id) override; 61 void OnMessagesDeleted(const std::string& app_id) override;
59 void OnMessageSendError( 62 void OnMessageSendError(
60 const std::string& app_id, 63 const std::string& app_id,
61 const GCMClient::SendErrorDetails& send_error_details) override; 64 const GCMClient::SendErrorDetails& send_error_details) override;
62 void OnSendAcknowledged(const std::string& app_id, 65 void OnSendAcknowledged(const std::string& app_id,
63 const std::string& message_id) override; 66 const std::string& message_id) override;
64 void OnGCMReady(const std::vector<AccountMapping>& account_mappings, 67 void OnGCMReady(const std::vector<AccountMapping>& account_mappings,
65 const base::Time& last_token_fetch_time) override; 68 const base::Time& last_token_fetch_time) override;
66 void OnActivityRecorded() override; 69 void OnActivityRecorded() override;
67 void OnConnected(const net::IPEndPoint& ip_endpoint) override; 70 void OnConnected(const net::IPEndPoint& ip_endpoint) override;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 DCHECK(io_thread_->RunsTasksOnCurrentThread()); 240 DCHECK(io_thread_->RunsTasksOnCurrentThread());
238 241
239 ui_thread_->PostTask( 242 ui_thread_->PostTask(
240 FROM_HERE, 243 FROM_HERE,
241 base::Bind(&GCMDriverDesktop::MessageReceived, 244 base::Bind(&GCMDriverDesktop::MessageReceived,
242 service_, 245 service_,
243 app_id, 246 app_id,
244 message)); 247 message));
245 } 248 }
246 249
250 void GCMDriverDesktop::IOWorker::OnMessageReceivedError(
251 const std::string& app_id,
252 const std::string& message_id,
253 int status) {
254 DCHECK(io_thread_->RunsTasksOnCurrentThread());
255
256 ui_thread_->PostTask(
257 FROM_HERE, base::Bind(&GCMDriverDesktop::MessageReceivedError, service_,
258 app_id, message_id, status));
259 }
260
247 void GCMDriverDesktop::IOWorker::OnMessagesDeleted(const std::string& app_id) { 261 void GCMDriverDesktop::IOWorker::OnMessagesDeleted(const std::string& app_id) {
248 DCHECK(io_thread_->RunsTasksOnCurrentThread()); 262 DCHECK(io_thread_->RunsTasksOnCurrentThread());
249 263
250 ui_thread_->PostTask( 264 ui_thread_->PostTask(
251 FROM_HERE, 265 FROM_HERE,
252 base::Bind(&GCMDriverDesktop::MessagesDeleted, service_, app_id)); 266 base::Bind(&GCMDriverDesktop::MessagesDeleted, service_, app_id));
253 } 267 }
254 268
255 void GCMDriverDesktop::IOWorker::OnMessageSendError( 269 void GCMDriverDesktop::IOWorker::OnMessageSendError(
256 const std::string& app_id, 270 const std::string& app_id,
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 const IncomingMessage& message) { 1233 const IncomingMessage& message) {
1220 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 1234 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
1221 1235
1222 // Drop the event if the service has been stopped. 1236 // Drop the event if the service has been stopped.
1223 if (!gcm_started_) 1237 if (!gcm_started_)
1224 return; 1238 return;
1225 1239
1226 DispatchMessage(app_id, message); 1240 DispatchMessage(app_id, message);
1227 } 1241 }
1228 1242
1243 void GCMDriverDesktop::MessageReceivedError(const std::string& app_id,
1244 const std::string& message_id,
1245 int status) {
1246 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
1247
1248 // Drop the event if the service has been stopped.
1249 if (!gcm_started_)
1250 return;
1251
1252 SendMessageReceipt(app_id, message_id, status);
1253 }
1254
1229 void GCMDriverDesktop::MessagesDeleted(const std::string& app_id) { 1255 void GCMDriverDesktop::MessagesDeleted(const std::string& app_id) {
1230 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 1256 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
1231 1257
1232 // Drop the event if the service has been stopped. 1258 // Drop the event if the service has been stopped.
1233 if (!gcm_started_) 1259 if (!gcm_started_)
1234 return; 1260 return;
1235 1261
1236 GetAppHandler(app_id)->OnMessagesDeleted(app_id); 1262 GetAppHandler(app_id)->OnMessagesDeleted(app_id);
1237 } 1263 }
1238 1264
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 1362
1337 if (std::get<1>(a) < std::get<1>(b)) 1363 if (std::get<1>(a) < std::get<1>(b))
1338 return true; 1364 return true;
1339 if (std::get<1>(a) > std::get<1>(b)) 1365 if (std::get<1>(a) > std::get<1>(b))
1340 return false; 1366 return false;
1341 1367
1342 return std::get<2>(a) < std::get<2>(b); 1368 return std::get<2>(a) < std::get<2>(b);
1343 } 1369 }
1344 1370
1345 } // namespace gcm 1371 } // namespace gcm
OLDNEW
« components/gcm_driver/gcm_driver.cc ('K') | « components/gcm_driver/gcm_driver_desktop.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698