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

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

Issue 2704383002: Network traffic annotation added to gcm_network_channel. (Closed)
Patch Set: Annotation updated. Created 3 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
« 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/base/load_flags.h" 22 #include "net/base/load_flags.h"
23 #include "net/http/http_status_code.h" 23 #include "net/http/http_status_code.h"
24 #include "net/traffic_annotation/network_traffic_annotation.h"
24 #include "net/url_request/url_fetcher.h" 25 #include "net/url_request/url_fetcher.h"
25 #include "net/url_request/url_request_status.h" 26 #include "net/url_request/url_request_status.h"
26 27
27 #if !defined(OS_ANDROID) 28 #if !defined(OS_ANDROID)
28 // channel_common.proto defines ANDROID constant that conflicts with Android 29 // channel_common.proto defines ANDROID constant that conflicts with Android
29 // build. At the same time TiclInvalidationService is not used on Android so it 30 // build. At the same time TiclInvalidationService is not used on Android so it
30 // is safe to exclude these protos from Android build. 31 // is safe to exclude these protos from Android build.
31 #include "google/cacheinvalidation/android_channel.pb.h" 32 #include "google/cacheinvalidation/android_channel.pb.h"
32 #include "google/cacheinvalidation/channel_common.pb.h" 33 #include "google/cacheinvalidation/channel_common.pb.h"
33 #include "google/cacheinvalidation/types.pb.h" 34 #include "google/cacheinvalidation/types.pb.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // Message won't get sent. Notify that http channel doesn't work. 212 // Message won't get sent. Notify that http channel doesn't work.
212 UpdateHttpChannelState(false); 213 UpdateHttpChannelState(false);
213 cached_message_.clear(); 214 cached_message_.clear();
214 return; 215 return;
215 } 216 }
216 DCHECK(!token.empty()); 217 DCHECK(!token.empty());
217 // Save access token in case POST fails and we need to invalidate it. 218 // Save access token in case POST fails and we need to invalidate it.
218 access_token_ = token; 219 access_token_ = token;
219 220
220 DVLOG(2) << "Got access token, sending message"; 221 DVLOG(2) << "Got access token, sending message";
221 fetcher_ = net::URLFetcher::Create(BuildUrl(registration_id_), 222 net::NetworkTrafficAnnotationTag traffic_annotation =
222 net::URLFetcher::POST, this); 223 net::DefineNetworkTrafficAnnotation("invalidation_service", R"(
224 semantics {
225 sender: "Invalidation service"
226 description:
227 "Chromium uses cacheinvalidation library to receive push "
228 "notifications from server about sync items (bookmarks, passwords, "
msramek 2017/03/07 10:53:29 the server
Ramin Halavati 2017/03/07 13:10:35 Done.
229 "preferences, etc.) modified on other clients. It uses GCMClient "
230 "to receive incoming messages. This request is used for "
231 "client-to-server communications."
232 trigger:
233 "The first message is sent to register client with the server on "
234 "Chromium startup. It is then sent periodically to confirm that "
235 "client is still online. After receiving notification about server "
msramek 2017/03/07 10:53:29 the client
Ramin Halavati 2017/03/07 13:10:35 Done.
236 "changes client sends this request to acknowledge that "
msramek 2017/03/07 10:53:29 changes, the client
Ramin Halavati 2017/03/07 13:10:35 Done.
237 "notification is processed."
msramek 2017/03/07 10:53:29 the notification
Ramin Halavati 2017/03/07 13:10:34 Done.
238 data:
239 "No PII data is sent in this request. Request contains "
msramek 2017/03/07 10:53:29 The request.
Ramin Halavati 2017/03/07 13:10:34 Done.
240 "client_token generated on the server. It includes invalidation "
241 "object ids (not specific to client) and versions when confirming "
msramek 2017/03/07 10:53:29 a client I also don't fully understand the senten
msramek 2017/03/14 16:17:50 pavely@, can you please clarify this?
pavely 2017/03/15 17:55:46 As I understand version is internal invalidations
Ramin Halavati 2017/03/16 08:30:41 Done.
242 "invalidations. When updating registrations request includes "
msramek 2017/03/07 10:53:30 registrations, the request
Ramin Halavati 2017/03/07 13:10:35 Done.
msramek 2017/03/14 16:17:49 nit: Still missing the article :)
Ramin Halavati 2017/03/15 07:04:19 Done.
243 "object ids."
244 destination: GOOGLE_OWNED_SERVICE
245 }
246 policy {
247 cookies_allowed: false
248 setting: "This feature cannot be disabled."
249 policy_exception_justification:
250 "Not implemented. Disabling InvalidationService might break "
251 "features that depend on it. I think it makes sense to control "
msramek 2017/03/07 10:53:29 Keep in mind that this text will be read by enterp
Ramin Halavati 2017/03/07 13:10:34 Done.
252 "top level features that use InvalidationService."
253 })");
254 fetcher_ =
255 net::URLFetcher::Create(BuildUrl(registration_id_), net::URLFetcher::POST,
256 this, traffic_annotation);
223 data_use_measurement::DataUseUserData::AttachToFetcher( 257 data_use_measurement::DataUseUserData::AttachToFetcher(
224 fetcher_.get(), data_use_measurement::DataUseUserData::INVALIDATION); 258 fetcher_.get(), data_use_measurement::DataUseUserData::INVALIDATION);
225 fetcher_->SetRequestContext(request_context_getter_.get()); 259 fetcher_->SetRequestContext(request_context_getter_.get());
226 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 260 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
227 net::LOAD_DO_NOT_SAVE_COOKIES); 261 net::LOAD_DO_NOT_SAVE_COOKIES);
228 const std::string auth_header("Authorization: Bearer " + access_token_); 262 const std::string auth_header("Authorization: Bearer " + access_token_);
229 fetcher_->AddExtraRequestHeader(auth_header); 263 fetcher_->AddExtraRequestHeader(auth_header);
230 if (!echo_token_.empty()) { 264 if (!echo_token_.empty()) {
231 const std::string echo_header("echo-token: " + echo_token_); 265 const std::string echo_header("echo-token: " + echo_token_);
232 fetcher_->AddExtraRequestHeader(echo_header); 266 fetcher_->AddExtraRequestHeader(echo_header);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 ENUM_CASE(gcm::GCMClient::UNKNOWN_ERROR); 480 ENUM_CASE(gcm::GCMClient::UNKNOWN_ERROR);
447 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER); 481 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER);
448 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING); 482 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING);
449 ENUM_CASE(gcm::GCMClient::GCM_DISABLED); 483 ENUM_CASE(gcm::GCMClient::GCM_DISABLED);
450 } 484 }
451 NOTREACHED(); 485 NOTREACHED();
452 return ""; 486 return "";
453 } 487 }
454 488
455 } // namespace syncer 489 } // 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