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 "google_apis/gcm/engine/unregistration_request.h" | 5 #include "google_apis/gcm/engine/unregistration_request.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "google_apis/gcm/base/gcm_util.h" | 15 #include "google_apis/gcm/base/gcm_util.h" |
16 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 16 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
17 #include "net/base/escape.h" | 17 #include "net/base/escape.h" |
18 #include "net/base/load_flags.h" | 18 #include "net/base/load_flags.h" |
19 #include "net/http/http_request_headers.h" | 19 #include "net/http/http_request_headers.h" |
20 #include "net/http/http_status_code.h" | 20 #include "net/http/http_status_code.h" |
21 #include "net/traffic_annotation/network_traffic_annotation.h" | |
21 #include "net/url_request/url_fetcher.h" | 22 #include "net/url_request/url_fetcher.h" |
22 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
23 #include "net/url_request/url_request_status.h" | 24 #include "net/url_request/url_request_status.h" |
24 | 25 |
25 namespace gcm { | 26 namespace gcm { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 const char kRequestContentType[] = "application/x-www-form-urlencoded"; | 30 const char kRequestContentType[] = "application/x-www-form-urlencoded"; |
30 | 31 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 source_to_record_(source_to_record), | 121 source_to_record_(source_to_record), |
121 weak_ptr_factory_(this) { | 122 weak_ptr_factory_(this) { |
122 DCHECK_GE(max_retry_count, 0); | 123 DCHECK_GE(max_retry_count, 0); |
123 } | 124 } |
124 | 125 |
125 UnregistrationRequest::~UnregistrationRequest() {} | 126 UnregistrationRequest::~UnregistrationRequest() {} |
126 | 127 |
127 void UnregistrationRequest::Start() { | 128 void UnregistrationRequest::Start() { |
128 DCHECK(!callback_.is_null()); | 129 DCHECK(!callback_.is_null()); |
129 DCHECK(!url_fetcher_.get()); | 130 DCHECK(!url_fetcher_.get()); |
130 | 131 net::NetworkTrafficAnnotationTag traffic_annotation = |
Peter Beverloo
2017/03/15 18:58:04
Proposal (gcm_unregistration):
semantics {
send
Ramin Halavati
2017/03/16 08:43:51
Done.
| |
131 url_fetcher_ = | 132 net::DefineNetworkTrafficAnnotation("...", R"( |
132 net::URLFetcher::Create(registration_url_, net::URLFetcher::POST, this); | 133 semantics { |
134 sender: "..." | |
135 description: "..." | |
136 trigger: "..." | |
137 data: "..." | |
138 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
139 } | |
140 policy { | |
141 cookies_allowed: false/true | |
142 cookies_store: "..." | |
143 setting: "..." | |
144 policy { | |
145 [POLICY_NAME] { | |
146 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
147 [POLICY_NAME]: ... //(value to disable it) | |
148 } | |
149 } | |
150 policy_exception_justification: "..." | |
151 })"); | |
152 url_fetcher_ = net::URLFetcher::Create( | |
153 registration_url_, net::URLFetcher::POST, this, traffic_annotation); | |
133 url_fetcher_->SetRequestContext(request_context_getter_.get()); | 154 url_fetcher_->SetRequestContext(request_context_getter_.get()); |
134 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 155 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
135 net::LOAD_DO_NOT_SAVE_COOKIES); | 156 net::LOAD_DO_NOT_SAVE_COOKIES); |
136 | 157 |
137 std::string extra_headers; | 158 std::string extra_headers; |
138 BuildRequestHeaders(&extra_headers); | 159 BuildRequestHeaders(&extra_headers); |
139 url_fetcher_->SetExtraRequestHeaders(extra_headers); | 160 url_fetcher_->SetExtraRequestHeaders(extra_headers); |
140 | 161 |
141 std::string body; | 162 std::string body; |
142 BuildRequestBody(&body); | 163 BuildRequestBody(&body); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 // Only REACHED_MAX_RETRIES is reported because the function will skip | 279 // Only REACHED_MAX_RETRIES is reported because the function will skip |
259 // reporting count and time when status is not SUCCESS. | 280 // reporting count and time when status is not SUCCESS. |
260 DCHECK(custom_request_handler_.get()); | 281 DCHECK(custom_request_handler_.get()); |
261 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); | 282 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); |
262 } | 283 } |
263 | 284 |
264 callback_.Run(status); | 285 callback_.Run(status); |
265 } | 286 } |
266 | 287 |
267 } // namespace gcm | 288 } // namespace gcm |
OLD | NEW |