Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: google_apis/gcm/gcm_client_impl.cc

Issue 215363007: [GCM] Adding basic G-services handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing the G-services handling form GCMClientImpl Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « google_apis/gcm/gcm_client_impl.h ('k') | google_apis/gcm/tools/mcs_probe.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "google_apis/gcm/gcm_client_impl.h" 5 #include "google_apis/gcm/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"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
14 #include "base/strings/string_number_conversions.h"
14 #include "base/time/default_clock.h" 15 #include "base/time/default_clock.h"
15 #include "google_apis/gcm/base/mcs_message.h" 16 #include "google_apis/gcm/base/mcs_message.h"
16 #include "google_apis/gcm/base/mcs_util.h" 17 #include "google_apis/gcm/base/mcs_util.h"
17 #include "google_apis/gcm/engine/checkin_request.h" 18 #include "google_apis/gcm/engine/checkin_request.h"
18 #include "google_apis/gcm/engine/connection_factory_impl.h" 19 #include "google_apis/gcm/engine/connection_factory_impl.h"
19 #include "google_apis/gcm/engine/gcm_store_impl.h" 20 #include "google_apis/gcm/engine/gcm_store_impl.h"
20 #include "google_apis/gcm/engine/mcs_client.h" 21 #include "google_apis/gcm/engine/mcs_client.h"
21 #include "google_apis/gcm/protocol/mcs.pb.h" 22 #include "google_apis/gcm/protocol/mcs.pb.h"
22 #include "net/http/http_network_session.h" 23 #include "net/http/http_network_session.h"
23 #include "net/url_request/url_request_context.h" 24 #include "net/url_request/url_request_context.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 mcs_client_->Login(device_checkin_info_.android_id, 287 mcs_client_->Login(device_checkin_info_.android_id,
287 device_checkin_info_.secret); 288 device_checkin_info_.secret);
288 } 289 }
289 290
290 void GCMClientImpl::ResetState() { 291 void GCMClientImpl::ResetState() {
291 state_ = UNINITIALIZED; 292 state_ = UNINITIALIZED;
292 // TODO(fgorski): reset all of the necessart objects and start over. 293 // TODO(fgorski): reset all of the necessart objects and start over.
293 } 294 }
294 295
295 void GCMClientImpl::StartCheckin() { 296 void GCMClientImpl::StartCheckin() {
297 CheckinRequest::RequestInfo request_info(
298 device_checkin_info_.android_id,
299 device_checkin_info_.secret,
300 std::string(),
301 account_ids_,
302 chrome_build_proto_);
296 checkin_request_.reset( 303 checkin_request_.reset(
297 new CheckinRequest(base::Bind(&GCMClientImpl::OnCheckinCompleted, 304 new CheckinRequest(request_info,
305 kDefaultBackoffPolicy,
306 base::Bind(&GCMClientImpl::OnCheckinCompleted,
298 weak_ptr_factory_.GetWeakPtr()), 307 weak_ptr_factory_.GetWeakPtr()),
299 kDefaultBackoffPolicy,
300 chrome_build_proto_,
301 device_checkin_info_.android_id,
302 device_checkin_info_.secret,
303 account_ids_,
304 url_request_context_getter_)); 308 url_request_context_getter_));
305 checkin_request_->Start(); 309 checkin_request_->Start();
306 } 310 }
307 311
308 void GCMClientImpl::OnCheckinCompleted(uint64 android_id, 312 void GCMClientImpl::OnCheckinCompleted(
309 uint64 security_token) { 313 const checkin_proto::AndroidCheckinResponse& checkin_response) {
310 checkin_request_.reset(); 314 checkin_request_.reset();
311 315
312 CheckinInfo checkin_info; 316 if (!checkin_response.has_android_id() ||
313 checkin_info.android_id = android_id; 317 !checkin_response.has_security_token()) {
314 checkin_info.secret = security_token; 318 // TODO(fgorski): I don't think a retry here will help, we should probably
315
316 if (!checkin_info.IsValid()) {
317 // TODO(fgorski): I don't think a retry here will help, we should probalby
318 // start over. By checking in with (0, 0). 319 // start over. By checking in with (0, 0).
319 return; 320 return;
320 } 321 }
321 322
323 CheckinInfo checkin_info;
324 checkin_info.android_id = checkin_response.android_id();
325 checkin_info.secret = checkin_response.security_token();
326
322 if (state_ == INITIAL_DEVICE_CHECKIN) { 327 if (state_ == INITIAL_DEVICE_CHECKIN) {
323 OnFirstTimeDeviceCheckinCompleted(checkin_info); 328 OnFirstTimeDeviceCheckinCompleted(checkin_info);
324 } else { 329 } else {
325 // checkin_info is not expected to change after a periodic checkin as it 330 // checkin_info is not expected to change after a periodic checkin as it
326 // would invalidate the registratoin IDs. 331 // would invalidate the registratoin IDs.
327 DCHECK_EQ(READY, state_); 332 DCHECK_EQ(READY, state_);
328 DCHECK_EQ(device_checkin_info_.android_id, checkin_info.android_id); 333 DCHECK_EQ(device_checkin_info_.android_id, checkin_info.android_id);
329 DCHECK_EQ(device_checkin_info_.secret, checkin_info.secret); 334 DCHECK_EQ(device_checkin_info_.secret, checkin_info.secret);
330 } 335 }
331 336
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 if (iter != send_error_details.additional_data.end()) { 701 if (iter != send_error_details.additional_data.end()) {
697 send_error_details.message_id = iter->second; 702 send_error_details.message_id = iter->second;
698 send_error_details.additional_data.erase(iter); 703 send_error_details.additional_data.erase(iter);
699 } 704 }
700 705
701 delegate_->OnMessageSendError(data_message_stanza.category(), 706 delegate_->OnMessageSendError(data_message_stanza.category(),
702 send_error_details); 707 send_error_details);
703 } 708 }
704 709
705 } // namespace gcm 710 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/gcm_client_impl.h ('k') | google_apis/gcm/tools/mcs_probe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698