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

Side by Side Diff: components/sync/engine/net/http_bridge.cc

Issue 2707363004: Network traffic annotation added to sync. (Closed)
Patch Set: 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/sync/engine/net/http_bridge.h" 5 #include "components/sync/engine/net/http_bridge.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bit_cast.h" 11 #include "base/bit_cast.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/metrics/sparse_histogram.h" 15 #include "base/metrics/sparse_histogram.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
20 #include "components/sync/base/cancelation_signal.h" 20 #include "components/sync/base/cancelation_signal.h"
21 #include "net/base/load_flags.h" 21 #include "net/base/load_flags.h"
22 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
23 #include "net/http/http_cache.h" 23 #include "net/http/http_cache.h"
24 #include "net/http/http_network_layer.h" 24 #include "net/http/http_network_layer.h"
25 #include "net/http/http_request_headers.h" 25 #include "net/http/http_request_headers.h"
26 #include "net/http/http_response_headers.h" 26 #include "net/http/http_response_headers.h"
27 #include "net/traffic_annotation/network_traffic_annotation.h"
27 #include "net/url_request/static_http_user_agent_settings.h" 28 #include "net/url_request/static_http_user_agent_settings.h"
28 #include "net/url_request/url_fetcher.h" 29 #include "net/url_request/url_fetcher.h"
29 #include "net/url_request/url_request_job_factory_impl.h" 30 #include "net/url_request/url_request_job_factory_impl.h"
30 #include "net/url_request/url_request_status.h" 31 #include "net/url_request/url_request_status.h"
31 #include "third_party/zlib/google/compression_utils.h" 32 #include "third_party/zlib/google/compression_utils.h"
32 33
33 namespace syncer { 34 namespace syncer {
34 35
35 namespace { 36 namespace {
36 37
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // on, and on which the url fetcher lives). 228 // on, and on which the url fetcher lives).
228 DCHECK(!fetch_state_.http_request_timeout_timer.get()); 229 DCHECK(!fetch_state_.http_request_timeout_timer.get());
229 fetch_state_.http_request_timeout_timer = 230 fetch_state_.http_request_timeout_timer =
230 base::MakeUnique<base::Timer>(false, false); 231 base::MakeUnique<base::Timer>(false, false);
231 fetch_state_.http_request_timeout_timer->Start( 232 fetch_state_.http_request_timeout_timer->Start(
232 FROM_HERE, base::TimeDelta::FromSeconds(kMaxHttpRequestTimeSeconds), 233 FROM_HERE, base::TimeDelta::FromSeconds(kMaxHttpRequestTimeSeconds),
233 base::Bind(&HttpBridge::OnURLFetchTimedOut, this)); 234 base::Bind(&HttpBridge::OnURLFetchTimedOut, this));
234 235
235 DCHECK(request_context_getter_.get()); 236 DCHECK(request_context_getter_.get());
236 fetch_state_.start_time = base::Time::Now(); 237 fetch_state_.start_time = base::Time::Now();
238 net::NetworkTrafficAnnotationTag traffic_annotation =
239 net::DefineNetworkTrafficAnnotation("...", R"(
240 semantics {
241 sender: "..."
Nicolas Zea 2017/03/03 22:39:55 sender: "chrome sync" description: "Chrome Sync wi
Ramin Halavati 2017/03/06 06:55:45 Done.
242 description: "..."
243 trigger: "..."
244 data: "..."
245 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
246 }
247 policy {
248 cookies_allowed: false/true
249 cookies_store: "..."
250 setting: "..."
251 policy {
252 [POLICY_NAME] {
253 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
254 value: ...
255 }
256 }
257 policy_exception_justification: "..."
258 })");
237 fetch_state_.url_poster = 259 fetch_state_.url_poster =
238 net::URLFetcher::Create(url_for_request_, net::URLFetcher::POST, this) 260 net::URLFetcher::Create(url_for_request_, net::URLFetcher::POST, this,
261 traffic_annotation)
239 .release(); 262 .release();
240 if (!bind_to_tracker_callback_.is_null()) 263 if (!bind_to_tracker_callback_.is_null())
241 bind_to_tracker_callback_.Run(fetch_state_.url_poster); 264 bind_to_tracker_callback_.Run(fetch_state_.url_poster);
242 fetch_state_.url_poster->SetRequestContext(request_context_getter_.get()); 265 fetch_state_.url_poster->SetRequestContext(request_context_getter_.get());
243 fetch_state_.url_poster->SetExtraRequestHeaders(extra_headers_); 266 fetch_state_.url_poster->SetExtraRequestHeaders(extra_headers_);
244 267
245 std::string request_to_send; 268 std::string request_to_send;
246 compression::GzipCompress(request_content_, &request_to_send); 269 compression::GzipCompress(request_content_, &request_to_send);
247 fetch_state_.url_poster->AddExtraRequestHeader("Content-Encoding: gzip"); 270 fetch_state_.url_poster->AddExtraRequestHeader("Content-Encoding: gzip");
248 fetch_state_.url_poster->SetUploadData(content_type_, request_to_send); 271 fetch_state_.url_poster->SetUploadData(content_type_, request_to_send);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 int64_t sane_time_ms = 0; 465 int64_t sane_time_ms = 0;
443 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { 466 if (base::StringToInt64(sane_time_str, &sane_time_ms)) {
444 network_time_update_callback_.Run( 467 network_time_update_callback_.Run(
445 base::Time::FromJsTime(sane_time_ms), 468 base::Time::FromJsTime(sane_time_ms),
446 base::TimeDelta::FromMilliseconds(1), 469 base::TimeDelta::FromMilliseconds(1),
447 fetch_state_.end_time - fetch_state_.start_time); 470 fetch_state_.end_time - fetch_state_.start_time);
448 } 471 }
449 } 472 }
450 473
451 } // namespace syncer 474 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698