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/location.h" | 7 #include "base/location.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #if !defined(OS_ANDROID) | 14 #if !defined(OS_ANDROID) |
15 // channel_common.proto defines ANDROID constant that conflicts with Android | 15 // channel_common.proto defines ANDROID constant that conflicts with Android |
16 // build. At the same time TiclInvalidationService is not used on Android so it | 16 // build. At the same time TiclInvalidationService is not used on Android so it |
17 // is safe to exclude these protos from Android build. | 17 // is safe to exclude these protos from Android build. |
18 #include "google/cacheinvalidation/android_channel.pb.h" | 18 #include "google/cacheinvalidation/android_channel.pb.h" |
19 #include "google/cacheinvalidation/channel_common.pb.h" | 19 #include "google/cacheinvalidation/channel_common.pb.h" |
20 #include "google/cacheinvalidation/types.pb.h" | 20 #include "google/cacheinvalidation/types.pb.h" |
21 #endif | 21 #endif |
| 22 #include "components/data_use_measurement/core/data_use_user_data.h" |
22 #include "components/invalidation/impl/gcm_network_channel.h" | 23 #include "components/invalidation/impl/gcm_network_channel.h" |
23 #include "components/invalidation/impl/gcm_network_channel_delegate.h" | 24 #include "components/invalidation/impl/gcm_network_channel_delegate.h" |
24 #include "google_apis/gaia/google_service_auth_error.h" | 25 #include "google_apis/gaia/google_service_auth_error.h" |
25 #include "net/http/http_status_code.h" | 26 #include "net/http/http_status_code.h" |
26 #include "net/url_request/url_fetcher.h" | 27 #include "net/url_request/url_fetcher.h" |
27 #include "net/url_request/url_request_status.h" | 28 #include "net/url_request/url_request_status.h" |
28 | 29 |
29 namespace syncer { | 30 namespace syncer { |
30 | 31 |
31 namespace { | 32 namespace { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 cached_message_.clear(); | 205 cached_message_.clear(); |
205 return; | 206 return; |
206 } | 207 } |
207 DCHECK(!token.empty()); | 208 DCHECK(!token.empty()); |
208 // Save access token in case POST fails and we need to invalidate it. | 209 // Save access token in case POST fails and we need to invalidate it. |
209 access_token_ = token; | 210 access_token_ = token; |
210 | 211 |
211 DVLOG(2) << "Got access token, sending message"; | 212 DVLOG(2) << "Got access token, sending message"; |
212 fetcher_ = net::URLFetcher::Create(BuildUrl(registration_id_), | 213 fetcher_ = net::URLFetcher::Create(BuildUrl(registration_id_), |
213 net::URLFetcher::POST, this); | 214 net::URLFetcher::POST, this); |
| 215 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 216 fetcher_.get(), data_use_measurement::DataUseUserData::INVALIDATION); |
214 fetcher_->SetRequestContext(request_context_getter_.get()); | 217 fetcher_->SetRequestContext(request_context_getter_.get()); |
215 const std::string auth_header("Authorization: Bearer " + access_token_); | 218 const std::string auth_header("Authorization: Bearer " + access_token_); |
216 fetcher_->AddExtraRequestHeader(auth_header); | 219 fetcher_->AddExtraRequestHeader(auth_header); |
217 if (!echo_token_.empty()) { | 220 if (!echo_token_.empty()) { |
218 const std::string echo_header("echo-token: " + echo_token_); | 221 const std::string echo_header("echo-token: " + echo_token_); |
219 fetcher_->AddExtraRequestHeader(echo_header); | 222 fetcher_->AddExtraRequestHeader(echo_header); |
220 } | 223 } |
221 fetcher_->SetUploadData("application/x-protobuffer", cached_message_); | 224 fetcher_->SetUploadData("application/x-protobuffer", cached_message_); |
222 fetcher_->Start(); | 225 fetcher_->Start(); |
223 // Clear message to prevent accidentally resending it in the future. | 226 // Clear message to prevent accidentally resending it in the future. |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 ENUM_CASE(gcm::GCMClient::UNKNOWN_ERROR); | 453 ENUM_CASE(gcm::GCMClient::UNKNOWN_ERROR); |
451 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER); | 454 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER); |
452 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING); | 455 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING); |
453 ENUM_CASE(gcm::GCMClient::GCM_DISABLED); | 456 ENUM_CASE(gcm::GCMClient::GCM_DISABLED); |
454 } | 457 } |
455 NOTREACHED(); | 458 NOTREACHED(); |
456 return ""; | 459 return ""; |
457 } | 460 } |
458 | 461 |
459 } // namespace syncer | 462 } // namespace syncer |
OLD | NEW |