OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // This file contains an implementation of the ResourceLoaderBridge class. | 5 // This file contains an implementation of the ResourceLoaderBridge class. |
6 // The class is implemented using net::URLRequest, meaning it is a "simple" | 6 // The class is implemented using net::URLRequest, meaning it is a "simple" |
7 // version that directly issues requests. The more complicated one used in the | 7 // version that directly issues requests. The more complicated one used in the |
8 // browser uses IPC. | 8 // browser uses IPC. |
9 // | 9 // |
10 // Because net::URLRequest only provides an asynchronous resource loading API, | 10 // Because net::URLRequest only provides an asynchronous resource loading API, |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 // Called on the IO thread. | 527 // Called on the IO thread. |
528 void MaybeUpdateUploadProgress() { | 528 void MaybeUpdateUploadProgress() { |
529 // If a redirect is received upload is cancelled in net::URLRequest, we | 529 // If a redirect is received upload is cancelled in net::URLRequest, we |
530 // should try to stop the |upload_progress_timer_| timer and return. | 530 // should try to stop the |upload_progress_timer_| timer and return. |
531 if (!request_->has_upload()) { | 531 if (!request_->has_upload()) { |
532 if (upload_progress_timer_.IsRunning()) | 532 if (upload_progress_timer_.IsRunning()) |
533 upload_progress_timer_.Stop(); | 533 upload_progress_timer_.Stop(); |
534 return; | 534 return; |
535 } | 535 } |
536 | 536 |
537 uint64 size = request_->get_upload()->GetContentLength(); | 537 // GetContentLengthSync() may perform file IO, but it's ok here, as file |
| 538 // IO is not prohibited in IOThread defined in the file. |
| 539 uint64 size = request_->get_upload()->GetContentLengthSync(); |
538 uint64 position = request_->GetUploadProgress(); | 540 uint64 position = request_->GetUploadProgress(); |
539 if (position == last_upload_position_) | 541 if (position == last_upload_position_) |
540 return; // no progress made since last time | 542 return; // no progress made since last time |
541 | 543 |
542 const uint64 kHalfPercentIncrements = 200; | 544 const uint64 kHalfPercentIncrements = 200; |
543 const base::TimeDelta kOneSecond = base::TimeDelta::FromMilliseconds(1000); | 545 const base::TimeDelta kOneSecond = base::TimeDelta::FromMilliseconds(1000); |
544 | 546 |
545 uint64 amt_since_last = position - last_upload_position_; | 547 uint64 amt_since_last = position - last_upload_position_; |
546 base::TimeDelta time_since_last = base::TimeTicks::Now() - | 548 base::TimeDelta time_since_last = base::TimeTicks::Now() - |
547 last_upload_ticks_; | 549 last_upload_ticks_; |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); | 1035 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); |
1034 g_file_over_http_params = new FileOverHTTPParams(file_path_template, | 1036 g_file_over_http_params = new FileOverHTTPParams(file_path_template, |
1035 http_prefix); | 1037 http_prefix); |
1036 } | 1038 } |
1037 | 1039 |
1038 // static | 1040 // static |
1039 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create( | 1041 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create( |
1040 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { | 1042 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { |
1041 return new ResourceLoaderBridgeImpl(request_info); | 1043 return new ResourceLoaderBridgeImpl(request_info); |
1042 } | 1044 } |
OLD | NEW |