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

Side by Side Diff: components/invalidation/impl/gcm_network_channel.cc

Issue 2704383002: Network traffic annotation added to gcm_network_channel. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « components/invalidation/impl/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/invalidation/impl/gcm_network_channel.h" 5 #include "components/invalidation/impl/gcm_network_channel.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64url.h" 9 #include "base/base64url.h"
10 #include "base/i18n/time_formatting.h" 10 #include "base/i18n/time_formatting.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/sha1.h" 13 #include "base/sha1.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "components/data_use_measurement/core/data_use_user_data.h" 19 #include "components/data_use_measurement/core/data_use_user_data.h"
20 #include "components/invalidation/impl/gcm_network_channel_delegate.h" 20 #include "components/invalidation/impl/gcm_network_channel_delegate.h"
21 #include "google_apis/gaia/google_service_auth_error.h" 21 #include "google_apis/gaia/google_service_auth_error.h"
22 #include "net/http/http_status_code.h" 22 #include "net/http/http_status_code.h"
23 #include "net/traffic_annotation/network_traffic_annotation.h"
23 #include "net/url_request/url_fetcher.h" 24 #include "net/url_request/url_fetcher.h"
24 #include "net/url_request/url_request_status.h" 25 #include "net/url_request/url_request_status.h"
25 26
26 #if !defined(OS_ANDROID) 27 #if !defined(OS_ANDROID)
27 // channel_common.proto defines ANDROID constant that conflicts with Android 28 // channel_common.proto defines ANDROID constant that conflicts with Android
28 // build. At the same time TiclInvalidationService is not used on Android so it 29 // build. At the same time TiclInvalidationService is not used on Android so it
29 // is safe to exclude these protos from Android build. 30 // is safe to exclude these protos from Android build.
30 #include "google/cacheinvalidation/android_channel.pb.h" 31 #include "google/cacheinvalidation/android_channel.pb.h"
31 #include "google/cacheinvalidation/channel_common.pb.h" 32 #include "google/cacheinvalidation/channel_common.pb.h"
32 #include "google/cacheinvalidation/types.pb.h" 33 #include "google/cacheinvalidation/types.pb.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // Message won't get sent. Notify that http channel doesn't work. 211 // Message won't get sent. Notify that http channel doesn't work.
211 UpdateHttpChannelState(false); 212 UpdateHttpChannelState(false);
212 cached_message_.clear(); 213 cached_message_.clear();
213 return; 214 return;
214 } 215 }
215 DCHECK(!token.empty()); 216 DCHECK(!token.empty());
216 // Save access token in case POST fails and we need to invalidate it. 217 // Save access token in case POST fails and we need to invalidate it.
217 access_token_ = token; 218 access_token_ = token;
218 219
219 DVLOG(2) << "Got access token, sending message"; 220 DVLOG(2) << "Got access token, sending message";
220 fetcher_ = net::URLFetcher::Create(BuildUrl(registration_id_), 221 net::NetworkTrafficAnnotationTag traffic_annotation =
221 net::URLFetcher::POST, this); 222 net::DefineNetworkTrafficAnnotation("...", R"(
223 semantics {
224 sender: "..."
dcheng 2017/02/23 19:15:12 To help me understand, is this something that will
Ramin Halavati 2017/02/24 10:16:00 Sorry that the first message was not clear enough.
dcheng 2017/02/25 00:17:43 I see. I'm probably not a good reviewer for this C
pavely 2017/02/27 19:29:41 sender: Invalidation service
Ramin Halavati 2017/02/28 11:57:03 Done.
225 description: "..."
pavely 2017/02/27 19:29:41 Chrome uses cacheinvalidation library to receive p
Ramin Halavati 2017/02/28 11:57:03 Done.
226 trigger: "..."
pavely 2017/02/27 19:29:41 The first message is sent to register client with
Ramin Halavati 2017/02/28 11:57:03 Done.
227 data: "..."
Ramin Halavati 2017/02/28 11:57:04 Please specify what data is sent.
pavely 2017/02/28 18:38:49 No PII data is sent in this request. Request cont
Ramin Halavati 2017/03/01 08:35:02 Done.
228 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
pavely 2017/02/27 19:29:41 destination: GOOGLE_OWNED_SERVICE
Ramin Halavati 2017/03/01 08:35:01 Done.
229 }
230 policy {
231 cookies_allowed: false/true
pavely 2017/02/27 19:29:41 cookies_allowed: false
Ramin Halavati 2017/02/28 11:57:03 It seems to me that cookies are not disabled. If t
pavely 2017/02/28 18:38:49 I believe cookies are not required. Authentication
Ramin Halavati 2017/03/01 08:35:02 https://codereview.chromium.org/2723043002 created
232 cookies_store: "..."
233 setting: "..."
pavely 2017/02/27 19:29:41 Invalidation service is enabled by default. I don'
Ramin Halavati 2017/02/28 11:57:03 Isn't it disabled if Sync is disabled?
pavely 2017/02/28 18:38:49 Apart from Sync, InvalidationService is used by co
Ramin Halavati 2017/03/01 08:35:01 Acknowledged.
234 policy {
235 [POLICY_NAME] {
Ramin Halavati 2017/02/28 11:57:03 Isn't this related? http://dev.chromium.org/admin
pavely 2017/02/28 18:38:49 This policy disables sync, it doesn't affect other
Ramin Halavati 2017/03/01 08:35:02 Acknowledged.
236 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
237 value: ...
238 }
239 }
240 policy_exception_justification: "..."
Ramin Halavati 2017/02/28 11:57:03 Do you think it's useful to have a policy to disab
pavely 2017/02/28 18:38:49 Disabling InvalidationService might break features
Ramin Halavati 2017/03/01 08:35:01 Done.
241 })");
242 fetcher_ =
243 net::URLFetcher::Create(BuildUrl(registration_id_), net::URLFetcher::POST,
244 this, traffic_annotation);
222 data_use_measurement::DataUseUserData::AttachToFetcher( 245 data_use_measurement::DataUseUserData::AttachToFetcher(
223 fetcher_.get(), data_use_measurement::DataUseUserData::INVALIDATION); 246 fetcher_.get(), data_use_measurement::DataUseUserData::INVALIDATION);
224 fetcher_->SetRequestContext(request_context_getter_.get()); 247 fetcher_->SetRequestContext(request_context_getter_.get());
225 const std::string auth_header("Authorization: Bearer " + access_token_); 248 const std::string auth_header("Authorization: Bearer " + access_token_);
226 fetcher_->AddExtraRequestHeader(auth_header); 249 fetcher_->AddExtraRequestHeader(auth_header);
227 if (!echo_token_.empty()) { 250 if (!echo_token_.empty()) {
228 const std::string echo_header("echo-token: " + echo_token_); 251 const std::string echo_header("echo-token: " + echo_token_);
229 fetcher_->AddExtraRequestHeader(echo_header); 252 fetcher_->AddExtraRequestHeader(echo_header);
230 } 253 }
231 fetcher_->SetUploadData("application/x-protobuffer", cached_message_); 254 fetcher_->SetUploadData("application/x-protobuffer", cached_message_);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 ENUM_CASE(gcm::GCMClient::UNKNOWN_ERROR); 466 ENUM_CASE(gcm::GCMClient::UNKNOWN_ERROR);
444 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER); 467 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER);
445 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING); 468 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING);
446 ENUM_CASE(gcm::GCMClient::GCM_DISABLED); 469 ENUM_CASE(gcm::GCMClient::GCM_DISABLED);
447 } 470 }
448 NOTREACHED(); 471 NOTREACHED();
449 return ""; 472 return "";
450 } 473 }
451 474
452 } // namespace syncer 475 } // namespace syncer
OLDNEW
« no previous file with comments | « components/invalidation/impl/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698