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

Side by Side Diff: google_apis/gcm/engine/registration_request.cc

Issue 2737433002: Network traffic annotation added to goolge_apis/gcm/engine. (Closed)
Patch Set: Wrong files removed. 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
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 "google_apis/gcm/engine/registration_request.h" 5 #include "google_apis/gcm/engine/registration_request.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "google_apis/gcm/base/gcm_util.h" 18 #include "google_apis/gcm/base/gcm_util.h"
19 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" 19 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
20 #include "net/base/load_flags.h" 20 #include "net/base/load_flags.h"
21 #include "net/http/http_request_headers.h" 21 #include "net/http/http_request_headers.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_context_getter.h" 25 #include "net/url_request/url_request_context_getter.h"
25 #include "net/url_request/url_request_status.h" 26 #include "net/url_request/url_request_status.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 28
28 namespace gcm { 29 namespace gcm {
29 30
30 namespace { 31 namespace {
31 32
32 const char kRegistrationRequestContentType[] = 33 const char kRegistrationRequestContentType[] =
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 source_to_record_(source_to_record), 138 source_to_record_(source_to_record),
138 weak_ptr_factory_(this) { 139 weak_ptr_factory_(this) {
139 DCHECK_GE(max_retry_count, 0); 140 DCHECK_GE(max_retry_count, 0);
140 } 141 }
141 142
142 RegistrationRequest::~RegistrationRequest() {} 143 RegistrationRequest::~RegistrationRequest() {}
143 144
144 void RegistrationRequest::Start() { 145 void RegistrationRequest::Start() {
145 DCHECK(!callback_.is_null()); 146 DCHECK(!callback_.is_null());
146 DCHECK(!url_fetcher_.get()); 147 DCHECK(!url_fetcher_.get());
147 148 net::NetworkTrafficAnnotationTag traffic_annotation =
148 url_fetcher_ = 149 net::DefineNetworkTrafficAnnotation("gcm_registration", R"(
149 net::URLFetcher::Create(registration_url_, net::URLFetcher::POST, this); 150 semantics {
151 sender: "GCM Driver"
152 description:
153 "Chromium interacts with Google Cloud Messaging to receive push "
154 "messages for various browser features, as well as on behalf of "
155 "websites and extensions. This requests Google Cloud Messaging to "
156 "create a new subscription through which messages can be sent to "
157 "the registering entity, through Chromium."
158 trigger:
159 "Immediately after a feature, website or extension creates a new "
160 "registration with the GCM Driver."
Dmitry Titov 2017/03/18 01:27:12 Not sure if it makes any difference, but it can be
Peter Beverloo 2017/03/21 00:18:46 I think that'd be a good addition. Let me send you
161 data:
162 "The profile-bound Android ID and associated secret, and the "
163 "identifiers for the feature, website or extension that is "
164 "creating the registration."
165 destination: GOOGLE_OWNED_SERVICE
166 }
167 policy {
168 cookies_allowed: false
169 setting:
170 "Support for interacting with Google Cloud Messaging is enabled by "
171 "default, and there is no configuration option to completely "
172 "disable it."
173 policy_exception_justification:
174 "Not implemented, considered not useful."
175 })");
176 url_fetcher_ = net::URLFetcher::Create(
177 registration_url_, net::URLFetcher::POST, this, traffic_annotation);
150 url_fetcher_->SetRequestContext(request_context_getter_.get()); 178 url_fetcher_->SetRequestContext(request_context_getter_.get());
151 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 179 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
152 net::LOAD_DO_NOT_SAVE_COOKIES); 180 net::LOAD_DO_NOT_SAVE_COOKIES);
153 181
154 std::string extra_headers; 182 std::string extra_headers;
155 BuildRequestHeaders(&extra_headers); 183 BuildRequestHeaders(&extra_headers);
156 url_fetcher_->SetExtraRequestHeaders(extra_headers); 184 url_fetcher_->SetExtraRequestHeaders(extra_headers);
157 185
158 std::string body; 186 std::string body;
159 BuildRequestBody(&body); 187 BuildRequestBody(&body);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 // Only REACHED_MAX_RETRIES is reported because the function will skip 301 // Only REACHED_MAX_RETRIES is reported because the function will skip
274 // reporting count and time when status is not SUCCESS. 302 // reporting count and time when status is not SUCCESS.
275 DCHECK(custom_request_handler_.get()); 303 DCHECK(custom_request_handler_.get());
276 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); 304 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta());
277 } 305 }
278 306
279 callback_.Run(status, token); 307 callback_.Run(status, token);
280 } 308 }
281 309
282 } // namespace gcm 310 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/checkin_request.cc ('k') | google_apis/gcm/engine/unregistration_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698