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

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

Issue 562423002: Clear GCM data when the user clears cookies and other site data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 6 years, 3 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
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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 362 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
363 GCMDriver::Shutdown(); 363 GCMDriver::Shutdown();
364 io_thread_->DeleteSoon(FROM_HERE, io_worker_.release()); 364 io_thread_->DeleteSoon(FROM_HERE, io_worker_.release());
365 } 365 }
366 366
367 void GCMDriverDesktop::OnSignedIn() { 367 void GCMDriverDesktop::OnSignedIn() {
368 signed_in_ = true; 368 signed_in_ = true;
369 EnsureStarted(); 369 EnsureStarted();
370 } 370 }
371 371
372 void GCMDriverDesktop::OnSignedOut() {
373 signed_in_ = false;
374
375 // When sign-in enforcement is dropped, we will no longer wipe out the GCM
376 // data when the user signs out.
377 if (!GCMDriver::IsAllowedForAllUsers())
378 Purge();
379 }
380
372 void GCMDriverDesktop::Purge() { 381 void GCMDriverDesktop::Purge() {
373 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 382 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
374 383
375 // We still proceed with the check-out logic even if the check-in is not
376 // initiated in the current session. This will make sure that all the
377 // persisted data written previously will get purged.
378 signed_in_ = false;
379 RemoveCachedData(); 384 RemoveCachedData();
380 385
381 io_thread_->PostTask(FROM_HERE, 386 io_thread_->PostTask(FROM_HERE,
382 base::Bind(&GCMDriverDesktop::IOWorker::CheckOut, 387 base::Bind(&GCMDriverDesktop::IOWorker::CheckOut,
383 base::Unretained(io_worker_.get()))); 388 base::Unretained(io_worker_.get())));
384 } 389 }
385 390
386 void GCMDriverDesktop::AddAppHandler(const std::string& app_id, 391 void GCMDriverDesktop::AddAppHandler(const std::string& app_id,
387 GCMAppHandler* handler) { 392 GCMAppHandler* handler) {
388 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); 393 DCHECK(ui_thread_->RunsTasksOnCurrentThread());
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 if (gcm_started_) 614 if (gcm_started_)
610 return GCMClient::SUCCESS; 615 return GCMClient::SUCCESS;
611 616
612 if (!gcm_enabled_) 617 if (!gcm_enabled_)
613 return GCMClient::GCM_DISABLED; 618 return GCMClient::GCM_DISABLED;
614 619
615 // Have any app requested the service? 620 // Have any app requested the service?
616 if (app_handlers().empty()) 621 if (app_handlers().empty())
617 return GCMClient::UNKNOWN_ERROR; 622 return GCMClient::UNKNOWN_ERROR;
618 623
619 // TODO(jianli): To be removed when sign-in enforcement is dropped.
620 if (!signed_in_ && !GCMDriver::IsAllowedForAllUsers()) 624 if (!signed_in_ && !GCMDriver::IsAllowedForAllUsers())
621 return GCMClient::NOT_SIGNED_IN; 625 return GCMClient::NOT_SIGNED_IN;
622 626
623 DCHECK(!delayed_task_controller_); 627 DCHECK(!delayed_task_controller_);
624 delayed_task_controller_.reset(new GCMDelayedTaskController); 628 delayed_task_controller_.reset(new GCMDelayedTaskController);
625 629
626 // Note that we need to pass weak pointer again since the existing weak 630 // Note that we need to pass weak pointer again since the existing weak
627 // pointer in IOWorker might have been invalidated when check-out occurs. 631 // pointer in IOWorker might have been invalidated when check-out occurs.
628 io_thread_->PostTask( 632 io_thread_->PostTask(
629 FROM_HERE, 633 FROM_HERE,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 734
731 // Normally request_gcm_statistics_callback_ would not be null. 735 // Normally request_gcm_statistics_callback_ would not be null.
732 if (!request_gcm_statistics_callback_.is_null()) 736 if (!request_gcm_statistics_callback_.is_null())
733 request_gcm_statistics_callback_.Run(stats); 737 request_gcm_statistics_callback_.Run(stats);
734 else 738 else
735 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; 739 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL.";
736 } 740 }
737 741
738 } // namespace gcm 742 } // namespace gcm
739 743
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