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

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

Issue 442123003: [GCM] Adding the OnSendAcknowledgement event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing code review comments. Created 6 years, 4 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 | Annotate | Revision Log
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 virtual void OnSendFinished(const std::string& app_id, 101 virtual void OnSendFinished(const std::string& app_id,
102 const std::string& message_id, 102 const std::string& message_id,
103 GCMClient::Result result) OVERRIDE; 103 GCMClient::Result result) OVERRIDE;
104 virtual void OnMessageReceived( 104 virtual void OnMessageReceived(
105 const std::string& app_id, 105 const std::string& app_id,
106 const GCMClient::IncomingMessage& message) OVERRIDE; 106 const GCMClient::IncomingMessage& message) OVERRIDE;
107 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; 107 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE;
108 virtual void OnMessageSendError( 108 virtual void OnMessageSendError(
109 const std::string& app_id, 109 const std::string& app_id,
110 const GCMClient::SendErrorDetails& send_error_details) OVERRIDE; 110 const GCMClient::SendErrorDetails& send_error_details) OVERRIDE;
111 virtual void OnSendAcknowledged(const std::string& app_id,
112 const std::string& message_id) OVERRIDE;
111 virtual void OnGCMReady() OVERRIDE; 113 virtual void OnGCMReady() OVERRIDE;
112 virtual void OnActivityRecorded() OVERRIDE; 114 virtual void OnActivityRecorded() OVERRIDE;
113 virtual void OnConnected(const net::IPEndPoint& ip_endpoint) OVERRIDE; 115 virtual void OnConnected(const net::IPEndPoint& ip_endpoint) OVERRIDE;
114 virtual void OnDisconnected() OVERRIDE; 116 virtual void OnDisconnected() OVERRIDE;
115 117
116 // Called on IO thread. 118 // Called on IO thread.
117 void Initialize( 119 void Initialize(
118 scoped_ptr<GCMClientFactory> gcm_client_factory, 120 scoped_ptr<GCMClientFactory> gcm_client_factory,
119 const GCMClient::ChromeBuildInfo& chrome_build_info, 121 const GCMClient::ChromeBuildInfo& chrome_build_info,
120 const base::FilePath& store_path, 122 const base::FilePath& store_path,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 const std::string& app_id, 241 const std::string& app_id,
240 const GCMClient::SendErrorDetails& send_error_details) { 242 const GCMClient::SendErrorDetails& send_error_details) {
241 DCHECK(io_thread_->RunsTasksOnCurrentThread()); 243 DCHECK(io_thread_->RunsTasksOnCurrentThread());
242 244
243 ui_thread_->PostTask( 245 ui_thread_->PostTask(
244 FROM_HERE, 246 FROM_HERE,
245 base::Bind(&GCMDriverDesktop::MessageSendError, service_, app_id, 247 base::Bind(&GCMDriverDesktop::MessageSendError, service_, app_id,
246 send_error_details)); 248 send_error_details));
247 } 249 }
248 250
251 void GCMDriverDesktop::IOWorker::OnSendAcknowledged(
252 const std::string& app_id,
253 const std::string& message_id) {
254 DCHECK(io_thread_->RunsTasksOnCurrentThread());
255
256 ui_thread_->PostTask(
257 FROM_HERE,
258 base::Bind(
259 &GCMDriverDesktop::SendAcknowledged, service_, app_id, message_id));
260 }
261
249 void GCMDriverDesktop::IOWorker::OnGCMReady() { 262 void GCMDriverDesktop::IOWorker::OnGCMReady() {
250 ui_thread_->PostTask( 263 ui_thread_->PostTask(
251 FROM_HERE, 264 FROM_HERE,
252 base::Bind(&GCMDriverDesktop::GCMClientReady, service_)); 265 base::Bind(&GCMDriverDesktop::GCMClientReady, service_));
253 } 266 }
254 267
255 void GCMDriverDesktop::IOWorker::OnActivityRecorded() { 268 void GCMDriverDesktop::IOWorker::OnActivityRecorded() {
256 DCHECK(io_thread_->RunsTasksOnCurrentThread()); 269 DCHECK(io_thread_->RunsTasksOnCurrentThread());
257 // When an activity is recorded, get all the stats and refresh the UI of 270 // When an activity is recorded, get all the stats and refresh the UI of
258 // gcm-internals page. 271 // gcm-internals page.
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 const GCMClient::SendErrorDetails& send_error_details) { 686 const GCMClient::SendErrorDetails& send_error_details) {
674 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 687 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
675 688
676 // Drop the event if the service has been stopped. 689 // Drop the event if the service has been stopped.
677 if (!gcm_started_) 690 if (!gcm_started_)
678 return; 691 return;
679 692
680 GetAppHandler(app_id)->OnSendError(app_id, send_error_details); 693 GetAppHandler(app_id)->OnSendError(app_id, send_error_details);
681 } 694 }
682 695
696 void GCMDriverDesktop::SendAcknowledged(const std::string& app_id,
697 const std::string& message_id) {
698 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
699
700 // Drop the event if the service has been stopped.
701 if (!gcm_started_)
702 return;
703
704 GetAppHandler(app_id)->OnSendAcknowledged(app_id, message_id);
705 }
706
683 void GCMDriverDesktop::GCMClientReady() { 707 void GCMDriverDesktop::GCMClientReady() {
684 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 708 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
685 709
686 delayed_task_controller_->SetReady(); 710 delayed_task_controller_->SetReady();
687 } 711 }
688 712
689 void GCMDriverDesktop::OnConnected(const net::IPEndPoint& ip_endpoint) { 713 void GCMDriverDesktop::OnConnected(const net::IPEndPoint& ip_endpoint) {
690 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 714 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
691 715
692 connected_ = true; 716 connected_ = true;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 752
729 // Normally request_gcm_statistics_callback_ would not be null. 753 // Normally request_gcm_statistics_callback_ would not be null.
730 if (!request_gcm_statistics_callback_.is_null()) 754 if (!request_gcm_statistics_callback_.is_null())
731 request_gcm_statistics_callback_.Run(stats); 755 request_gcm_statistics_callback_.Run(stats);
732 else 756 else
733 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; 757 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL.";
734 } 758 }
735 759
736 } // namespace gcm 760 } // namespace gcm
737 761
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_driver_desktop.h ('k') | components/gcm_driver/gcm_driver_desktop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698