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/gcm_app_handler.h" |
| 18 #include "components/gcm/gcm_client_factory.h" |
| 19 #include "components/gcm/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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } | 186 } |
186 | 187 |
187 void GCMService::IOWorker::Initialize( | 188 void GCMService::IOWorker::Initialize( |
188 scoped_ptr<GCMClientFactory> gcm_client_factory, | 189 scoped_ptr<GCMClientFactory> gcm_client_factory, |
189 const base::FilePath& store_path, | 190 const base::FilePath& store_path, |
190 const std::vector<std::string>& account_ids, | 191 const std::vector<std::string>& account_ids, |
191 const scoped_refptr<net::URLRequestContextGetter>& | 192 const scoped_refptr<net::URLRequestContextGetter>& |
192 url_request_context_getter) { | 193 url_request_context_getter) { |
193 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 194 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
194 | 195 |
195 gcm_client_ = gcm_client_factory->BuildInstance().Pass(); | 196 gcm_client_ = gcm_client_factory->BuildInstance(); |
196 | 197 |
197 checkin_proto::ChromeBuildProto chrome_build_proto; | 198 checkin_proto::ChromeBuildProto chrome_build_proto; |
198 chrome_build_proto.set_platform(GetPlatform()); | 199 chrome_build_proto.set_platform(GetPlatform()); |
199 chrome_build_proto.set_chrome_version(GetVersion()); | 200 chrome_build_proto.set_chrome_version(GetVersion()); |
200 chrome_build_proto.set_channel(GetChannel()); | 201 chrome_build_proto.set_channel(GetChannel()); |
201 | 202 |
202 scoped_refptr<base::SequencedWorkerPool> worker_pool( | 203 scoped_refptr<base::SequencedWorkerPool> worker_pool( |
203 content::BrowserThread::GetBlockingPool()); | 204 content::BrowserThread::GetBlockingPool()); |
204 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( | 205 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( |
205 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( | 206 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( |
206 worker_pool->GetSequenceToken(), | 207 worker_pool->GetSequenceToken(), |
207 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 208 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
208 | 209 |
209 gcm_client_->Initialize(chrome_build_proto, | 210 gcm_client_->Initialize(chrome_build_proto, |
210 store_path, | 211 store_path, |
211 account_ids, | 212 account_ids, |
212 blocking_task_runner, | 213 blocking_task_runner, |
213 url_request_context_getter, | 214 url_request_context_getter, |
| 215 make_scoped_ptr<Encryptor>(new SystemEncryptor), |
214 this); | 216 this); |
215 } | 217 } |
216 | 218 |
217 void GCMService::IOWorker::OnRegisterFinished( | 219 void GCMService::IOWorker::OnRegisterFinished( |
218 const std::string& app_id, | 220 const std::string& app_id, |
219 const std::string& registration_id, | 221 const std::string& registration_id, |
220 GCMClient::Result result) { | 222 GCMClient::Result result) { |
221 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 223 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
222 | 224 |
223 content::BrowserThread::PostTask(content::BrowserThread::UI, | 225 content::BrowserThread::PostTask(content::BrowserThread::UI, |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 return iter == app_handlers_.end() ? &default_app_handler_ : iter->second; | 843 return iter == app_handlers_.end() ? &default_app_handler_ : iter->second; |
842 } | 844 } |
843 | 845 |
844 void GCMService::GetGCMStatisticsFinished( | 846 void GCMService::GetGCMStatisticsFinished( |
845 GCMClient::GCMStatistics stats) { | 847 GCMClient::GCMStatistics stats) { |
846 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 848 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
847 request_gcm_statistics_callback_.Run(stats); | 849 request_gcm_statistics_callback_.Run(stats); |
848 } | 850 } |
849 | 851 |
850 } // namespace gcm | 852 } // namespace gcm |
OLD | NEW |