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" |
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_account_mapper.h" | |
16 #include "components/gcm_driver/gcm_app_handler.h" | 17 #include "components/gcm_driver/gcm_app_handler.h" |
17 #include "components/gcm_driver/gcm_channel_status_syncer.h" | 18 #include "components/gcm_driver/gcm_channel_status_syncer.h" |
18 #include "components/gcm_driver/gcm_client_factory.h" | 19 #include "components/gcm_driver/gcm_client_factory.h" |
19 #include "components/gcm_driver/gcm_delayed_task_controller.h" | 20 #include "components/gcm_driver/gcm_delayed_task_controller.h" |
20 #include "components/gcm_driver/system_encryptor.h" | 21 #include "components/gcm_driver/system_encryptor.h" |
21 #include "google_apis/gcm/engine/account_mapping.h" | 22 #include "google_apis/gcm/engine/account_mapping.h" |
22 #include "net/base/ip_endpoint.h" | 23 #include "net/base/ip_endpoint.h" |
23 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
24 | 25 |
25 namespace gcm { | 26 namespace gcm { |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 void GCMDriverDesktop::RemoveAccountMapping(const std::string& account_id) { | 608 void GCMDriverDesktop::RemoveAccountMapping(const std::string& account_id) { |
608 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 609 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
609 | 610 |
610 io_thread_->PostTask( | 611 io_thread_->PostTask( |
611 FROM_HERE, | 612 FROM_HERE, |
612 base::Bind(&GCMDriverDesktop::IOWorker::RemoveAccountMapping, | 613 base::Bind(&GCMDriverDesktop::IOWorker::RemoveAccountMapping, |
613 base::Unretained(io_worker_.get()), | 614 base::Unretained(io_worker_.get()), |
614 account_id)); | 615 account_id)); |
615 } | 616 } |
616 | 617 |
617 void GCMDriverDesktop::SetAccountsForCheckin( | 618 void GCMDriverDesktop::SetAccountTokens( |
618 const std::map<std::string, std::string>& account_tokens) { | 619 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) { |
619 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 620 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
621 std::map<std::string, std::string> account_token_map; | |
jianli
2014/09/25 20:26:45
I think we should also pass std::vector to IO thre
fgorski
2014/09/26 22:51:42
Done.
| |
622 for (std::vector<GCMClient::AccountTokenInfo>::const_iterator iter = | |
623 account_tokens.begin(); | |
624 iter != account_tokens.end(); | |
625 ++iter) { | |
626 account_token_map[iter->email] = iter->access_token; | |
627 } | |
620 | 628 |
621 io_thread_->PostTask( | 629 io_thread_->PostTask( |
622 FROM_HERE, | 630 FROM_HERE, |
623 base::Bind(&GCMDriverDesktop::IOWorker::SetAccountsForCheckin, | 631 base::Bind(&GCMDriverDesktop::IOWorker::SetAccountsForCheckin, |
624 base::Unretained(io_worker_.get()), | 632 base::Unretained(io_worker_.get()), |
625 account_tokens)); | 633 account_token_map)); |
626 } | 634 } |
627 | 635 |
628 GCMClient::Result GCMDriverDesktop::EnsureStarted() { | 636 GCMClient::Result GCMDriverDesktop::EnsureStarted() { |
629 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 637 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
630 | 638 |
631 if (gcm_started_) | 639 if (gcm_started_) |
632 return GCMClient::SUCCESS; | 640 return GCMClient::SUCCESS; |
633 | 641 |
634 if (!gcm_enabled_) | 642 if (!gcm_enabled_) |
635 return GCMClient::GCM_DISABLED; | 643 return GCMClient::GCM_DISABLED; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 | 765 |
758 // Normally request_gcm_statistics_callback_ would not be null. | 766 // Normally request_gcm_statistics_callback_ would not be null. |
759 if (!request_gcm_statistics_callback_.is_null()) | 767 if (!request_gcm_statistics_callback_.is_null()) |
760 request_gcm_statistics_callback_.Run(stats); | 768 request_gcm_statistics_callback_.Run(stats); |
761 else | 769 else |
762 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; | 770 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; |
763 } | 771 } |
764 | 772 |
765 } // namespace gcm | 773 } // namespace gcm |
766 | 774 |
OLD | NEW |