OLD | NEW |
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 "sync/internal_api/public/http_bridge.h" | 5 #include "sync/internal_api/public/http_bridge.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "components/data_use_measurement/core/data_use_user_data.h" |
13 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "net/http/http_cache.h" | 16 #include "net/http/http_cache.h" |
16 #include "net/http/http_network_layer.h" | 17 #include "net/http/http_network_layer.h" |
17 #include "net/http/http_request_headers.h" | 18 #include "net/http/http_request_headers.h" |
18 #include "net/http/http_response_headers.h" | 19 #include "net/http/http_response_headers.h" |
19 #include "net/url_request/static_http_user_agent_settings.h" | 20 #include "net/url_request/static_http_user_agent_settings.h" |
20 #include "net/url_request/url_fetcher.h" | 21 #include "net/url_request/url_fetcher.h" |
21 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
22 #include "net/url_request/url_request_job_factory_impl.h" | 23 #include "net/url_request/url_request_job_factory_impl.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 fetch_state_.http_request_timeout_timer.reset(new base::Timer(false, false)); | 307 fetch_state_.http_request_timeout_timer.reset(new base::Timer(false, false)); |
307 fetch_state_.http_request_timeout_timer->Start( | 308 fetch_state_.http_request_timeout_timer->Start( |
308 FROM_HERE, base::TimeDelta::FromSeconds(kMaxHttpRequestTimeSeconds), | 309 FROM_HERE, base::TimeDelta::FromSeconds(kMaxHttpRequestTimeSeconds), |
309 base::Bind(&HttpBridge::OnURLFetchTimedOut, this)); | 310 base::Bind(&HttpBridge::OnURLFetchTimedOut, this)); |
310 | 311 |
311 DCHECK(request_context_getter_.get()); | 312 DCHECK(request_context_getter_.get()); |
312 fetch_state_.start_time = base::Time::Now(); | 313 fetch_state_.start_time = base::Time::Now(); |
313 fetch_state_.url_poster = | 314 fetch_state_.url_poster = |
314 net::URLFetcher::Create(url_for_request_, net::URLFetcher::POST, this) | 315 net::URLFetcher::Create(url_for_request_, net::URLFetcher::POST, this) |
315 .release(); | 316 .release(); |
| 317 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 318 fetch_state_.url_poster, data_use_measurement::DataUseUserData::SYNC); |
316 fetch_state_.url_poster->SetRequestContext(request_context_getter_.get()); | 319 fetch_state_.url_poster->SetRequestContext(request_context_getter_.get()); |
317 fetch_state_.url_poster->SetExtraRequestHeaders(extra_headers_); | 320 fetch_state_.url_poster->SetExtraRequestHeaders(extra_headers_); |
318 | 321 |
319 int64 compressed_content_size = 0; | 322 int64 compressed_content_size = 0; |
320 if (IsSyncHttpContentCompressionEnabled()) { | 323 if (IsSyncHttpContentCompressionEnabled()) { |
321 std::string compressed_request_content; | 324 std::string compressed_request_content; |
322 GzipCompress(request_content_, &compressed_request_content); | 325 GzipCompress(request_content_, &compressed_request_content); |
323 compressed_content_size = compressed_request_content.size(); | 326 compressed_content_size = compressed_request_content.size(); |
324 fetch_state_.url_poster->SetUploadData(content_type_, | 327 fetch_state_.url_poster->SetUploadData(content_type_, |
325 compressed_request_content); | 328 compressed_request_content); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 int64 sane_time_ms = 0; | 529 int64 sane_time_ms = 0; |
527 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { | 530 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { |
528 network_time_update_callback_.Run( | 531 network_time_update_callback_.Run( |
529 base::Time::FromJsTime(sane_time_ms), | 532 base::Time::FromJsTime(sane_time_ms), |
530 base::TimeDelta::FromMilliseconds(1), | 533 base::TimeDelta::FromMilliseconds(1), |
531 fetch_state_.end_time - fetch_state_.start_time); | 534 fetch_state_.end_time - fetch_state_.start_time); |
532 } | 535 } |
533 } | 536 } |
534 | 537 |
535 } // namespace syncer | 538 } // namespace syncer |
OLD | NEW |