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

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

Issue 2707363004: Network traffic annotation added to sync. (Closed)
Patch Set: nits 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("http_bridge", R"(
240 semantics {
241 sender: "Chrome Sync"
242 description:
243 "Chrome Sync synchronizes profile data between Chromium clients "
244 "and Google for a given user account."
245 trigger:
246 "User makes a change to syncable profile data after enabling sync "
247 "on the device."
248 data:
249 "The device and user identifiers, along with any profile data that "
250 "is changing."
251 destination: GOOGLE_OWNED_SERVICE
252 }
253 policy {
254 cookies_allowed: false
255 setting: "This feature cannot be disabled by settings."
Nicolas Zea 2017/03/06 17:56:35 Looks like I forgot to specify this string. It sho
Ramin Halavati 2017/03/07 08:53:47 Done.
256 policy {
257 SyncDisabled {
258 policy_options {mode: MANDATORY}
259 SyncDisabled: true
260 }
261 }
262 })");
237 fetch_state_.url_poster = 263 fetch_state_.url_poster =
238 net::URLFetcher::Create(url_for_request_, net::URLFetcher::POST, this) 264 net::URLFetcher::Create(url_for_request_, net::URLFetcher::POST, this,
265 traffic_annotation)
239 .release(); 266 .release();
240 if (!bind_to_tracker_callback_.is_null()) 267 if (!bind_to_tracker_callback_.is_null())
241 bind_to_tracker_callback_.Run(fetch_state_.url_poster); 268 bind_to_tracker_callback_.Run(fetch_state_.url_poster);
242 fetch_state_.url_poster->SetRequestContext(request_context_getter_.get()); 269 fetch_state_.url_poster->SetRequestContext(request_context_getter_.get());
243 fetch_state_.url_poster->SetExtraRequestHeaders(extra_headers_); 270 fetch_state_.url_poster->SetExtraRequestHeaders(extra_headers_);
244 271
245 std::string request_to_send; 272 std::string request_to_send;
246 compression::GzipCompress(request_content_, &request_to_send); 273 compression::GzipCompress(request_content_, &request_to_send);
247 fetch_state_.url_poster->AddExtraRequestHeader("Content-Encoding: gzip"); 274 fetch_state_.url_poster->AddExtraRequestHeader("Content-Encoding: gzip");
248 fetch_state_.url_poster->SetUploadData(content_type_, request_to_send); 275 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; 469 int64_t sane_time_ms = 0;
443 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { 470 if (base::StringToInt64(sane_time_str, &sane_time_ms)) {
444 network_time_update_callback_.Run( 471 network_time_update_callback_.Run(
445 base::Time::FromJsTime(sane_time_ms), 472 base::Time::FromJsTime(sane_time_ms),
446 base::TimeDelta::FromMilliseconds(1), 473 base::TimeDelta::FromMilliseconds(1),
447 fetch_state_.end_time - fetch_state_.start_time); 474 fetch_state_.end_time - fetch_state_.start_time);
448 } 475 }
449 } 476 }
450 477
451 } // namespace syncer 478 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/sync_stopped_reporter.cc ('k') | components/sync/engine_impl/attachments/attachment_downloader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698