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