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