| 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/profiler/scoped_profile.h" |
| 8 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 9 #include "net/base/load_flags.h" | 10 #include "net/base/load_flags.h" |
| 10 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 11 #include "net/cookies/cookie_monster.h" | 12 #include "net/cookies/cookie_monster.h" |
| 12 #include "net/http/http_cache.h" | 13 #include "net/http/http_cache.h" |
| 13 #include "net/http/http_network_layer.h" | 14 #include "net/http/http_network_layer.h" |
| 14 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
| 15 #include "net/url_request/static_http_user_agent_settings.h" | 16 #include "net/url_request/static_http_user_agent_settings.h" |
| 16 #include "net/url_request/url_fetcher.h" | 17 #include "net/url_request/url_fetcher.h" |
| 17 #include "net/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 fetch_state_.error_code = net::ERR_ABORTED; | 338 fetch_state_.error_code = net::ERR_ABORTED; |
| 338 http_post_completed_.Signal(); | 339 http_post_completed_.Signal(); |
| 339 } | 340 } |
| 340 | 341 |
| 341 void HttpBridge::DestroyURLFetcherOnIOThread(net::URLFetcher* fetcher) { | 342 void HttpBridge::DestroyURLFetcherOnIOThread(net::URLFetcher* fetcher) { |
| 342 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 343 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 343 delete fetcher; | 344 delete fetcher; |
| 344 } | 345 } |
| 345 | 346 |
| 346 void HttpBridge::OnURLFetchComplete(const net::URLFetcher* source) { | 347 void HttpBridge::OnURLFetchComplete(const net::URLFetcher* source) { |
| 348 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422577 is fixed. |
| 349 tracked_objects::ScopedProfile tracking_profile( |
| 350 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 351 "422577 HttpBridge::OnURLFetchComplete")); |
| 352 |
| 347 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 353 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 348 base::AutoLock lock(fetch_state_lock_); | 354 base::AutoLock lock(fetch_state_lock_); |
| 349 if (fetch_state_.aborted) | 355 if (fetch_state_.aborted) |
| 350 return; | 356 return; |
| 351 | 357 |
| 352 fetch_state_.end_time = base::Time::Now(); | 358 fetch_state_.end_time = base::Time::Now(); |
| 353 fetch_state_.request_completed = true; | 359 fetch_state_.request_completed = true; |
| 354 fetch_state_.request_succeeded = | 360 fetch_state_.request_succeeded = |
| 355 (net::URLRequestStatus::SUCCESS == source->GetStatus().status()); | 361 (net::URLRequestStatus::SUCCESS == source->GetStatus().status()); |
| 356 fetch_state_.http_response_code = source->GetResponseCode(); | 362 fetch_state_.http_response_code = source->GetResponseCode(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 int64 sane_time_ms = 0; | 401 int64 sane_time_ms = 0; |
| 396 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { | 402 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { |
| 397 network_time_update_callback_.Run( | 403 network_time_update_callback_.Run( |
| 398 base::Time::FromJsTime(sane_time_ms), | 404 base::Time::FromJsTime(sane_time_ms), |
| 399 base::TimeDelta::FromMilliseconds(1), | 405 base::TimeDelta::FromMilliseconds(1), |
| 400 fetch_state_.end_time - fetch_state_.start_time); | 406 fetch_state_.end_time - fetch_state_.start_time); |
| 401 } | 407 } |
| 402 } | 408 } |
| 403 | 409 |
| 404 } // namespace syncer | 410 } // namespace syncer |
| OLD | NEW |