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

Side by Side Diff: google_apis/gcm/engine/checkin_request.cc

Issue 215363007: [GCM] Adding basic G-services handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
OLDNEW
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 "google_apis/gcm/engine/checkin_request.h" 5 #include "google_apis/gcm/engine/checkin_request.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "google_apis/gcm/protocol/checkin.pb.h" 10 #include "google_apis/gcm/protocol/checkin.pb.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 net::HttpStatusCode response_status = static_cast<net::HttpStatusCode>( 134 net::HttpStatusCode response_status = static_cast<net::HttpStatusCode>(
135 source->GetResponseCode()); 135 source->GetResponseCode());
136 if (response_status == net::HTTP_BAD_REQUEST || 136 if (response_status == net::HTTP_BAD_REQUEST ||
137 response_status == net::HTTP_UNAUTHORIZED) { 137 response_status == net::HTTP_UNAUTHORIZED) {
138 // BAD_REQUEST indicates that the request was malformed. 138 // BAD_REQUEST indicates that the request was malformed.
139 // UNAUTHORIZED indicates that security token didn't match the android id. 139 // UNAUTHORIZED indicates that security token didn't match the android id.
140 LOG(ERROR) << "No point retrying the checkin with status: " 140 LOG(ERROR) << "No point retrying the checkin with status: "
141 << response_status << ". Checkin failed."; 141 << response_status << ". Checkin failed.";
142 RecordCheckinStatusToUMA(response_status == net::HTTP_BAD_REQUEST ? 142 RecordCheckinStatusToUMA(response_status == net::HTTP_BAD_REQUEST ?
143 HTTP_BAD_REQUEST : HTTP_UNAUTHORIZED); 143 HTTP_BAD_REQUEST : HTTP_UNAUTHORIZED);
144 callback_.Run(0,0); 144 callback_.Run(response_proto);
fgorski 2014/03/28 14:30:51 could we set android_id and security_token to 0 be
Nicolas Zea 2014/03/28 18:31:38 You could pass an empty protobuf here I suspect.
fgorski 2014/03/29 01:09:32 I know I just don't like that idea that much. All
145 return; 145 return;
146 } 146 }
147 147
148 if (response_status != net::HTTP_OK || 148 if (response_status != net::HTTP_OK ||
149 !source->GetResponseAsString(&response_string) || 149 !source->GetResponseAsString(&response_string) ||
150 !response_proto.ParseFromString(response_string)) { 150 !response_proto.ParseFromString(response_string)) {
151 LOG(ERROR) << "Failed to get checkin response. HTTP Status: " 151 LOG(ERROR) << "Failed to get checkin response. HTTP Status: "
152 << response_status << ". Retrying."; 152 << response_status << ". Retrying.";
153 RecordCheckinStatusToUMA(response_status != net::HTTP_OK ? 153 RecordCheckinStatusToUMA(response_status != net::HTTP_OK ?
154 HTTP_NOT_OK : RESPONSE_PARSING_FAILED); 154 HTTP_NOT_OK : RESPONSE_PARSING_FAILED);
155 RetryWithBackoff(true); 155 RetryWithBackoff(true);
156 return; 156 return;
157 } 157 }
158 158
159 if (!response_proto.has_android_id() || 159 if (!response_proto.has_android_id() ||
160 !response_proto.has_security_token() || 160 !response_proto.has_security_token() ||
161 response_proto.android_id() == 0 || 161 response_proto.android_id() == 0 ||
162 response_proto.security_token() == 0) { 162 response_proto.security_token() == 0) {
163 LOG(ERROR) << "Android ID or security token is 0. Retrying."; 163 LOG(ERROR) << "Android ID or security token is 0. Retrying.";
164 RecordCheckinStatusToUMA(ZERO_ID_OR_TOKEN); 164 RecordCheckinStatusToUMA(ZERO_ID_OR_TOKEN);
165 RetryWithBackoff(true); 165 RetryWithBackoff(true);
166 return; 166 return;
167 } 167 }
168 168
169 RecordCheckinStatusToUMA(SUCCESS); 169 RecordCheckinStatusToUMA(SUCCESS);
170 callback_.Run(response_proto.android_id(), response_proto.security_token()); 170 callback_.Run(response_proto);
171 } 171 }
172 172
173 } // namespace gcm 173 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698