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

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

Issue 344033002: Remove GCMDriver::IsGCMClientReady (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 scoped_ptr<GCMClientFactory> gcm_client_factory, 349 scoped_ptr<GCMClientFactory> gcm_client_factory,
350 const GCMClient::ChromeBuildInfo& chrome_build_info, 350 const GCMClient::ChromeBuildInfo& chrome_build_info,
351 const base::FilePath& store_path, 351 const base::FilePath& store_path,
352 const scoped_refptr<net::URLRequestContextGetter>& request_context, 352 const scoped_refptr<net::URLRequestContextGetter>& request_context,
353 const scoped_refptr<base::SequencedTaskRunner>& ui_thread, 353 const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
354 const scoped_refptr<base::SequencedTaskRunner>& io_thread, 354 const scoped_refptr<base::SequencedTaskRunner>& io_thread,
355 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) 355 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner)
356 : signed_in_(false), 356 : signed_in_(false),
357 gcm_started_(false), 357 gcm_started_(false),
358 gcm_enabled_(true), 358 gcm_enabled_(true),
359 gcm_client_ready_(false),
360 connected_(false), 359 connected_(false),
361 ui_thread_(ui_thread), 360 ui_thread_(ui_thread),
362 io_thread_(io_thread), 361 io_thread_(io_thread),
363 weak_ptr_factory_(this) { 362 weak_ptr_factory_(this) {
364 // Create and initialize the GCMClient. Note that this does not initiate the 363 // Create and initialize the GCMClient. Note that this does not initiate the
365 // GCM check-in. 364 // GCM check-in.
366 io_worker_.reset(new IOWorker(ui_thread, io_thread)); 365 io_worker_.reset(new IOWorker(ui_thread, io_thread));
367 io_thread_->PostTask( 366 io_thread_->PostTask(
368 FROM_HERE, 367 FROM_HERE,
369 base::Bind(&GCMDriverDesktop::IOWorker::Initialize, 368 base::Bind(&GCMDriverDesktop::IOWorker::Initialize,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 GCMClient* GCMDriverDesktop::GetGCMClientForTesting() const { 544 GCMClient* GCMDriverDesktop::GetGCMClientForTesting() const {
546 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 545 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
547 return io_worker_ ? io_worker_->gcm_client_for_testing() : NULL; 546 return io_worker_ ? io_worker_->gcm_client_for_testing() : NULL;
548 } 547 }
549 548
550 bool GCMDriverDesktop::IsStarted() const { 549 bool GCMDriverDesktop::IsStarted() const {
551 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 550 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
552 return gcm_started_; 551 return gcm_started_;
553 } 552 }
554 553
555 bool GCMDriverDesktop::IsGCMClientReady() const {
556 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
557 return gcm_client_ready_;
558 }
559
560 bool GCMDriverDesktop::IsConnected() const { 554 bool GCMDriverDesktop::IsConnected() const {
561 return connected_; 555 return connected_;
562 } 556 }
563 557
564 void GCMDriverDesktop::GetGCMStatistics( 558 void GCMDriverDesktop::GetGCMStatistics(
565 const GetGCMStatisticsCallback& callback, 559 const GetGCMStatisticsCallback& callback,
566 bool clear_logs) { 560 bool clear_logs) {
567 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 561 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
568 DCHECK(!callback.is_null()); 562 DCHECK(!callback.is_null());
569 563
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 return GCMClient::SUCCESS; 613 return GCMClient::SUCCESS;
620 } 614 }
621 615
622 void GCMDriverDesktop::RemoveCachedData() { 616 void GCMDriverDesktop::RemoveCachedData() {
623 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 617 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
624 // Remove all the queued tasks since they no longer make sense after 618 // Remove all the queued tasks since they no longer make sense after
625 // GCM service is stopped. 619 // GCM service is stopped.
626 weak_ptr_factory_.InvalidateWeakPtrs(); 620 weak_ptr_factory_.InvalidateWeakPtrs();
627 621
628 gcm_started_ = false; 622 gcm_started_ = false;
629 gcm_client_ready_ = false;
630 delayed_task_controller_.reset(); 623 delayed_task_controller_.reset();
631 ClearCallbacks(); 624 ClearCallbacks();
632 } 625 }
633 626
634 void GCMDriverDesktop::MessageReceived( 627 void GCMDriverDesktop::MessageReceived(
635 const std::string& app_id, 628 const std::string& app_id,
636 const GCMClient::IncomingMessage& message) { 629 const GCMClient::IncomingMessage& message) {
637 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 630 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
638 631
639 // Drop the event if the service has been stopped. 632 // Drop the event if the service has been stopped.
(...skipping 21 matching lines...) Expand all
661 // Drop the event if the service has been stopped. 654 // Drop the event if the service has been stopped.
662 if (!gcm_started_) 655 if (!gcm_started_)
663 return; 656 return;
664 657
665 GetAppHandler(app_id)->OnSendError(app_id, send_error_details); 658 GetAppHandler(app_id)->OnSendError(app_id, send_error_details);
666 } 659 }
667 660
668 void GCMDriverDesktop::GCMClientReady() { 661 void GCMDriverDesktop::GCMClientReady() {
669 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 662 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
670 663
671 if (gcm_client_ready_)
672 return;
673 gcm_client_ready_ = true;
674
675 delayed_task_controller_->SetReady(); 664 delayed_task_controller_->SetReady();
676 } 665 }
677 666
678 void GCMDriverDesktop::OnConnected(const net::IPEndPoint& ip_endpoint) { 667 void GCMDriverDesktop::OnConnected(const net::IPEndPoint& ip_endpoint) {
679 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 668 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
680 669
681 connected_ = true; 670 connected_ = true;
682 671
683 // Drop the event if signed out. 672 // Drop the event if signed out.
684 if (!signed_in_) 673 if (!signed_in_)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 706
718 // Normally request_gcm_statistics_callback_ would not be null. 707 // Normally request_gcm_statistics_callback_ would not be null.
719 if (!request_gcm_statistics_callback_.is_null()) 708 if (!request_gcm_statistics_callback_.is_null())
720 request_gcm_statistics_callback_.Run(stats); 709 request_gcm_statistics_callback_.Run(stats);
721 else 710 else
722 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; 711 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL.";
723 } 712 }
724 713
725 } // namespace gcm 714 } // namespace gcm
726 715
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