| OLD | NEW |
| 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 gcm_channel_status_syncer_.reset(); | 379 gcm_channel_status_syncer_.reset(); |
| 380 | 380 |
| 381 io_thread_->DeleteSoon(FROM_HERE, io_worker_.release()); | 381 io_thread_->DeleteSoon(FROM_HERE, io_worker_.release()); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void GCMDriverDesktop::OnSignedIn() { | 384 void GCMDriverDesktop::OnSignedIn() { |
| 385 signed_in_ = true; | 385 signed_in_ = true; |
| 386 EnsureStarted(); | 386 EnsureStarted(); |
| 387 } | 387 } |
| 388 | 388 |
| 389 void GCMDriverDesktop::OnSignedOut() { |
| 390 signed_in_ = false; |
| 391 |
| 392 // When sign-in enforcement is not dropped, we will stop the GCM connection |
| 393 // when the user signs out. |
| 394 if (!GCMDriver::IsAllowedForAllUsers()) |
| 395 Stop(); |
| 396 } |
| 397 |
| 389 void GCMDriverDesktop::Purge() { | 398 void GCMDriverDesktop::Purge() { |
| 390 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 399 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
| 391 | 400 |
| 392 // We still proceed with the check-out logic even if the check-in is not | |
| 393 // initiated in the current session. This will make sure that all the | |
| 394 // persisted data written previously will get purged. | |
| 395 signed_in_ = false; | |
| 396 RemoveCachedData(); | 401 RemoveCachedData(); |
| 397 | 402 |
| 398 io_thread_->PostTask(FROM_HERE, | 403 io_thread_->PostTask(FROM_HERE, |
| 399 base::Bind(&GCMDriverDesktop::IOWorker::CheckOut, | 404 base::Bind(&GCMDriverDesktop::IOWorker::CheckOut, |
| 400 base::Unretained(io_worker_.get()))); | 405 base::Unretained(io_worker_.get()))); |
| 401 } | 406 } |
| 402 | 407 |
| 403 void GCMDriverDesktop::AddAppHandler(const std::string& app_id, | 408 void GCMDriverDesktop::AddAppHandler(const std::string& app_id, |
| 404 GCMAppHandler* handler) { | 409 GCMAppHandler* handler) { |
| 405 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 410 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 | 762 |
| 758 // Normally request_gcm_statistics_callback_ would not be null. | 763 // Normally request_gcm_statistics_callback_ would not be null. |
| 759 if (!request_gcm_statistics_callback_.is_null()) | 764 if (!request_gcm_statistics_callback_.is_null()) |
| 760 request_gcm_statistics_callback_.Run(stats); | 765 request_gcm_statistics_callback_.Run(stats); |
| 761 else | 766 else |
| 762 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; | 767 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; |
| 763 } | 768 } |
| 764 | 769 |
| 765 } // namespace gcm | 770 } // namespace gcm |
| 766 | 771 |
| OLD | NEW |