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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_.reset(net::URLFetcher::Create( |
211 BuildUrl(registration_id_), net::URLFetcher::POST, this)); | 211 BuildUrl(registration_id_), net::URLFetcher::POST, this)); |
212 fetcher_->SetRequestContext(request_context_getter_); | 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. |
222 cached_message_.clear(); | 222 cached_message_.clear(); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 ENUM_CASE(gcm::GCMClient::NOT_SIGNED_IN); | 449 ENUM_CASE(gcm::GCMClient::NOT_SIGNED_IN); |
450 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER); | 450 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER); |
451 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING); | 451 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING); |
452 ENUM_CASE(gcm::GCMClient::GCM_DISABLED); | 452 ENUM_CASE(gcm::GCMClient::GCM_DISABLED); |
453 } | 453 } |
454 NOTREACHED(); | 454 NOTREACHED(); |
455 return ""; | 455 return ""; |
456 } | 456 } |
457 | 457 |
458 } // namespace syncer | 458 } // namespace syncer |
OLD | NEW |