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/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
17 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
18 #include "base/sequenced_task_runner.h" | 18 #include "base/sequenced_task_runner.h" |
19 #include "base/task_runner_util.h" | 19 #include "base/task_runner_util.h" |
20 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" |
21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
22 #include "components/gcm_driver/gcm_account_mapper.h" | 23 #include "components/gcm_driver/gcm_account_mapper.h" |
23 #include "components/gcm_driver/gcm_app_handler.h" | 24 #include "components/gcm_driver/gcm_app_handler.h" |
24 #include "components/gcm_driver/gcm_channel_status_syncer.h" | 25 #include "components/gcm_driver/gcm_channel_status_syncer.h" |
25 #include "components/gcm_driver/gcm_client_factory.h" | 26 #include "components/gcm_driver/gcm_client_factory.h" |
26 #include "components/gcm_driver/gcm_delayed_task_controller.h" | 27 #include "components/gcm_driver/gcm_delayed_task_controller.h" |
27 #include "components/gcm_driver/instance_id/instance_id_impl.h" | 28 #include "components/gcm_driver/instance_id/instance_id_impl.h" |
28 #include "components/gcm_driver/system_encryptor.h" | 29 #include "components/gcm_driver/system_encryptor.h" |
29 #include "google_apis/gcm/engine/account_mapping.h" | 30 #include "google_apis/gcm/engine/account_mapping.h" |
30 #include "net/base/ip_endpoint.h" | 31 #include "net/base/ip_endpoint.h" |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 } | 1112 } |
1112 | 1113 |
1113 void GCMDriverDesktop::GetInstanceIDData( | 1114 void GCMDriverDesktop::GetInstanceIDData( |
1114 const std::string& app_id, | 1115 const std::string& app_id, |
1115 const GetInstanceIDDataCallback& callback) { | 1116 const GetInstanceIDDataCallback& callback) { |
1116 DCHECK(!get_instance_id_data_callbacks_.count(app_id)); | 1117 DCHECK(!get_instance_id_data_callbacks_.count(app_id)); |
1117 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 1118 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
1118 | 1119 |
1119 GCMClient::Result result = EnsureStarted(GCMClient::IMMEDIATE_START); | 1120 GCMClient::Result result = EnsureStarted(GCMClient::IMMEDIATE_START); |
1120 if (result != GCMClient::SUCCESS) { | 1121 if (result != GCMClient::SUCCESS) { |
1121 callback.Run(std::string(), std::string()); | 1122 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1123 FROM_HERE, base::Bind(callback, std::string(), std::string())); |
1122 return; | 1124 return; |
1123 } | 1125 } |
1124 | 1126 |
1125 get_instance_id_data_callbacks_[app_id] = callback; | 1127 get_instance_id_data_callbacks_[app_id] = callback; |
1126 | 1128 |
1127 // Delay the operation until GCMClient is ready. | 1129 // Delay the operation until GCMClient is ready. |
1128 if (!delayed_task_controller_->CanRunTaskWithoutDelay()) { | 1130 if (!delayed_task_controller_->CanRunTaskWithoutDelay()) { |
1129 delayed_task_controller_->AddTask( | 1131 delayed_task_controller_->AddTask( |
1130 base::Bind(&GCMDriverDesktop::DoGetInstanceIDData, | 1132 base::Bind(&GCMDriverDesktop::DoGetInstanceIDData, |
1131 weak_ptr_factory_.GetWeakPtr(), | 1133 weak_ptr_factory_.GetWeakPtr(), |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 | 1442 |
1441 if (std::get<1>(a) < std::get<1>(b)) | 1443 if (std::get<1>(a) < std::get<1>(b)) |
1442 return true; | 1444 return true; |
1443 if (std::get<1>(a) > std::get<1>(b)) | 1445 if (std::get<1>(a) > std::get<1>(b)) |
1444 return false; | 1446 return false; |
1445 | 1447 |
1446 return std::get<2>(a) < std::get<2>(b); | 1448 return std::get<2>(a) < std::get<2>(b); |
1447 } | 1449 } |
1448 | 1450 |
1449 } // namespace gcm | 1451 } // namespace gcm |
OLD | NEW |