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

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

Issue 330733002: Move IdentityProvider usage from GCMDriverDesktop to GCMProfileService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix after sync 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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/sequenced_task_runner.h" 14 #include "base/sequenced_task_runner.h"
15 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
16 #include "components/gcm_driver/gcm_app_handler.h" 16 #include "components/gcm_driver/gcm_app_handler.h"
17 #include "components/gcm_driver/gcm_client_factory.h" 17 #include "components/gcm_driver/gcm_client_factory.h"
18 #include "components/gcm_driver/system_encryptor.h" 18 #include "components/gcm_driver/system_encryptor.h"
19 #include "google_apis/gaia/oauth2_token_service.h"
20 #include "net/base/ip_endpoint.h" 19 #include "net/base/ip_endpoint.h"
21 #include "net/url_request/url_request_context_getter.h" 20 #include "net/url_request/url_request_context_getter.h"
22 21
23 namespace gcm { 22 namespace gcm {
24 23
25 namespace { 24 namespace {
26 25
27 // Empty string is reserved for the default app handler. 26 // Empty string is reserved for the default app handler.
28 const char kDefaultAppHandler[] = ""; 27 const char kDefaultAppHandler[] = "";
29 28
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 virtual void OnGCMReady() OVERRIDE; 111 virtual void OnGCMReady() OVERRIDE;
113 virtual void OnActivityRecorded() OVERRIDE; 112 virtual void OnActivityRecorded() OVERRIDE;
114 virtual void OnConnected(const net::IPEndPoint& ip_endpoint) OVERRIDE; 113 virtual void OnConnected(const net::IPEndPoint& ip_endpoint) OVERRIDE;
115 virtual void OnDisconnected() OVERRIDE; 114 virtual void OnDisconnected() OVERRIDE;
116 115
117 // Called on IO thread. 116 // Called on IO thread.
118 void Initialize( 117 void Initialize(
119 scoped_ptr<GCMClientFactory> gcm_client_factory, 118 scoped_ptr<GCMClientFactory> gcm_client_factory,
120 const GCMClient::ChromeBuildInfo& chrome_build_info, 119 const GCMClient::ChromeBuildInfo& chrome_build_info,
121 const base::FilePath& store_path, 120 const base::FilePath& store_path,
122 const std::vector<std::string>& account_ids,
123 const scoped_refptr<net::URLRequestContextGetter>& request_context, 121 const scoped_refptr<net::URLRequestContextGetter>& request_context,
124 const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); 122 const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
125 void Start(const base::WeakPtr<GCMDriverDesktop>& service); 123 void Start(const base::WeakPtr<GCMDriverDesktop>& service);
126 void Stop(); 124 void Stop();
127 void CheckOut(); 125 void CheckOut();
128 void Register(const std::string& app_id, 126 void Register(const std::string& app_id,
129 const std::vector<std::string>& sender_ids); 127 const std::vector<std::string>& sender_ids);
130 void Unregister(const std::string& app_id); 128 void Unregister(const std::string& app_id);
131 void Send(const std::string& app_id, 129 void Send(const std::string& app_id,
132 const std::string& receiver_id, 130 const std::string& receiver_id,
(...skipping 24 matching lines...) Expand all
157 } 155 }
158 156
159 GCMDriverDesktop::IOWorker::~IOWorker() { 157 GCMDriverDesktop::IOWorker::~IOWorker() {
160 DCHECK(io_thread_->RunsTasksOnCurrentThread()); 158 DCHECK(io_thread_->RunsTasksOnCurrentThread());
161 } 159 }
162 160
163 void GCMDriverDesktop::IOWorker::Initialize( 161 void GCMDriverDesktop::IOWorker::Initialize(
164 scoped_ptr<GCMClientFactory> gcm_client_factory, 162 scoped_ptr<GCMClientFactory> gcm_client_factory,
165 const GCMClient::ChromeBuildInfo& chrome_build_info, 163 const GCMClient::ChromeBuildInfo& chrome_build_info,
166 const base::FilePath& store_path, 164 const base::FilePath& store_path,
167 const std::vector<std::string>& account_ids,
168 const scoped_refptr<net::URLRequestContextGetter>& request_context, 165 const scoped_refptr<net::URLRequestContextGetter>& request_context,
169 const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) { 166 const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) {
170 DCHECK(io_thread_->RunsTasksOnCurrentThread()); 167 DCHECK(io_thread_->RunsTasksOnCurrentThread());
171 168
172 gcm_client_ = gcm_client_factory->BuildInstance(); 169 gcm_client_ = gcm_client_factory->BuildInstance();
173 170
174 gcm_client_->Initialize(chrome_build_info, 171 gcm_client_->Initialize(chrome_build_info,
175 store_path, 172 store_path,
176 account_ids,
177 blocking_task_runner, 173 blocking_task_runner,
178 request_context, 174 request_context,
179 make_scoped_ptr<Encryptor>(new SystemEncryptor), 175 make_scoped_ptr<Encryptor>(new SystemEncryptor),
180 this); 176 this);
181 } 177 }
182 178
183 void GCMDriverDesktop::IOWorker::OnRegisterFinished( 179 void GCMDriverDesktop::IOWorker::OnRegisterFinished(
184 const std::string& app_id, 180 const std::string& app_id,
185 const std::string& registration_id, 181 const std::string& registration_id,
186 GCMClient::Result result) { 182 GCMClient::Result result) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 stats.gcm_client_created = true; 340 stats.gcm_client_created = true;
345 } 341 }
346 342
347 ui_thread_->PostTask( 343 ui_thread_->PostTask(
348 FROM_HERE, 344 FROM_HERE,
349 base::Bind(&GCMDriverDesktop::GetGCMStatisticsFinished, service_, stats)); 345 base::Bind(&GCMDriverDesktop::GetGCMStatisticsFinished, service_, stats));
350 } 346 }
351 347
352 GCMDriverDesktop::GCMDriverDesktop( 348 GCMDriverDesktop::GCMDriverDesktop(
353 scoped_ptr<GCMClientFactory> gcm_client_factory, 349 scoped_ptr<GCMClientFactory> gcm_client_factory,
354 scoped_ptr<IdentityProvider> identity_provider,
355 const GCMClient::ChromeBuildInfo& chrome_build_info, 350 const GCMClient::ChromeBuildInfo& chrome_build_info,
356 const base::FilePath& store_path, 351 const base::FilePath& store_path,
357 const scoped_refptr<net::URLRequestContextGetter>& request_context, 352 const scoped_refptr<net::URLRequestContextGetter>& request_context,
358 const scoped_refptr<base::SequencedTaskRunner>& ui_thread, 353 const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
359 const scoped_refptr<base::SequencedTaskRunner>& io_thread, 354 const scoped_refptr<base::SequencedTaskRunner>& io_thread,
360 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) 355 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner)
361 : gcm_enabled_(true), 356 : signed_in_(false),
357 gcm_started_(false),
358 gcm_enabled_(true),
362 gcm_client_ready_(false), 359 gcm_client_ready_(false),
363 connected_(false), 360 connected_(false),
364 identity_provider_(identity_provider.Pass()),
365 ui_thread_(ui_thread), 361 ui_thread_(ui_thread),
366 io_thread_(io_thread), 362 io_thread_(io_thread),
367 weak_ptr_factory_(this) { 363 weak_ptr_factory_(this) {
368 // Get the list of available accounts.
369 std::vector<std::string> account_ids;
370 account_ids = identity_provider_->GetTokenService()->GetAccounts();
371
372 // Create and initialize the GCMClient. Note that this does not initiate the 364 // Create and initialize the GCMClient. Note that this does not initiate the
373 // GCM check-in. 365 // GCM check-in.
374 io_worker_.reset(new IOWorker(ui_thread, io_thread)); 366 io_worker_.reset(new IOWorker(ui_thread, io_thread));
375 io_thread_->PostTask( 367 io_thread_->PostTask(
376 FROM_HERE, 368 FROM_HERE,
377 base::Bind(&GCMDriverDesktop::IOWorker::Initialize, 369 base::Bind(&GCMDriverDesktop::IOWorker::Initialize,
378 base::Unretained(io_worker_.get()), 370 base::Unretained(io_worker_.get()),
379 base::Passed(&gcm_client_factory), 371 base::Passed(&gcm_client_factory),
380 chrome_build_info, 372 chrome_build_info,
381 store_path, 373 store_path,
382 account_ids,
383 request_context, 374 request_context,
384 blocking_task_runner)); 375 blocking_task_runner));
385
386 identity_provider_->AddObserver(this);
387 } 376 }
388 377
389 GCMDriverDesktop::~GCMDriverDesktop() { 378 GCMDriverDesktop::~GCMDriverDesktop() {
390 } 379 }
391 380
392 void GCMDriverDesktop::OnActiveAccountLogin() {
393 EnsureStarted();
394 }
395
396 void GCMDriverDesktop::OnActiveAccountLogout() {
397 CheckOut();
398 }
399
400 void GCMDriverDesktop::Shutdown() { 381 void GCMDriverDesktop::Shutdown() {
401 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 382 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
402 identity_provider_->RemoveObserver(this);
403 GCMDriver::Shutdown(); 383 GCMDriver::Shutdown();
404 io_thread_->DeleteSoon(FROM_HERE, io_worker_.release()); 384 io_thread_->DeleteSoon(FROM_HERE, io_worker_.release());
405 } 385 }
406 386
387 void GCMDriverDesktop::OnSignedIn() {
388 signed_in_ = true;
389 EnsureStarted();
390 }
391
392 void GCMDriverDesktop::Purge() {
393 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
394
395 // We still proceed with the check-out logic even if the check-in is not
396 // initiated in the current session. This will make sure that all the
397 // persisted data written previously will get purged.
398 signed_in_ = false;
399 RemoveCachedData();
400
401 io_thread_->PostTask(FROM_HERE,
402 base::Bind(&GCMDriverDesktop::IOWorker::CheckOut,
403 base::Unretained(io_worker_.get())));
404 }
405
407 void GCMDriverDesktop::AddAppHandler(const std::string& app_id, 406 void GCMDriverDesktop::AddAppHandler(const std::string& app_id,
408 GCMAppHandler* handler) { 407 GCMAppHandler* handler) {
409 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 408 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
410 GCMDriver::AddAppHandler(app_id, handler); 409 GCMDriver::AddAppHandler(app_id, handler);
411 410
412 // Ensures that the GCM service is started when there is an interest. 411 // Ensures that the GCM service is started when there is an interest.
413 EnsureStarted(); 412 EnsureStarted();
414 } 413 }
415 414
416 void GCMDriverDesktop::RemoveAppHandler(const std::string& app_id) { 415 void GCMDriverDesktop::RemoveAppHandler(const std::string& app_id) {
(...skipping 22 matching lines...) Expand all
439 return; 438 return;
440 gcm_enabled_ = false; 439 gcm_enabled_ = false;
441 440
442 Stop(); 441 Stop();
443 } 442 }
444 443
445 void GCMDriverDesktop::Stop() { 444 void GCMDriverDesktop::Stop() {
446 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 445 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
447 446
448 // No need to stop GCM service if not started yet. 447 // No need to stop GCM service if not started yet.
449 if (account_id_.empty()) 448 if (!gcm_started_)
450 return; 449 return;
451 450
452 RemoveCachedData(); 451 RemoveCachedData();
453 452
454 io_thread_->PostTask( 453 io_thread_->PostTask(
455 FROM_HERE, 454 FROM_HERE,
456 base::Bind(&GCMDriverDesktop::IOWorker::Stop, 455 base::Bind(&GCMDriverDesktop::IOWorker::Stop,
457 base::Unretained(io_worker_.get()))); 456 base::Unretained(io_worker_.get())));
458 } 457 }
459 458
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 message)); 542 message));
544 } 543 }
545 544
546 GCMClient* GCMDriverDesktop::GetGCMClientForTesting() const { 545 GCMClient* GCMDriverDesktop::GetGCMClientForTesting() const {
547 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 546 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
548 return io_worker_ ? io_worker_->gcm_client_for_testing() : NULL; 547 return io_worker_ ? io_worker_->gcm_client_for_testing() : NULL;
549 } 548 }
550 549
551 bool GCMDriverDesktop::IsStarted() const { 550 bool GCMDriverDesktop::IsStarted() const {
552 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 551 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
553 return !account_id_.empty(); 552 return gcm_started_;
554 } 553 }
555 554
556 bool GCMDriverDesktop::IsGCMClientReady() const { 555 bool GCMDriverDesktop::IsGCMClientReady() const {
557 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 556 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
558 return gcm_client_ready_; 557 return gcm_client_ready_;
559 } 558 }
560 559
561 bool GCMDriverDesktop::IsConnected() const { 560 bool GCMDriverDesktop::IsConnected() const {
562 return connected_; 561 return connected_;
563 } 562 }
(...skipping 20 matching lines...) Expand all
584 io_thread_->PostTask( 583 io_thread_->PostTask(
585 FROM_HERE, 584 FROM_HERE,
586 base::Bind(&GCMDriverDesktop::IOWorker::SetGCMRecording, 585 base::Bind(&GCMDriverDesktop::IOWorker::SetGCMRecording,
587 base::Unretained(io_worker_.get()), 586 base::Unretained(io_worker_.get()),
588 recording)); 587 recording));
589 } 588 }
590 589
591 GCMClient::Result GCMDriverDesktop::EnsureStarted() { 590 GCMClient::Result GCMDriverDesktop::EnsureStarted() {
592 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 591 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
593 592
593 if (gcm_started_)
594 return GCMClient::SUCCESS;
595
594 if (!gcm_enabled_) 596 if (!gcm_enabled_)
595 return GCMClient::GCM_DISABLED; 597 return GCMClient::GCM_DISABLED;
596 598
597 // Have any app requested the service? 599 // Have any app requested the service?
598 if (app_handlers().empty()) 600 if (app_handlers().empty())
599 return GCMClient::UNKNOWN_ERROR; 601 return GCMClient::UNKNOWN_ERROR;
600 602
601 // Is the user signed in? 603 // TODO(jianli): To be removed when sign-in enforcement is dropped.
602 const std::string account_id = identity_provider_->GetActiveAccountId(); 604 if (!signed_in_)
603 if (account_id.empty())
604 return GCMClient::NOT_SIGNED_IN; 605 return GCMClient::NOT_SIGNED_IN;
605 606
606 // CheckIn could be called more than once when:
607 // 1) The password changes.
608 // 2) Register/send function calls it to ensure CheckIn is done.
609 if (account_id_ == account_id)
610 return GCMClient::SUCCESS;
611 account_id_ = account_id;
612
613 DCHECK(!delayed_task_controller_); 607 DCHECK(!delayed_task_controller_);
614 delayed_task_controller_.reset(new DelayedTaskController); 608 delayed_task_controller_.reset(new DelayedTaskController);
615 609
616 // Note that we need to pass weak pointer again since the existing weak 610 // Note that we need to pass weak pointer again since the existing weak
617 // pointer in IOWorker might have been invalidated when check-out occurs. 611 // pointer in IOWorker might have been invalidated when check-out occurs.
618 io_thread_->PostTask( 612 io_thread_->PostTask(
619 FROM_HERE, 613 FROM_HERE,
620 base::Bind(&GCMDriverDesktop::IOWorker::Start, 614 base::Bind(&GCMDriverDesktop::IOWorker::Start,
621 base::Unretained(io_worker_.get()), 615 base::Unretained(io_worker_.get()),
622 weak_ptr_factory_.GetWeakPtr())); 616 weak_ptr_factory_.GetWeakPtr()));
623 617
618 gcm_started_ = true;
624 return GCMClient::SUCCESS; 619 return GCMClient::SUCCESS;
625 } 620 }
626 621
627 void GCMDriverDesktop::RemoveCachedData() { 622 void GCMDriverDesktop::RemoveCachedData() {
628 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 623 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
629 // Remove all the queued tasks since they no longer make sense after 624 // Remove all the queued tasks since they no longer make sense after
630 // GCM service is stopped. 625 // GCM service is stopped.
631 weak_ptr_factory_.InvalidateWeakPtrs(); 626 weak_ptr_factory_.InvalidateWeakPtrs();
632 627
633 account_id_.clear(); 628 gcm_started_ = false;
634 gcm_client_ready_ = false; 629 gcm_client_ready_ = false;
635 delayed_task_controller_.reset(); 630 delayed_task_controller_.reset();
636 ClearCallbacks(); 631 ClearCallbacks();
637 } 632 }
638 633
639 void GCMDriverDesktop::CheckOut() {
640 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
641
642 // We still proceed with the check-out logic even if the check-in is not
643 // initiated in the current session. This will make sure that all the
644 // persisted data written previously will get purged.
645
646 RemoveCachedData();
647
648 io_thread_->PostTask(
649 FROM_HERE,
650 base::Bind(&GCMDriverDesktop::IOWorker::CheckOut,
651 base::Unretained(io_worker_.get())));
652 }
653
654 void GCMDriverDesktop::MessageReceived( 634 void GCMDriverDesktop::MessageReceived(
655 const std::string& app_id, 635 const std::string& app_id,
656 const GCMClient::IncomingMessage& message) { 636 const GCMClient::IncomingMessage& message) {
657 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 637 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
658 638
659 // Drop the event if signed out. 639 // Drop the event if the service has been stopped.
660 if (account_id_.empty()) 640 if (!gcm_started_)
661 return; 641 return;
662 642
663 GetAppHandler(app_id)->OnMessage(app_id, message); 643 GetAppHandler(app_id)->OnMessage(app_id, message);
664 } 644 }
665 645
666 void GCMDriverDesktop::MessagesDeleted(const std::string& app_id) { 646 void GCMDriverDesktop::MessagesDeleted(const std::string& app_id) {
667 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 647 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
668 648
669 // Drop the event if signed out. 649 // Drop the event if the service has been stopped.
670 if (account_id_.empty()) 650 if (!gcm_started_)
671 return; 651 return;
672 652
673 GetAppHandler(app_id)->OnMessagesDeleted(app_id); 653 GetAppHandler(app_id)->OnMessagesDeleted(app_id);
674 } 654 }
675 655
676 void GCMDriverDesktop::MessageSendError( 656 void GCMDriverDesktop::MessageSendError(
677 const std::string& app_id, 657 const std::string& app_id,
678 const GCMClient::SendErrorDetails& send_error_details) { 658 const GCMClient::SendErrorDetails& send_error_details) {
679 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 659 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
680 660
681 // Drop the event if signed out. 661 // Drop the event if the service has been stopped.
682 if (account_id_.empty()) 662 if (!gcm_started_)
683 return; 663 return;
684 664
685 GetAppHandler(app_id)->OnSendError(app_id, send_error_details); 665 GetAppHandler(app_id)->OnSendError(app_id, send_error_details);
686 } 666 }
687 667
688 void GCMDriverDesktop::GCMClientReady() { 668 void GCMDriverDesktop::GCMClientReady() {
689 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 669 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
690 670
691 if (gcm_client_ready_) 671 if (gcm_client_ready_)
692 return; 672 return;
693 gcm_client_ready_ = true; 673 gcm_client_ready_ = true;
694 674
695 delayed_task_controller_->SetReady(); 675 delayed_task_controller_->SetReady();
696 } 676 }
697 677
698 void GCMDriverDesktop::OnConnected(const net::IPEndPoint& ip_endpoint) { 678 void GCMDriverDesktop::OnConnected(const net::IPEndPoint& ip_endpoint) {
699 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 679 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
700 680
701 connected_ = true; 681 connected_ = true;
702 682
703 // Drop the event if signed out. 683 // Drop the event if signed out.
704 if (account_id_.empty()) 684 if (!signed_in_)
705 return; 685 return;
706 686
707 const GCMAppHandlerMap& app_handler_map = app_handlers(); 687 const GCMAppHandlerMap& app_handler_map = app_handlers();
708 for (GCMAppHandlerMap::const_iterator iter = app_handler_map.begin(); 688 for (GCMAppHandlerMap::const_iterator iter = app_handler_map.begin();
709 iter != app_handler_map.end(); ++iter) { 689 iter != app_handler_map.end(); ++iter) {
710 iter->second->OnConnected(ip_endpoint); 690 iter->second->OnConnected(ip_endpoint);
711 } 691 }
712 692
713 GetAppHandler(kDefaultAppHandler)->OnConnected(ip_endpoint); 693 GetAppHandler(kDefaultAppHandler)->OnConnected(ip_endpoint);
714 } 694 }
715 695
716 void GCMDriverDesktop::OnDisconnected() { 696 void GCMDriverDesktop::OnDisconnected() {
717 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 697 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
718 698
719 connected_ = false; 699 connected_ = false;
720 700
721 // Drop the event if signed out. 701 // Drop the event if signed out.
722 if (account_id_.empty()) 702 if (!signed_in_)
723 return; 703 return;
724 704
725 const GCMAppHandlerMap& app_handler_map = app_handlers(); 705 const GCMAppHandlerMap& app_handler_map = app_handlers();
726 for (GCMAppHandlerMap::const_iterator iter = app_handler_map.begin(); 706 for (GCMAppHandlerMap::const_iterator iter = app_handler_map.begin();
727 iter != app_handler_map.end(); ++iter) { 707 iter != app_handler_map.end(); ++iter) {
728 iter->second->OnDisconnected(); 708 iter->second->OnDisconnected();
729 } 709 }
730 710
731 GetAppHandler(kDefaultAppHandler)->OnDisconnected(); 711 GetAppHandler(kDefaultAppHandler)->OnDisconnected();
732 } 712 }
733 713
734 void GCMDriverDesktop::GetGCMStatisticsFinished( 714 void GCMDriverDesktop::GetGCMStatisticsFinished(
735 const GCMClient::GCMStatistics& stats) { 715 const GCMClient::GCMStatistics& stats) {
736 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 716 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
737 717
738 // Normally request_gcm_statistics_callback_ would not be null. 718 // Normally request_gcm_statistics_callback_ would not be null.
739 if (!request_gcm_statistics_callback_.is_null()) 719 if (!request_gcm_statistics_callback_.is_null())
740 request_gcm_statistics_callback_.Run(stats); 720 request_gcm_statistics_callback_.Run(stats);
741 else 721 else
742 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; 722 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL.";
743 } 723 }
744 724
745 std::string GCMDriverDesktop::SignedInUserName() const {
746 if (IsStarted())
747 return identity_provider_->GetActiveUsername();
748 return std::string();
749 }
750
751 } // namespace gcm 725 } // namespace gcm
752 726
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