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_client_impl.h" | 5 #include "components/gcm_driver/gcm_client_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 periodic_checkin_ptr_factory_(this), | 259 periodic_checkin_ptr_factory_(this), |
260 weak_ptr_factory_(this) { | 260 weak_ptr_factory_(this) { |
261 } | 261 } |
262 | 262 |
263 GCMClientImpl::~GCMClientImpl() { | 263 GCMClientImpl::~GCMClientImpl() { |
264 } | 264 } |
265 | 265 |
266 void GCMClientImpl::Initialize( | 266 void GCMClientImpl::Initialize( |
267 const ChromeBuildInfo& chrome_build_info, | 267 const ChromeBuildInfo& chrome_build_info, |
268 const base::FilePath& path, | 268 const base::FilePath& path, |
269 const std::vector<std::string>& account_ids, | |
270 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 269 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
271 const scoped_refptr<net::URLRequestContextGetter>& | 270 const scoped_refptr<net::URLRequestContextGetter>& |
272 url_request_context_getter, | 271 url_request_context_getter, |
273 scoped_ptr<Encryptor> encryptor, | 272 scoped_ptr<Encryptor> encryptor, |
274 GCMClient::Delegate* delegate) { | 273 GCMClient::Delegate* delegate) { |
275 DCHECK_EQ(UNINITIALIZED, state_); | 274 DCHECK_EQ(UNINITIALIZED, state_); |
276 DCHECK(url_request_context_getter); | 275 DCHECK(url_request_context_getter); |
277 DCHECK(delegate); | 276 DCHECK(delegate); |
278 | 277 |
279 url_request_context_getter_ = url_request_context_getter; | 278 url_request_context_getter_ = url_request_context_getter; |
280 const net::HttpNetworkSession::Params* network_session_params = | 279 const net::HttpNetworkSession::Params* network_session_params = |
281 url_request_context_getter_->GetURLRequestContext()-> | 280 url_request_context_getter_->GetURLRequestContext()-> |
282 GetNetworkSessionParams(); | 281 GetNetworkSessionParams(); |
283 DCHECK(network_session_params); | 282 DCHECK(network_session_params); |
284 network_session_ = new net::HttpNetworkSession(*network_session_params); | 283 network_session_ = new net::HttpNetworkSession(*network_session_params); |
285 | 284 |
286 chrome_build_info_ = chrome_build_info; | 285 chrome_build_info_ = chrome_build_info; |
287 account_ids_ = account_ids; | |
288 | 286 |
289 gcm_store_.reset( | 287 gcm_store_.reset( |
290 new GCMStoreImpl(path, blocking_task_runner, encryptor.Pass())); | 288 new GCMStoreImpl(path, blocking_task_runner, encryptor.Pass())); |
291 | 289 |
292 delegate_ = delegate; | 290 delegate_ = delegate; |
293 | 291 |
294 recorder_.SetDelegate(this); | 292 recorder_.SetDelegate(this); |
295 | 293 |
296 state_ = INITIALIZED; | 294 state_ = INITIALIZED; |
297 } | 295 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 void GCMClientImpl::StartCheckin() { | 393 void GCMClientImpl::StartCheckin() { |
396 // Make sure no checkin is in progress. | 394 // Make sure no checkin is in progress. |
397 if (checkin_request_.get()) | 395 if (checkin_request_.get()) |
398 return; | 396 return; |
399 | 397 |
400 checkin_proto::ChromeBuildProto chrome_build_proto; | 398 checkin_proto::ChromeBuildProto chrome_build_proto; |
401 ToCheckinProtoVersion(chrome_build_info_, &chrome_build_proto); | 399 ToCheckinProtoVersion(chrome_build_info_, &chrome_build_proto); |
402 CheckinRequest::RequestInfo request_info(device_checkin_info_.android_id, | 400 CheckinRequest::RequestInfo request_info(device_checkin_info_.android_id, |
403 device_checkin_info_.secret, | 401 device_checkin_info_.secret, |
404 gservices_settings_.digest(), | 402 gservices_settings_.digest(), |
405 account_ids_, | |
406 chrome_build_proto); | 403 chrome_build_proto); |
407 checkin_request_.reset( | 404 checkin_request_.reset( |
408 new CheckinRequest(gservices_settings_.GetCheckinURL(), | 405 new CheckinRequest(gservices_settings_.GetCheckinURL(), |
409 request_info, | 406 request_info, |
410 kDefaultBackoffPolicy, | 407 kDefaultBackoffPolicy, |
411 base::Bind(&GCMClientImpl::OnCheckinCompleted, | 408 base::Bind(&GCMClientImpl::OnCheckinCompleted, |
412 weak_ptr_factory_.GetWeakPtr()), | 409 weak_ptr_factory_.GetWeakPtr()), |
413 url_request_context_getter_, | 410 url_request_context_getter_, |
414 &recorder_)); | 411 &recorder_)); |
415 checkin_request_->Start(); | 412 checkin_request_->Start(); |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 | 882 |
886 recorder_.RecordIncomingSendError( | 883 recorder_.RecordIncomingSendError( |
887 data_message_stanza.category(), | 884 data_message_stanza.category(), |
888 data_message_stanza.to(), | 885 data_message_stanza.to(), |
889 data_message_stanza.id()); | 886 data_message_stanza.id()); |
890 delegate_->OnMessageSendError(data_message_stanza.category(), | 887 delegate_->OnMessageSendError(data_message_stanza.category(), |
891 send_error_details); | 888 send_error_details); |
892 } | 889 } |
893 | 890 |
894 } // namespace gcm | 891 } // namespace gcm |
OLD | NEW |