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 "base/base64.h" | 5 #include "base/base64.h" |
6 #include "base/i18n/time_formatting.h" | 6 #include "base/i18n/time_formatting.h" |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // Message won't get sent. Notify that http channel doesn't work. | 200 // Message won't get sent. Notify that http channel doesn't work. |
201 UpdateHttpChannelState(false); | 201 UpdateHttpChannelState(false); |
202 cached_message_.clear(); | 202 cached_message_.clear(); |
203 return; | 203 return; |
204 } | 204 } |
205 DCHECK(!token.empty()); | 205 DCHECK(!token.empty()); |
206 // Save access token in case POST fails and we need to invalidate it. | 206 // Save access token in case POST fails and we need to invalidate it. |
207 access_token_ = token; | 207 access_token_ = token; |
208 | 208 |
209 DVLOG(2) << "Got access token, sending message"; | 209 DVLOG(2) << "Got access token, sending message"; |
210 fetcher_.reset(net::URLFetcher::Create( | 210 fetcher_ = net::URLFetcher::Create(BuildUrl(registration_id_), |
211 BuildUrl(registration_id_), net::URLFetcher::POST, this)); | 211 net::URLFetcher::POST, this); |
212 fetcher_->SetRequestContext(request_context_getter_.get()); | 212 fetcher_->SetRequestContext(request_context_getter_.get()); |
213 const std::string auth_header("Authorization: Bearer " + access_token_); | 213 const std::string auth_header("Authorization: Bearer " + access_token_); |
214 fetcher_->AddExtraRequestHeader(auth_header); | 214 fetcher_->AddExtraRequestHeader(auth_header); |
215 if (!echo_token_.empty()) { | 215 if (!echo_token_.empty()) { |
216 const std::string echo_header("echo-token: " + echo_token_); | 216 const std::string echo_header("echo-token: " + echo_token_); |
217 fetcher_->AddExtraRequestHeader(echo_header); | 217 fetcher_->AddExtraRequestHeader(echo_header); |
218 } | 218 } |
219 fetcher_->SetUploadData("application/x-protobuffer", cached_message_); | 219 fetcher_->SetUploadData("application/x-protobuffer", cached_message_); |
220 fetcher_->Start(); | 220 fetcher_->Start(); |
221 // Clear message to prevent accidentally resending it in the future. | 221 // Clear message to prevent accidentally resending it in the future. |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 ENUM_CASE(gcm::GCMClient::UNKNOWN_ERROR); | 448 ENUM_CASE(gcm::GCMClient::UNKNOWN_ERROR); |
449 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER); | 449 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER); |
450 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING); | 450 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING); |
451 ENUM_CASE(gcm::GCMClient::GCM_DISABLED); | 451 ENUM_CASE(gcm::GCMClient::GCM_DISABLED); |
452 } | 452 } |
453 NOTREACHED(); | 453 NOTREACHED(); |
454 return ""; | 454 return ""; |
455 } | 455 } |
456 | 456 |
457 } // namespace syncer | 457 } // namespace syncer |
OLD | NEW |