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 "chrome/browser/services/gcm/gcm_service.h" | 5 #include "chrome/browser/services/gcm/gcm_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.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 "chrome/browser/services/gcm/gcm_app_handler.h" |
| 17 #include "chrome/browser/services/gcm/gcm_client_factory.h" |
16 #include "chrome/common/chrome_version_info.h" | 18 #include "chrome/common/chrome_version_info.h" |
17 #include "components/gcm_driver/gcm_app_handler.h" | |
18 #include "components/gcm_driver/gcm_client_factory.h" | |
19 #include "components/gcm_driver/system_encryptor.h" | |
20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
21 #include "google_apis/gaia/oauth2_token_service.h" | 20 #include "google_apis/gaia/oauth2_token_service.h" |
22 #include "google_apis/gcm/protocol/android_checkin.pb.h" | 21 #include "google_apis/gcm/protocol/android_checkin.pb.h" |
23 #include "net/url_request/url_request_context_getter.h" | 22 #include "net/url_request/url_request_context_getter.h" |
24 | 23 |
25 namespace gcm { | 24 namespace gcm { |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
29 checkin_proto::ChromeBuildProto_Platform GetPlatform() { | 28 checkin_proto::ChromeBuildProto_Platform GetPlatform() { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 186 } |
188 | 187 |
189 void GCMService::IOWorker::Initialize( | 188 void GCMService::IOWorker::Initialize( |
190 scoped_ptr<GCMClientFactory> gcm_client_factory, | 189 scoped_ptr<GCMClientFactory> gcm_client_factory, |
191 const base::FilePath& store_path, | 190 const base::FilePath& store_path, |
192 const std::vector<std::string>& account_ids, | 191 const std::vector<std::string>& account_ids, |
193 const scoped_refptr<net::URLRequestContextGetter>& | 192 const scoped_refptr<net::URLRequestContextGetter>& |
194 url_request_context_getter) { | 193 url_request_context_getter) { |
195 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 194 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
196 | 195 |
197 gcm_client_ = gcm_client_factory->BuildInstance(); | 196 gcm_client_ = gcm_client_factory->BuildInstance().Pass(); |
198 | 197 |
199 checkin_proto::ChromeBuildProto chrome_build_proto; | 198 checkin_proto::ChromeBuildProto chrome_build_proto; |
200 chrome_build_proto.set_platform(GetPlatform()); | 199 chrome_build_proto.set_platform(GetPlatform()); |
201 chrome_build_proto.set_chrome_version(GetVersion()); | 200 chrome_build_proto.set_chrome_version(GetVersion()); |
202 chrome_build_proto.set_channel(GetChannel()); | 201 chrome_build_proto.set_channel(GetChannel()); |
203 | 202 |
204 scoped_refptr<base::SequencedWorkerPool> worker_pool( | 203 scoped_refptr<base::SequencedWorkerPool> worker_pool( |
205 content::BrowserThread::GetBlockingPool()); | 204 content::BrowserThread::GetBlockingPool()); |
206 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( | 205 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( |
207 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( | 206 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( |
208 worker_pool->GetSequenceToken(), | 207 worker_pool->GetSequenceToken(), |
209 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 208 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
210 | 209 |
211 gcm_client_->Initialize(chrome_build_proto, | 210 gcm_client_->Initialize(chrome_build_proto, |
212 store_path, | 211 store_path, |
213 account_ids, | 212 account_ids, |
214 blocking_task_runner, | 213 blocking_task_runner, |
215 url_request_context_getter, | 214 url_request_context_getter, |
216 make_scoped_ptr<Encryptor>(new SystemEncryptor), | |
217 this); | 215 this); |
218 } | 216 } |
219 | 217 |
220 void GCMService::IOWorker::OnRegisterFinished( | 218 void GCMService::IOWorker::OnRegisterFinished( |
221 const std::string& app_id, | 219 const std::string& app_id, |
222 const std::string& registration_id, | 220 const std::string& registration_id, |
223 GCMClient::Result result) { | 221 GCMClient::Result result) { |
224 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 222 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
225 | 223 |
226 content::BrowserThread::PostTask(content::BrowserThread::UI, | 224 content::BrowserThread::PostTask(content::BrowserThread::UI, |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 852 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
855 | 853 |
856 // Normally request_gcm_statistics_callback_ would not be null. | 854 // Normally request_gcm_statistics_callback_ would not be null. |
857 if (!request_gcm_statistics_callback_.is_null()) | 855 if (!request_gcm_statistics_callback_.is_null()) |
858 request_gcm_statistics_callback_.Run(stats); | 856 request_gcm_statistics_callback_.Run(stats); |
859 else | 857 else |
860 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; | 858 LOG(WARNING) << "request_gcm_statistics_callback_ is NULL."; |
861 } | 859 } |
862 | 860 |
863 } // namespace gcm | 861 } // namespace gcm |
OLD | NEW |