| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 URLRequest, meaning it is a "simple" version | 6 // The class is implemented using URLRequest, meaning it is a "simple" version |
| 7 // that directly issues requests. The more complicated one used in the | 7 // that directly issues requests. The more complicated one used in the |
| 8 // browser uses IPC. | 8 // browser uses IPC. |
| 9 // | 9 // |
| 10 // Because URLRequest only provides an asynchronous resource loading API, this | 10 // Because URLRequest only provides an asynchronous resource loading API, this |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 MaybeUpdateUploadProgress(); | 313 MaybeUpdateUploadProgress(); |
| 314 upload_progress_timer_.Stop(); | 314 upload_progress_timer_.Stop(); |
| 315 } | 315 } |
| 316 DCHECK(request_.get()); | 316 DCHECK(request_.get()); |
| 317 OnCompletedRequest(request_->status(), std::string()); | 317 OnCompletedRequest(request_->status(), std::string()); |
| 318 request_.reset(); // destroy on the io thread | 318 request_.reset(); // destroy on the io thread |
| 319 } | 319 } |
| 320 | 320 |
| 321 // Called on the IO thread. | 321 // Called on the IO thread. |
| 322 void MaybeUpdateUploadProgress() { | 322 void MaybeUpdateUploadProgress() { |
| 323 // If a redirect is received upload is cancelled in URLRequest, we should |
| 324 // try to stop the |upload_progress_timer_| timer and return. |
| 325 if (!request_->has_upload()) { |
| 326 if (upload_progress_timer_.IsRunning()) |
| 327 upload_progress_timer_.Stop(); |
| 328 return; |
| 329 } |
| 330 |
| 323 uint64 size = request_->get_upload()->GetContentLength(); | 331 uint64 size = request_->get_upload()->GetContentLength(); |
| 324 uint64 position = request_->GetUploadProgress(); | 332 uint64 position = request_->GetUploadProgress(); |
| 325 if (position == last_upload_position_) | 333 if (position == last_upload_position_) |
| 326 return; // no progress made since last time | 334 return; // no progress made since last time |
| 327 | 335 |
| 328 const uint64 kHalfPercentIncrements = 200; | 336 const uint64 kHalfPercentIncrements = 200; |
| 329 const base::TimeDelta kOneSecond = base::TimeDelta::FromMilliseconds(1000); | 337 const base::TimeDelta kOneSecond = base::TimeDelta::FromMilliseconds(1000); |
| 330 | 338 |
| 331 uint64 amt_since_last = position - last_upload_position_; | 339 uint64 amt_since_last = position - last_upload_position_; |
| 332 base::TimeDelta time_since_last = base::TimeTicks::Now() - | 340 base::TimeDelta time_since_last = base::TimeTicks::Now() - |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 return std::string(); | 636 return std::string(); |
| 629 } | 637 } |
| 630 | 638 |
| 631 scoped_refptr<CookieGetter> getter = new CookieGetter(); | 639 scoped_refptr<CookieGetter> getter = new CookieGetter(); |
| 632 | 640 |
| 633 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 641 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 634 getter.get(), &CookieGetter::Get, url)); | 642 getter.get(), &CookieGetter::Get, url)); |
| 635 | 643 |
| 636 return getter->GetResult(); | 644 return getter->GetResult(); |
| 637 } | 645 } |
| OLD | NEW |