Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: webkit/tools/test_shell/simple_resource_loader_bridge.cc

Issue 10640019: Remove the HANDLED_EXTERNALLY status code. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix more nits Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 return; 390 return;
391 391
392 // Continue reading more data, see the comment in NotifyReceivedData. 392 // Continue reading more data, see the comment in NotifyReceivedData.
393 g_io_thread->message_loop()->PostTask( 393 g_io_thread->message_loop()->PostTask(
394 FROM_HERE, 394 FROM_HERE,
395 base::Bind(&RequestProxy::AsyncReadData, this)); 395 base::Bind(&RequestProxy::AsyncReadData, this));
396 396
397 peer_->OnDownloadedData(bytes_read); 397 peer_->OnDownloadedData(bytes_read);
398 } 398 }
399 399
400 void NotifyCompletedRequest(const net::URLRequestStatus& status, 400 void NotifyCompletedRequest(int error_code,
401 const std::string& security_info, 401 const std::string& security_info,
402 const base::TimeTicks& complete_time) { 402 const base::TimeTicks& complete_time) {
403 if (peer_) { 403 if (peer_) {
404 peer_->OnCompletedRequest(status, security_info, complete_time); 404 peer_->OnCompletedRequest(error_code, false, security_info,
405 complete_time);
405 DropPeer(); // ensure no further notifications 406 DropPeer(); // ensure no further notifications
406 } 407 }
407 } 408 }
408 409
409 void NotifyUploadProgress(uint64 position, uint64 size) { 410 void NotifyUploadProgress(uint64 position, uint64 size) {
410 if (peer_) 411 if (peer_)
411 peer_->OnUploadProgress(position, size); 412 peer_->OnUploadProgress(position, size);
412 } 413 }
413 414
414 // -------------------------------------------------------------------------- 415 // --------------------------------------------------------------------------
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 FROM_HERE, 526 FROM_HERE,
526 base::Bind(&RequestProxy::NotifyDownloadedData, this, bytes_read)); 527 base::Bind(&RequestProxy::NotifyDownloadedData, this, bytes_read));
527 return; 528 return;
528 } 529 }
529 530
530 owner_loop_->PostTask( 531 owner_loop_->PostTask(
531 FROM_HERE, 532 FROM_HERE,
532 base::Bind(&RequestProxy::NotifyReceivedData, this, bytes_read)); 533 base::Bind(&RequestProxy::NotifyReceivedData, this, bytes_read));
533 } 534 }
534 535
535 virtual void OnCompletedRequest(const net::URLRequestStatus& status, 536 virtual void OnCompletedRequest(int error_code,
536 const std::string& security_info, 537 const std::string& security_info,
537 const base::TimeTicks& complete_time) { 538 const base::TimeTicks& complete_time) {
538 if (download_to_file_) 539 if (download_to_file_)
539 file_stream_.CloseSync(); 540 file_stream_.CloseSync();
540 owner_loop_->PostTask( 541 owner_loop_->PostTask(
541 FROM_HERE, 542 FROM_HERE,
542 base::Bind(&RequestProxy::NotifyCompletedRequest, this, status, 543 base::Bind(&RequestProxy::NotifyCompletedRequest, this, error_code,
543 security_info, complete_time)); 544 security_info, complete_time));
544 } 545 }
545 546
546 // -------------------------------------------------------------------------- 547 // --------------------------------------------------------------------------
547 // net::URLRequest::Delegate implementation: 548 // net::URLRequest::Delegate implementation:
548 549
549 virtual void OnReceivedRedirect(net::URLRequest* request, 550 virtual void OnReceivedRedirect(net::URLRequest* request,
550 const GURL& new_url, 551 const GURL& new_url,
551 bool* defer_redirect) OVERRIDE { 552 bool* defer_redirect) OVERRIDE {
552 DCHECK(request->status().is_success()); 553 DCHECK(request->status().is_success());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 void Done() { 597 void Done() {
597 if (upload_progress_timer_.IsRunning()) { 598 if (upload_progress_timer_.IsRunning()) {
598 MaybeUpdateUploadProgress(); 599 MaybeUpdateUploadProgress();
599 upload_progress_timer_.Stop(); 600 upload_progress_timer_.Stop();
600 } 601 }
601 DCHECK(request_.get()); 602 DCHECK(request_.get());
602 // If |failed_file_request_status_| is not empty, which means the request 603 // If |failed_file_request_status_| is not empty, which means the request
603 // was a file request and encountered an error, then we need to use the 604 // was a file request and encountered an error, then we need to use the
604 // |failed_file_request_status_|. Otherwise use request_'s status. 605 // |failed_file_request_status_|. Otherwise use request_'s status.
605 OnCompletedRequest(failed_file_request_status_.get() ? 606 OnCompletedRequest(failed_file_request_status_.get() ?
606 *failed_file_request_status_ : request_->status(), 607 failed_file_request_status_->error() :
608 request_->status().error(),
607 std::string(), base::TimeTicks()); 609 std::string(), base::TimeTicks());
608 request_.reset(); // destroy on the io thread 610 request_.reset(); // destroy on the io thread
609 } 611 }
610 612
611 // Called on the IO thread. 613 // Called on the IO thread.
612 void MaybeUpdateUploadProgress() { 614 void MaybeUpdateUploadProgress() {
613 // If a redirect is received upload is cancelled in net::URLRequest, we 615 // If a redirect is received upload is cancelled in net::URLRequest, we
614 // should try to stop the |upload_progress_timer_| timer and return. 616 // should try to stop the |upload_progress_timer_| timer and return.
615 if (!request_->has_upload()) { 617 if (!request_->has_upload()) {
616 if (upload_progress_timer_.IsRunning()) 618 if (upload_progress_timer_.IsRunning())
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 821
820 virtual void OnReceivedData(int bytes_read) OVERRIDE { 822 virtual void OnReceivedData(int bytes_read) OVERRIDE {
821 if (download_to_file_) 823 if (download_to_file_)
822 file_stream_.WriteSync(buf_->data(), bytes_read); 824 file_stream_.WriteSync(buf_->data(), bytes_read);
823 else 825 else
824 result_->data.append(buf_->data(), bytes_read); 826 result_->data.append(buf_->data(), bytes_read);
825 AsyncReadData(); // read more (may recurse) 827 AsyncReadData(); // read more (may recurse)
826 } 828 }
827 829
828 virtual void OnCompletedRequest( 830 virtual void OnCompletedRequest(
829 const net::URLRequestStatus& status, 831 int error_code,
830 const std::string& security_info, 832 const std::string& security_info,
831 const base::TimeTicks& complete_time) OVERRIDE { 833 const base::TimeTicks& complete_time) OVERRIDE {
832 if (download_to_file_) 834 if (download_to_file_)
833 file_stream_.CloseSync(); 835 file_stream_.CloseSync();
834 result_->status = status; 836 result_->error_code = error_code;
835 event_.Signal(); 837 event_.Signal();
836 } 838 }
837 839
838 protected: 840 protected:
839 virtual ~SyncRequestProxy() {} 841 virtual ~SyncRequestProxy() {}
840 842
841 private: 843 private:
842 ResourceLoaderBridge::SyncLoadResponse* result_; 844 ResourceLoaderBridge::SyncLoadResponse* result_;
843 base::WaitableEvent event_; 845 base::WaitableEvent event_;
844 }; 846 };
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); 1109 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https")));
1108 g_file_over_http_params = new FileOverHTTPParams(file_path_template, 1110 g_file_over_http_params = new FileOverHTTPParams(file_path_template,
1109 http_prefix); 1111 http_prefix);
1110 } 1112 }
1111 1113
1112 // static 1114 // static
1113 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create( 1115 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create(
1114 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { 1116 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) {
1115 return new ResourceLoaderBridgeImpl(request_info); 1117 return new ResourceLoaderBridgeImpl(request_info);
1116 } 1118 }
OLDNEW
« content/browser/renderer_host/async_resource_handler.cc ('K') | « webkit/glue/weburlloader_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698