Chromium Code Reviews| Index: components/gcm_driver/gcm_driver_desktop.cc |
| diff --git a/components/gcm_driver/gcm_driver_desktop.cc b/components/gcm_driver/gcm_driver_desktop.cc |
| index d8794263240892360a42e0de8c77009f2b0f60e4..1303152f20aa0b5342f804da7b576483127abcc3 100644 |
| --- a/components/gcm_driver/gcm_driver_desktop.cc |
| +++ b/components/gcm_driver/gcm_driver_desktop.cc |
| @@ -16,6 +16,7 @@ |
| #include "components/gcm_driver/gcm_app_handler.h" |
| #include "components/gcm_driver/gcm_client_factory.h" |
| #include "components/gcm_driver/system_encryptor.h" |
| +#include "google_apis/gcm/engine/account_mapping.h" |
| #include "net/base/ip_endpoint.h" |
| #include "net/url_request/url_request_context_getter.h" |
| @@ -136,6 +137,8 @@ class GCMDriverDesktop::IOWorker : public GCMClient::Delegate { |
| void SetAccountsForCheckin( |
| const std::map<std::string, std::string>& account_tokens); |
| + void UpdateAccountMapping(const AccountMapping& account_mapping); |
| + void RemoveAccountMapping(const std::string& account_id); |
| // For testing purpose. Can be called from UI thread. Use with care. |
| GCMClient* gcm_client_for_testing() const { return gcm_client_.get(); } |
| @@ -369,6 +372,22 @@ void GCMDriverDesktop::IOWorker::SetAccountsForCheckin( |
| gcm_client_->SetAccountsForCheckin(account_tokens); |
| } |
| +void GCMDriverDesktop::IOWorker::UpdateAccountMapping( |
| + const AccountMapping& account_mapping) { |
| + DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
| + |
| + if (gcm_client_.get()) |
|
Nicolas Zea
2014/08/11 18:21:05
Shouldn't we always have a gcm_client_ at this poi
fgorski
2014/08/20 18:29:06
It shouldn't be after Initialize was called. I am
|
| + gcm_client_->UpdateAccountMapping(account_mapping); |
| +} |
| + |
| +void GCMDriverDesktop::IOWorker::RemoveAccountMapping( |
| + const std::string& account_id) { |
| + DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
| + |
| + if (gcm_client_.get()) |
| + gcm_client_->RemoveAccountMapping(account_id); |
| +} |
| + |
| GCMDriverDesktop::GCMDriverDesktop( |
| scoped_ptr<GCMClientFactory> gcm_client_factory, |
| const GCMClient::ChromeBuildInfo& chrome_build_info, |
| @@ -605,6 +624,27 @@ void GCMDriverDesktop::SetGCMRecording(const GetGCMStatisticsCallback& callback, |
| recording)); |
| } |
| +void GCMDriverDesktop::UpdateAccountMapping( |
| + const AccountMapping& account_mapping) { |
| + DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
| + |
| + io_thread_->PostTask( |
| + FROM_HERE, |
| + base::Bind(&GCMDriverDesktop::IOWorker::UpdateAccountMapping, |
| + base::Unretained(io_worker_.get()), |
| + account_mapping)); |
| +} |
| + |
| +void GCMDriverDesktop::RemoveAccountMapping(const std::string& account_id) { |
| + DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
| + |
| + io_thread_->PostTask( |
| + FROM_HERE, |
| + base::Bind(&GCMDriverDesktop::IOWorker::RemoveAccountMapping, |
| + base::Unretained(io_worker_.get()), |
| + account_id)); |
| +} |
| + |
| void GCMDriverDesktop::SetAccountsForCheckin( |
| const std::map<std::string, std::string>& account_tokens) { |
| DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |