| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bit_cast.h" | 12 #include "base/bit_cast.h" |
| 13 #include "base/location.h" |
| 13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/metrics/sparse_histogram.h" | 17 #include "base/metrics/sparse_histogram.h" |
| 18 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 19 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 22 #include "base/threading/thread_task_runner_handle.h" |
| 20 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
| 21 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 22 #include "net/http/http_cache.h" | 25 #include "net/http/http_cache.h" |
| 23 #include "net/http/http_network_layer.h" | 26 #include "net/http/http_network_layer.h" |
| 24 #include "net/http/http_request_headers.h" | 27 #include "net/http/http_request_headers.h" |
| 25 #include "net/http/http_response_headers.h" | 28 #include "net/http/http_response_headers.h" |
| 26 #include "net/url_request/static_http_user_agent_settings.h" | 29 #include "net/url_request/static_http_user_agent_settings.h" |
| 27 #include "net/url_request/url_fetcher.h" | 30 #include "net/url_request/url_fetcher.h" |
| 28 #include "net/url_request/url_request_context.h" | 31 #include "net/url_request/url_request_context.h" |
| 29 #include "net/url_request/url_request_job_factory_impl.h" | 32 #include "net/url_request/url_request_job_factory_impl.h" |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 | 375 |
| 373 int64_t original_content_length = fetch_state_.response_content.size(); | 376 int64_t original_content_length = fetch_state_.response_content.size(); |
| 374 int64_t compressed_content_length = | 377 int64_t compressed_content_length = |
| 375 source->GetReceivedResponseContentLength(); | 378 source->GetReceivedResponseContentLength(); |
| 376 RecordSyncResponseContentLengthHistograms(compressed_content_length, | 379 RecordSyncResponseContentLengthHistograms(compressed_content_length, |
| 377 original_content_length); | 380 original_content_length); |
| 378 | 381 |
| 379 // End of the line for url_poster_. It lives only on the IO loop. | 382 // End of the line for url_poster_. It lives only on the IO loop. |
| 380 // We defer deletion because we're inside a callback from a component of the | 383 // We defer deletion because we're inside a callback from a component of the |
| 381 // URLFetcher, so it seems most natural / "polite" to let the stack unwind. | 384 // URLFetcher, so it seems most natural / "polite" to let the stack unwind. |
| 382 base::MessageLoop::current()->DeleteSoon(FROM_HERE, fetch_state_.url_poster); | 385 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, |
| 386 fetch_state_.url_poster); |
| 383 fetch_state_.url_poster = NULL; | 387 fetch_state_.url_poster = NULL; |
| 384 | 388 |
| 385 // Wake the blocked syncer thread in MakeSynchronousPost. | 389 // Wake the blocked syncer thread in MakeSynchronousPost. |
| 386 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! | 390 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! |
| 387 http_post_completed_.Signal(); | 391 http_post_completed_.Signal(); |
| 388 } | 392 } |
| 389 | 393 |
| 390 void HttpBridge::OnURLFetchDownloadProgress(const net::URLFetcher* source, | 394 void HttpBridge::OnURLFetchDownloadProgress(const net::URLFetcher* source, |
| 391 int64_t current, | 395 int64_t current, |
| 392 int64_t total) { | 396 int64_t total) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 int64_t sane_time_ms = 0; | 459 int64_t sane_time_ms = 0; |
| 456 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { | 460 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { |
| 457 network_time_update_callback_.Run( | 461 network_time_update_callback_.Run( |
| 458 base::Time::FromJsTime(sane_time_ms), | 462 base::Time::FromJsTime(sane_time_ms), |
| 459 base::TimeDelta::FromMilliseconds(1), | 463 base::TimeDelta::FromMilliseconds(1), |
| 460 fetch_state_.end_time - fetch_state_.start_time); | 464 fetch_state_.end_time - fetch_state_.start_time); |
| 461 } | 465 } |
| 462 } | 466 } |
| 463 | 467 |
| 464 } // namespace syncer | 468 } // namespace syncer |
| OLD | NEW |