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

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

Issue 2707363004: Network traffic annotation added to sync. (Closed)
Patch Set: policy changed to chrome_policy. 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("sync_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:
256 "Users can disable Chrome Sync by going into the profile settings "
257 "and choosing to Sign Out."
258 chrome_policy {
259 SyncDisabled {
260 policy_options {mode: MANDATORY}
261 SyncDisabled: true
262 }
263 }
264 })");
237 fetch_state_.url_poster = 265 fetch_state_.url_poster =
238 net::URLFetcher::Create(url_for_request_, net::URLFetcher::POST, this) 266 net::URLFetcher::Create(url_for_request_, net::URLFetcher::POST, this,
267 traffic_annotation)
239 .release(); 268 .release();
240 if (!bind_to_tracker_callback_.is_null()) 269 if (!bind_to_tracker_callback_.is_null())
241 bind_to_tracker_callback_.Run(fetch_state_.url_poster); 270 bind_to_tracker_callback_.Run(fetch_state_.url_poster);
242 fetch_state_.url_poster->SetRequestContext(request_context_getter_.get()); 271 fetch_state_.url_poster->SetRequestContext(request_context_getter_.get());
243 fetch_state_.url_poster->SetExtraRequestHeaders(extra_headers_); 272 fetch_state_.url_poster->SetExtraRequestHeaders(extra_headers_);
244 273
245 std::string request_to_send; 274 std::string request_to_send;
246 compression::GzipCompress(request_content_, &request_to_send); 275 compression::GzipCompress(request_content_, &request_to_send);
247 fetch_state_.url_poster->AddExtraRequestHeader("Content-Encoding: gzip"); 276 fetch_state_.url_poster->AddExtraRequestHeader("Content-Encoding: gzip");
248 fetch_state_.url_poster->SetUploadData(content_type_, request_to_send); 277 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; 471 int64_t sane_time_ms = 0;
443 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { 472 if (base::StringToInt64(sane_time_str, &sane_time_ms)) {
444 network_time_update_callback_.Run( 473 network_time_update_callback_.Run(
445 base::Time::FromJsTime(sane_time_ms), 474 base::Time::FromJsTime(sane_time_ms),
446 base::TimeDelta::FromMilliseconds(1), 475 base::TimeDelta::FromMilliseconds(1),
447 fetch_state_.end_time - fetch_state_.start_time); 476 fetch_state_.end_time - fetch_state_.start_time);
448 } 477 }
449 } 478 }
450 479
451 } // namespace syncer 480 } // 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