diff options
40 files changed, 208 insertions, 168 deletions
diff --git a/chrome/browser/extensions/user_script_listener_unittest.cc b/chrome/browser/extensions/user_script_listener_unittest.cc index 42d2011..d3a4141 100644 --- a/chrome/browser/extensions/user_script_listener_unittest.cc +++ b/chrome/browser/extensions/user_script_listener_unittest.cc @@ -48,6 +48,9 @@ class ThrottleController : public base::SupportsUserData::Data, virtual void Cancel() { NOTREACHED(); } + virtual void CancelAndIgnore() { + NOTREACHED(); + } private: net::URLRequest* request_; diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc index 94722f2..1dd4374 100644 --- a/chrome/browser/net/chrome_network_delegate.cc +++ b/chrome/browser/net/chrome_network_delegate.cc @@ -263,8 +263,7 @@ void ChromeNetworkDelegate::OnRawBytesRead(const net::URLRequest& request, void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) { - if (request->status().status() == net::URLRequestStatus::SUCCESS || - request->status().status() == net::URLRequestStatus::HANDLED_EXTERNALLY) { + if (request->status().status() == net::URLRequestStatus::SUCCESS) { bool is_redirect = request->response_headers() && net::HttpResponseHeaders::IsRedirectResponseCode( request->response_headers()->response_code()); diff --git a/chrome/browser/renderer_host/intercept_navigation_resource_throttle.cc b/chrome/browser/renderer_host/intercept_navigation_resource_throttle.cc index 3c36d11..3852627 100644 --- a/chrome/browser/renderer_host/intercept_navigation_resource_throttle.cc +++ b/chrome/browser/renderer_host/intercept_navigation_resource_throttle.cc @@ -10,8 +10,6 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/resource_request_info.h" #include "content/public/browser/resource_controller.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_delegate.h" #include "content/public/common/referrer.h" #include "net/url_request/url_request.h" @@ -20,8 +18,6 @@ using content::ChildProcessSecurityPolicy; using content::Referrer; using content::RenderViewHost; using content::ResourceRequestInfo; -using content::WebContents; -using content::WebContentsDelegate; namespace { @@ -116,9 +112,7 @@ void InterceptNavigationResourceThrottle::OnResultObtained( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (should_ignore_navigation) { - // TODO(mkosiba): Cancel() results in a CANCELLED status but what we really - // want is a HANDLED_EXTERNALLY status. - controller()->Cancel(); + controller()->CancelAndIgnore(); } else { controller()->Resume(); } diff --git a/chrome/browser/renderer_host/intercept_navigation_resource_throttle_unittest.cc b/chrome/browser/renderer_host/intercept_navigation_resource_throttle_unittest.cc index d8de977..c2e7693 100644 --- a/chrome/browser/renderer_host/intercept_navigation_resource_throttle_unittest.cc +++ b/chrome/browser/renderer_host/intercept_navigation_resource_throttle_unittest.cc @@ -68,7 +68,9 @@ class MockResourceController // content::ResourceController virtual void Cancel() { - DCHECK(status_ == UNKNOWN); + NOTREACHED(); + } + virtual void CancelAndIgnore() { status_ = CANCELLED; ContinueTestCase(); } diff --git a/chrome/common/extensions/extension_localization_peer.cc b/chrome/common/extensions/extension_localization_peer.cc index 3026ea3..980d2a4 100644 --- a/chrome/common/extensions/extension_localization_peer.cc +++ b/chrome/common/extensions/extension_localization_peer.cc @@ -66,19 +66,19 @@ void ExtensionLocalizationPeer::OnReceivedData(const char* data, } void ExtensionLocalizationPeer::OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time) { // Make sure we delete ourselves at the end of this call. scoped_ptr<ExtensionLocalizationPeer> this_deleter(this); // Give sub-classes a chance at altering the data. - if (status.status() != net::URLRequestStatus::SUCCESS) { + if (error_code != net::OK) { // We failed to load the resource. original_peer_->OnReceivedResponse(response_info_); - net::URLRequestStatus status(net::URLRequestStatus::CANCELED, - net::ERR_ABORTED); - original_peer_->OnCompletedRequest(status, security_info, completion_time); + original_peer_->OnCompletedRequest(net::ERR_ABORTED, false, security_info, + completion_time); return; } @@ -89,7 +89,8 @@ void ExtensionLocalizationPeer::OnCompletedRequest( original_peer_->OnReceivedData(data_.data(), static_cast<int>(data_.size()), -1); - original_peer_->OnCompletedRequest(status, security_info, completion_time); + original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler, + security_info, completion_time); } void ExtensionLocalizationPeer::ReplaceMessages() { diff --git a/chrome/common/extensions/extension_localization_peer.h b/chrome/common/extensions/extension_localization_peer.h index e49035b..fd69f41 100644 --- a/chrome/common/extensions/extension_localization_peer.h +++ b/chrome/common/extensions/extension_localization_peer.h @@ -42,7 +42,8 @@ class ExtensionLocalizationPeer int data_length, int encoded_data_length) OVERRIDE; virtual void OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time) OVERRIDE; diff --git a/chrome/common/extensions/extension_localization_peer_unittest.cc b/chrome/common/extensions/extension_localization_peer_unittest.cc index d03ba2a6..c0ca38f 100644 --- a/chrome/common/extensions/extension_localization_peer_unittest.cc +++ b/chrome/common/extensions/extension_localization_peer_unittest.cc @@ -69,8 +69,9 @@ class MockResourceLoaderBridgePeer MOCK_METHOD3(OnReceivedData, void(const char* data, int data_length, int encoded_data_length)); - MOCK_METHOD3(OnCompletedRequest, void( - const net::URLRequestStatus& status, + MOCK_METHOD4(OnCompletedRequest, void( + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time)); @@ -142,11 +143,10 @@ TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestBadURLRequestStatus) { EXPECT_CALL(*original_peer_, OnReceivedResponse(_)); EXPECT_CALL(*original_peer_, OnCompletedRequest( - IsURLRequestEqual(net::URLRequestStatus::CANCELED), "", base::TimeTicks())); + net::ERR_ABORTED, false, "", base::TimeTicks())); - net::URLRequestStatus status; - status.set_status(net::URLRequestStatus::FAILED); - filter_peer->OnCompletedRequest(status, "", base::TimeTicks()); + filter_peer->OnCompletedRequest(net::ERR_FAILED, false, "", + base::TimeTicks()); } TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestEmptyData) { @@ -158,12 +158,9 @@ TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestEmptyData) { EXPECT_CALL(*original_peer_, OnReceivedResponse(_)); EXPECT_CALL(*original_peer_, OnCompletedRequest( - IsURLRequestEqual(net::URLRequestStatus::SUCCESS), "", - base::TimeTicks())); + net::OK, false, "", base::TimeTicks())); - net::URLRequestStatus status; - status.set_status(net::URLRequestStatus::SUCCESS); - filter_peer->OnCompletedRequest(status, "", base::TimeTicks()); + filter_peer->OnCompletedRequest(net::OK, false, "", base::TimeTicks()); } TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestNoCatalogs) { @@ -180,19 +177,16 @@ TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestNoCatalogs) { EXPECT_CALL(*original_peer_, OnReceivedResponse(_)).Times(2); EXPECT_CALL(*original_peer_, OnCompletedRequest( - IsURLRequestEqual( - net::URLRequestStatus::SUCCESS), "", base::TimeTicks())).Times(2); + net::OK, false, "", base::TimeTicks())).Times(2); - net::URLRequestStatus status; - status.set_status(net::URLRequestStatus::SUCCESS); - filter_peer->OnCompletedRequest(status, "", base::TimeTicks()); + filter_peer->OnCompletedRequest(net::OK, false, "", base::TimeTicks()); // Test if Send gets called again (it shouldn't be) when first call returned // an empty dictionary. filter_peer = CreateExtensionLocalizationPeer("text/css", GURL(kExtensionUrl_1)); SetData(filter_peer, "some text"); - filter_peer->OnCompletedRequest(status, "", base::TimeTicks()); + filter_peer->OnCompletedRequest(net::OK, false, "", base::TimeTicks()); } TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestWithCatalogs) { @@ -218,12 +212,9 @@ TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestWithCatalogs) { EXPECT_CALL(*original_peer_, OnReceivedResponse(_)); EXPECT_CALL(*original_peer_, OnCompletedRequest( - IsURLRequestEqual(net::URLRequestStatus::SUCCESS), "", - base::TimeTicks())); + net::OK, false, "", base::TimeTicks())); - net::URLRequestStatus status; - status.set_status(net::URLRequestStatus::SUCCESS); - filter_peer->OnCompletedRequest(status, "", base::TimeTicks()); + filter_peer->OnCompletedRequest(net::OK, false, "", base::TimeTicks()); } TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestReplaceMessagesFails) { @@ -249,10 +240,7 @@ TEST_F(ExtensionLocalizationPeerTest, OnCompletedRequestReplaceMessagesFails) { EXPECT_CALL(*original_peer_, OnReceivedResponse(_)); EXPECT_CALL(*original_peer_, OnCompletedRequest( - IsURLRequestEqual(net::URLRequestStatus::SUCCESS), "", - base::TimeTicks())); + net::OK, false, "", base::TimeTicks())); - net::URLRequestStatus status; - status.set_status(net::URLRequestStatus::SUCCESS); - filter_peer->OnCompletedRequest(status, "", base::TimeTicks()); + filter_peer->OnCompletedRequest(net::OK, false, "", base::TimeTicks()); } diff --git a/chrome/renderer/chrome_render_process_observer.cc b/chrome/renderer/chrome_render_process_observer.cc index 70e7bed..128ecd5 100644 --- a/chrome/renderer/chrome_render_process_observer.cc +++ b/chrome/renderer/chrome_render_process_observer.cc @@ -76,7 +76,7 @@ class RendererResourceDelegate : public content::ResourceDispatcherDelegate { virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete( webkit_glue::ResourceLoaderBridge::Peer* current_peer, ResourceType::Type resource_type, - const net::URLRequestStatus& status) { + int error_code) { // Update the browser about our cache. // Rate limit informing the host of our cache stats. if (!weak_factory_.HasWeakPtrs()) { @@ -87,14 +87,13 @@ class RendererResourceDelegate : public content::ResourceDispatcherDelegate { base::TimeDelta::FromMilliseconds(kCacheStatsDelayMS)); } - if (status.status() != net::URLRequestStatus::CANCELED || - status.error() == net::ERR_ABORTED) { + if (error_code == net::ERR_ABORTED) { return NULL; } // Resource canceled with a specific error are filtered. return SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( - resource_type, current_peer, status.error()); + resource_type, current_peer, error_code); } virtual webkit_glue::ResourceLoaderBridge::Peer* OnReceivedResponse( diff --git a/chrome/renderer/security_filter_peer.cc b/chrome/renderer/security_filter_peer.cc index ee05496f..c720156 100644 --- a/chrome/renderer/security_filter_peer.cc +++ b/chrome/renderer/security_filter_peer.cc @@ -90,7 +90,8 @@ void SecurityFilterPeer::OnReceivedData(const char* data, } void SecurityFilterPeer::OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time) { NOTREACHED(); @@ -150,19 +151,19 @@ void BufferedPeer::OnReceivedData(const char* data, data_.append(data, data_length); } -void BufferedPeer::OnCompletedRequest(const net::URLRequestStatus& status, +void BufferedPeer::OnCompletedRequest(int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time) { // Make sure we delete ourselves at the end of this call. scoped_ptr<BufferedPeer> this_deleter(this); // Give sub-classes a chance at altering the data. - if (status.status() != net::URLRequestStatus::SUCCESS || !DataReady()) { + if (error_code != net::OK || !DataReady()) { // Pretend we failed to load the resource. original_peer_->OnReceivedResponse(response_info_); - net::URLRequestStatus status(net::URLRequestStatus::CANCELED, - net::ERR_ABORTED); - original_peer_->OnCompletedRequest(status, security_info, completion_time); + original_peer_->OnCompletedRequest(net::ERR_ABORTED, false, security_info, + completion_time); return; } @@ -171,7 +172,8 @@ void BufferedPeer::OnCompletedRequest(const net::URLRequestStatus& status, original_peer_->OnReceivedData(data_.data(), static_cast<int>(data_.size()), -1); - original_peer_->OnCompletedRequest(status, security_info, completion_time); + original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler, + security_info, completion_time); } //////////////////////////////////////////////////////////////////////////////// @@ -202,7 +204,8 @@ void ReplaceContentPeer::OnReceivedData(const char* data, } void ReplaceContentPeer::OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time) { webkit_glue::ResourceResponseInfo info; @@ -214,7 +217,8 @@ void ReplaceContentPeer::OnCompletedRequest( original_peer_->OnReceivedData(data_.data(), static_cast<int>(data_.size()), -1); - original_peer_->OnCompletedRequest(net::URLRequestStatus(), + original_peer_->OnCompletedRequest(net::OK, + false, security_info, completion_time); diff --git a/chrome/renderer/security_filter_peer.h b/chrome/renderer/security_filter_peer.h index 44b23282..b4dd637 100644 --- a/chrome/renderer/security_filter_peer.h +++ b/chrome/renderer/security_filter_peer.h @@ -41,7 +41,8 @@ class SecurityFilterPeer : public webkit_glue::ResourceLoaderBridge::Peer { int data_length, int encoded_data_length) OVERRIDE; virtual void OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time) OVERRIDE; @@ -72,7 +73,8 @@ class BufferedPeer : public SecurityFilterPeer { int data_length, int encoded_data_length) OVERRIDE; virtual void OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time) OVERRIDE; @@ -115,7 +117,8 @@ class ReplaceContentPeer : public SecurityFilterPeer { int data_length, int encoded_data_length) OVERRIDE; virtual void OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time) OVERRIDE; diff --git a/content/browser/renderer_host/async_resource_handler.cc b/content/browser/renderer_host/async_resource_handler.cc index 85103f5..e77a981 100644 --- a/content/browser/renderer_host/async_resource_handler.cc +++ b/content/browser/renderer_host/async_resource_handler.cc @@ -309,9 +309,31 @@ bool AsyncResourceHandler::OnResponseCompleted( sent_received_response_msg_); TimeTicks completion_time = TimeTicks::Now(); + + int error_code = status.error(); + bool was_ignored_by_handler = + ResourceRequestInfoImpl::ForRequest(request_)->WasIgnoredByHandler(); + + DCHECK(status.status() != net::URLRequestStatus::IO_PENDING); + // If this check fails, then we're in an inconsistent state because all + // requests ignored by the handler should be canceled (which should result in + // the ERR_ABORTED error code). + DCHECK(!was_ignored_by_handler || error_code == net::ERR_ABORTED); + + // TODO(mkosiba): Fix up cases where we create a URLRequestStatus + // with a status() != SUCCESS and an error_code() == net::OK. + if (status.status() == net::URLRequestStatus::CANCELED && + error_code == net::OK) { + error_code = net::ERR_ABORTED; + } else if (status.status() == net::URLRequestStatus::FAILED && + error_code == net::OK) { + error_code = net::ERR_FAILED; + } + filter_->Send(new ResourceMsg_RequestComplete(routing_id_, request_id, - status, + error_code, + was_ignored_by_handler, security_info, completion_time)); diff --git a/content/browser/renderer_host/buffered_resource_handler.cc b/content/browser/renderer_host/buffered_resource_handler.cc index 6f0f2f7..98aae33 100644 --- a/content/browser/renderer_host/buffered_resource_handler.cc +++ b/content/browser/renderer_host/buffered_resource_handler.cc @@ -211,6 +211,10 @@ void BufferedResourceHandler::Cancel() { controller()->Cancel(); } +void BufferedResourceHandler::CancelAndIgnore() { + controller()->CancelAndIgnore(); +} + bool BufferedResourceHandler::ProcessResponse(bool* defer) { DCHECK_EQ(STATE_PROCESSING, state_); @@ -351,7 +355,8 @@ bool BufferedResourceHandler::UseAlternateNextHandler( bool defer_ignored = false; next_handler_->OnResponseStarted(request_id, response_, &defer_ignored); DCHECK(!defer_ignored); - net::URLRequestStatus status(net::URLRequestStatus::HANDLED_EXTERNALLY, 0); + net::URLRequestStatus status(net::URLRequestStatus::CANCELED, + net::ERR_ABORTED); next_handler_->OnResponseCompleted(request_id, status, std::string()); // This is handled entirely within the new ResourceHandler, so just reset the diff --git a/content/browser/renderer_host/buffered_resource_handler.h b/content/browser/renderer_host/buffered_resource_handler.h index 7493999..de927fc 100644 --- a/content/browser/renderer_host/buffered_resource_handler.h +++ b/content/browser/renderer_host/buffered_resource_handler.h @@ -52,6 +52,7 @@ class BufferedResourceHandler // ResourceController implementation: virtual void Resume() OVERRIDE; virtual void Cancel() OVERRIDE; + virtual void CancelAndIgnore() OVERRIDE; bool ProcessResponse(bool* defer); diff --git a/content/browser/renderer_host/redirect_to_file_resource_handler.cc b/content/browser/renderer_host/redirect_to_file_resource_handler.cc index d7f0ea3..a527ac2 100644 --- a/content/browser/renderer_host/redirect_to_file_resource_handler.cc +++ b/content/browser/renderer_host/redirect_to_file_resource_handler.cc @@ -61,7 +61,8 @@ bool RedirectToFileResourceHandler::OnResponseStarted( int request_id, ResourceResponse* response, bool* defer) { - if (response->head.status.is_success()) { + if (response->head.error_code == net::OK || + response->head.error_code == net::ERR_IO_PENDING) { DCHECK(deletable_file_ && !deletable_file_->path().empty()); response->head.download_file_path = deletable_file_->path(); } diff --git a/content/browser/renderer_host/resource_dispatcher_host_impl.cc b/content/browser/renderer_host/resource_dispatcher_host_impl.cc index 8554466..dd6bf7d 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_impl.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_impl.cc @@ -127,11 +127,9 @@ void AbortRequestBeforeItStarts(ResourceMessageFilter* filter, IPC::Message* sync_result, int route_id, int request_id) { - net::URLRequestStatus status(net::URLRequestStatus::FAILED, - net::ERR_ABORTED); if (sync_result) { SyncLoadResult result; - result.status = status; + result.error_code = net::ERR_ABORTED; ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result, result); filter->Send(sync_result); } else { @@ -139,7 +137,8 @@ void AbortRequestBeforeItStarts(ResourceMessageFilter* filter, filter->Send(new ResourceMsg_RequestComplete( route_id, request_id, - status, + net::ERR_ABORTED, + false, std::string(), // No security info needed, connection not established. base::TimeTicks())); } diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc index 6d96949..c01c45c 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -788,13 +788,13 @@ TEST_F(ResourceDispatcherHostTest, Cancel) { ASSERT_EQ(ResourceMsg_RequestComplete::ID, msgs[1][1].type()); int request_id; - net::URLRequestStatus status; + int error_code; PickleIterator iter(msgs[1][1]); ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &request_id)); - ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &status)); + ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &error_code)); - EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status()); + EXPECT_EQ(net::ERR_ABORTED, error_code); } TEST_F(ResourceDispatcherHostTest, CancelWhileStartIsDeferred) { @@ -1217,18 +1217,17 @@ TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) { EXPECT_EQ(1U, msgs[index].size()); EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[index][0].type()); - // The RequestComplete message should have had status - // (CANCELLED, ERR_INSUFFICIENT_RESOURCES). + // The RequestComplete message should have the error code of + // ERR_INSUFFICIENT_RESOURCES. int request_id; - net::URLRequestStatus status; + int error_code; PickleIterator iter(msgs[index][0]); EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &request_id)); - EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &status)); + EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &error_code)); EXPECT_EQ(index + 1, request_id); - EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status()); - EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, status.error()); + EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, error_code); } // The final 2 requests should have succeeded. @@ -1391,18 +1390,17 @@ TEST_F(ResourceDispatcherHostTest, ForbiddenDownload) { ASSERT_EQ(1U, msgs[0].size()); EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type()); - // The RequestComplete message should have had status - // (CANCELED, ERR_FILE_NOT_FOUND). + // The RequestComplete message should have had the error code of + // ERR_FILE_NOT_FOUND. int request_id; - net::URLRequestStatus status; + int error_code; PickleIterator iter(msgs[0][0]); EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); - EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); + EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &error_code)); EXPECT_EQ(1, request_id); - EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status()); - EXPECT_EQ(net::ERR_FILE_NOT_FOUND, status.error()); + EXPECT_EQ(net::ERR_FILE_NOT_FOUND, error_code); } // Test for http://crbug.com/76202 . We don't want to destroy a @@ -1693,18 +1691,17 @@ TEST_F(ResourceDispatcherHostTest, UnknownURLScheme) { ASSERT_EQ(1U, msgs[0].size()); EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type()); - // The RequestComplete message should have had status - // (FAILED, ERR_UNKNOWN_URL_SCHEME). + // The RequestComplete message should have the error code of + // ERR_UNKNOWN_URL_SCHEME. int request_id; - net::URLRequestStatus status; + int error_code; PickleIterator iter(msgs[0][0]); EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); - EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); + EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &error_code)); EXPECT_EQ(1, request_id); - EXPECT_EQ(net::URLRequestStatus::FAILED, status.status()); - EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error()); + EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, error_code); } TEST_F(ResourceDispatcherHostTest, DataReceivedACKs) { diff --git a/content/browser/renderer_host/resource_loader.cc b/content/browser/renderer_host/resource_loader.cc index 0cbc455..0515a3c 100644 --- a/content/browser/renderer_host/resource_loader.cc +++ b/content/browser/renderer_host/resource_loader.cc @@ -28,7 +28,7 @@ namespace { void PopulateResourceResponse(net::URLRequest* request, ResourceResponse* response) { - response->head.status = request->status(); + response->head.error_code = request->status().error(); response->head.request_time = request->request_time(); response->head.response_time = request->response_time(); response->head.headers = request->response_headers(); @@ -78,7 +78,7 @@ ResourceLoader::~ResourceLoader() { void ResourceLoader::StartRequest() { if (delegate_->HandleExternalProtocol(this, request_->url())) { - CancelRequestInternal(net::ERR_UNKNOWN_URL_SCHEME, false); + CancelAndIgnore(); return; } @@ -101,6 +101,12 @@ void ResourceLoader::CancelRequest(bool from_renderer) { CancelRequestInternal(net::ERR_ABORTED, from_renderer); } +void ResourceLoader::CancelAndIgnore() { + ResourceRequestInfoImpl* info = GetRequestInfo(); + info->set_was_ignored_by_handler(true); + CancelRequest(false); +} + void ResourceLoader::ReportUploadProgress() { ResourceRequestInfoImpl* info = GetRequestInfo(); @@ -205,7 +211,7 @@ void ResourceLoader::OnReceivedRedirect(net::URLRequest* unused, if (delegate_->HandleExternalProtocol(this, new_url)) { // The request is complete so we can remove it. - CancelRequestInternal(net::ERR_UNKNOWN_URL_SCHEME, false); + CancelAndIgnore(); return; } diff --git a/content/browser/renderer_host/resource_loader.h b/content/browser/renderer_host/resource_loader.h index db6c78a..43e05a1 100644 --- a/content/browser/renderer_host/resource_loader.h +++ b/content/browser/renderer_host/resource_loader.h @@ -75,6 +75,7 @@ class ResourceLoader : public net::URLRequest::Delegate, // ResourceController implementation: virtual void Resume() OVERRIDE; virtual void Cancel() OVERRIDE; + virtual void CancelAndIgnore() OVERRIDE; void StartRequestInternal(); void CancelRequestInternal(int error, bool from_renderer); diff --git a/content/browser/renderer_host/resource_request_info_impl.cc b/content/browser/renderer_host/resource_request_info_impl.cc index c1f2437..7725353 100644 --- a/content/browser/renderer_host/resource_request_info_impl.cc +++ b/content/browser/renderer_host/resource_request_info_impl.cc @@ -109,6 +109,7 @@ ResourceRequestInfoImpl::ResourceRequestInfoImpl( is_download_(is_download), allow_download_(allow_download), has_user_gesture_(has_user_gesture), + was_ignored_by_handler_(false), resource_type_(resource_type), transition_type_(transition_type), memory_cost_(0), @@ -167,6 +168,10 @@ bool ResourceRequestInfoImpl::HasUserGesture() const { return has_user_gesture_; } +bool ResourceRequestInfoImpl::WasIgnoredByHandler() const { + return was_ignored_by_handler_; +} + bool ResourceRequestInfoImpl::GetAssociatedRenderView( int* render_process_id, int* render_view_id) const { diff --git a/content/browser/renderer_host/resource_request_info_impl.h b/content/browser/renderer_host/resource_request_info_impl.h index f2bc718..2040300 100644 --- a/content/browser/renderer_host/resource_request_info_impl.h +++ b/content/browser/renderer_host/resource_request_info_impl.h @@ -74,9 +74,11 @@ class ResourceRequestInfoImpl : public ResourceRequestInfo, virtual ResourceType::Type GetResourceType() const OVERRIDE; virtual WebKit::WebReferrerPolicy GetReferrerPolicy() const OVERRIDE; virtual bool HasUserGesture() const OVERRIDE; + virtual bool WasIgnoredByHandler() const OVERRIDE; virtual bool GetAssociatedRenderView(int* render_process_id, int* render_view_id) const OVERRIDE; + void AssociateWithRequest(net::URLRequest* request); GlobalRequestID GetGlobalRequestID() const; @@ -111,6 +113,10 @@ class ResourceRequestInfoImpl : public ResourceRequestInfo, PageTransition transition_type() const { return transition_type_; } + void set_was_ignored_by_handler(bool value) { + was_ignored_by_handler_ = value; + } + // The approximate in-memory size (bytes) that we credited this request // as consuming in |outstanding_requests_memory_cost_map_|. int memory_cost() const { return memory_cost_; } @@ -140,6 +146,7 @@ class ResourceRequestInfoImpl : public ResourceRequestInfo, bool is_download_; bool allow_download_; bool has_user_gesture_; + bool was_ignored_by_handler_; ResourceType::Type resource_type_; PageTransition transition_type_; int memory_cost_; diff --git a/content/browser/renderer_host/sync_resource_handler.cc b/content/browser/renderer_host/sync_resource_handler.cc index 5f50d74..c25c13d 100644 --- a/content/browser/renderer_host/sync_resource_handler.cc +++ b/content/browser/renderer_host/sync_resource_handler.cc @@ -116,7 +116,7 @@ bool SyncResourceHandler::OnResponseCompleted( int request_id, const net::URLRequestStatus& status, const std::string& security_info) { - result_.status = status; + result_.error_code = status.error(); result_.encoded_data_length = DevToolsNetLogObserver::GetAndResetEncodedDataLength(request_); diff --git a/content/browser/renderer_host/throttling_resource_handler.cc b/content/browser/renderer_host/throttling_resource_handler.cc index b833b7f..a6b9c88 100644 --- a/content/browser/renderer_host/throttling_resource_handler.cc +++ b/content/browser/renderer_host/throttling_resource_handler.cc @@ -95,6 +95,10 @@ void ThrottlingResourceHandler::Cancel() { controller()->Cancel(); } +void ThrottlingResourceHandler::CancelAndIgnore() { + controller()->CancelAndIgnore(); +} + void ThrottlingResourceHandler::Resume() { switch (deferred_stage_) { case DEFERRED_NONE: diff --git a/content/browser/renderer_host/throttling_resource_handler.h b/content/browser/renderer_host/throttling_resource_handler.h index 827ab4b..cca637d 100644 --- a/content/browser/renderer_host/throttling_resource_handler.h +++ b/content/browser/renderer_host/throttling_resource_handler.h @@ -39,6 +39,7 @@ class ThrottlingResourceHandler : public LayeredResourceHandler, // ResourceThrottleController implementation: virtual void Cancel() OVERRIDE; + virtual void CancelAndIgnore() OVERRIDE; virtual void Resume() OVERRIDE; private: diff --git a/content/common/resource_dispatcher.cc b/content/common/resource_dispatcher.cc index 5fc9091..7758a48 100644 --- a/content/common/resource_dispatcher.cc +++ b/content/common/resource_dispatcher.cc @@ -185,7 +185,7 @@ void IPCResourceLoaderBridge::SetDefersLoading(bool value) { void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { if (request_id_ != -1) { NOTREACHED() << "Starting a request twice"; - response->status.set_status(net::URLRequestStatus::FAILED); + response->error_code = net::ERR_FAILED; return; } @@ -197,11 +197,11 @@ void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { request_, &result); // NOTE: This may pump events (see RenderThread::Send). if (!dispatcher_->message_sender()->Send(msg)) { - response->status.set_status(net::URLRequestStatus::FAILED); + response->error_code = net::ERR_FAILED; return; } - response->status = result.status; + response->error_code = result.error_code; response->url = result.final_url; response->headers = result.headers; response->mime_type = result.mime_type; @@ -406,7 +406,8 @@ void ResourceDispatcher::FollowPendingRedirect( void ResourceDispatcher::OnRequestComplete( int request_id, - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& browser_completion_time) { PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); @@ -419,7 +420,7 @@ void ResourceDispatcher::OnRequestComplete( if (delegate_) { ResourceLoaderBridge::Peer* new_peer = delegate_->OnRequestComplete( - request_info->peer, request_info->resource_type, status); + request_info->peer, request_info->resource_type, error_code); if (new_peer) request_info->peer = new_peer; } @@ -429,7 +430,8 @@ void ResourceDispatcher::OnRequestComplete( // The request ID will be removed from our pending list in the destructor. // Normally, dispatching this message causes the reference-counted request to // die immediately. - peer->OnCompletedRequest(status, security_info, renderer_completion_time); + peer->OnCompletedRequest(error_code, was_ignored_by_handler, security_info, + renderer_completion_time); } int ResourceDispatcher::AddPendingRequest( diff --git a/content/common/resource_dispatcher.h b/content/common/resource_dispatcher.h index 79d955b..96c33e0 100644 --- a/content/common/resource_dispatcher.h +++ b/content/common/resource_dispatcher.h @@ -124,7 +124,8 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { int data_len); void OnRequestComplete( int request_id, - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time); diff --git a/content/common/resource_dispatcher_unittest.cc b/content/common/resource_dispatcher_unittest.cc index b1e6c58..ce514c0 100644 --- a/content/common/resource_dispatcher_unittest.cc +++ b/content/common/resource_dispatcher_unittest.cc @@ -13,6 +13,7 @@ #include "content/common/resource_dispatcher.h" #include "content/common/resource_messages.h" #include "content/public/common/resource_response.h" +#include "net/base/net_errors.h" #include "net/base/upload_data.h" #include "net/http/http_response_headers.h" #include "testing/gtest/include/gtest/gtest.h" @@ -68,9 +69,10 @@ class TestRequestCallback : public ResourceLoaderBridge::Peer { } virtual void OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, - const base::TimeTicks& completion_time) OVERRIDE { + const base::TimeTicks& completion_time) { EXPECT_FALSE(complete_); complete_ = true; } @@ -246,7 +248,7 @@ class DeferredResourceLoadingTest : public ResourceDispatcherTest, set_defer_loading(true); ResourceResponseHead response_head; - response_head.status.set_status(net::URLRequestStatus::SUCCESS); + response_head.error_code = net::OK; dispatcher_->OnMessageReceived( ResourceMsg_ReceivedResponse(0, 0, response_head)); @@ -292,9 +294,10 @@ class DeferredResourceLoadingTest : public ResourceDispatcherTest, } virtual void OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, - const base::TimeTicks& completion_time) OVERRIDE { + const base::TimeTicks& completion_time) { } protected: @@ -378,7 +381,8 @@ class TimeConversionTest : public ResourceDispatcherTest, } virtual void OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time) OVERRIDE { } @@ -392,7 +396,7 @@ class TimeConversionTest : public ResourceDispatcherTest, // TODO(simonjam): Enable this when 10829031 lands. TEST_F(TimeConversionTest, DISABLED_ProperlyInitialized) { ResourceResponseHead response_head; - response_head.status.set_status(net::URLRequestStatus::SUCCESS); + response_head.error_code = net::OK; response_head.request_start = base::TimeTicks::FromInternalValue(5); response_head.response_start = base::TimeTicks::FromInternalValue(15); response_head.load_timing.base_time = base::Time::Now(); @@ -409,7 +413,7 @@ TEST_F(TimeConversionTest, DISABLED_ProperlyInitialized) { TEST_F(TimeConversionTest, PartiallyInitialized) { ResourceResponseHead response_head; - response_head.status.set_status(net::URLRequestStatus::SUCCESS); + response_head.error_code = net::OK; response_head.request_start = base::TimeTicks::FromInternalValue(5); response_head.response_start = base::TimeTicks::FromInternalValue(15); @@ -421,7 +425,7 @@ TEST_F(TimeConversionTest, PartiallyInitialized) { TEST_F(TimeConversionTest, NotInitialized) { ResourceResponseHead response_head; - response_head.status.set_status(net::URLRequestStatus::SUCCESS); + response_head.error_code = net::OK; PerformTest(response_head); diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h index 638d238..ac39813 100644 --- a/content/common/resource_messages.h +++ b/content/common/resource_messages.h @@ -17,7 +17,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead) IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo) - IPC_STRUCT_TRAITS_MEMBER(status) + IPC_STRUCT_TRAITS_MEMBER(error_code) IPC_STRUCT_TRAITS_MEMBER(request_start) IPC_STRUCT_TRAITS_MEMBER(response_start) IPC_STRUCT_TRAITS_END() @@ -172,9 +172,10 @@ IPC_MESSAGE_ROUTED2(ResourceMsg_DataDownloaded, int /* data_len */) // Sent when the request has been completed. -IPC_MESSAGE_ROUTED4(ResourceMsg_RequestComplete, +IPC_MESSAGE_ROUTED5(ResourceMsg_RequestComplete, int /* request_id */, - net::URLRequestStatus /* status */, + int /* error_code */, + bool /* was_ignored_by_handler */, std::string /* security info */, base::TimeTicks /* completion_time */) diff --git a/content/public/browser/resource_controller.h b/content/public/browser/resource_controller.h index 17c0eab..7149e08 100644 --- a/content/public/browser/resource_controller.h +++ b/content/public/browser/resource_controller.h @@ -8,10 +8,12 @@ namespace content { // Used to either resume a deferred resource load or cancel a resource load at -// any time. +// any time. CancelAndIgnore is a variation of Cancel that also causes the +// requester of the resource to act like the request was never made. class ResourceController { public: virtual void Cancel() = 0; + virtual void CancelAndIgnore() = 0; virtual void Resume() = 0; protected: virtual ~ResourceController() {} diff --git a/content/public/browser/resource_request_info.h b/content/public/browser/resource_request_info.h index 61cac09..394493f 100644 --- a/content/public/browser/resource_request_info.h +++ b/content/public/browser/resource_request_info.h @@ -84,6 +84,10 @@ class ResourceRequestInfo { // a link). virtual bool HasUserGesture() const = 0; + // True if ResourceController::CancelAndIgnore() was called. For example, + // the requested URL may be being loaded by an external program. + virtual bool WasIgnoredByHandler() const = 0; + // Returns false if there is NOT an associated render view. virtual bool GetAssociatedRenderView(int* render_process_id, int* render_view_id) const = 0; diff --git a/content/public/common/common_param_traits.cc b/content/public/common/common_param_traits.cc index f8a030d..d340931 100644 --- a/content/public/common/common_param_traits.cc +++ b/content/public/common/common_param_traits.cc @@ -99,9 +99,6 @@ void ParamTraits<net::URLRequestStatus>::Log(const param_type& p, case net::URLRequestStatus::IO_PENDING: status = "IO_PENDING "; break; - case net::URLRequestStatus::HANDLED_EXTERNALLY: - status = "HANDLED_EXTERNALLY"; - break; case net::URLRequestStatus::CANCELED: status = "CANCELED"; break; diff --git a/content/public/common/resource_dispatcher_delegate.h b/content/public/common/resource_dispatcher_delegate.h index 21eb5ce..43d174a 100644 --- a/content/public/common/resource_dispatcher_delegate.h +++ b/content/public/common/resource_dispatcher_delegate.h @@ -19,7 +19,7 @@ class CONTENT_EXPORT ResourceDispatcherDelegate { virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete( webkit_glue::ResourceLoaderBridge::Peer* current_peer, ResourceType::Type resource_type, - const net::URLRequestStatus& status) = 0; + int error_code) = 0; virtual webkit_glue::ResourceLoaderBridge::Peer* OnReceivedResponse( webkit_glue::ResourceLoaderBridge::Peer* current_peer, diff --git a/content/public/common/resource_response.h b/content/public/common/resource_response.h index ff25a76..cbda885 100644 --- a/content/public/common/resource_response.h +++ b/content/public/common/resource_response.h @@ -20,8 +20,8 @@ namespace content { // Parameters for a resource response header. struct ResourceResponseHead : webkit_glue::ResourceResponseInfo { - // The response status. - net::URLRequestStatus status; + // The response error_code. + int error_code; // TimeTicks::Now() when the browser received the request from the renderer. base::TimeTicks request_start; // TimeTicks::Now() when the browser sent the response to the renderer. diff --git a/content/public/test/render_view_fake_resources_test.cc b/content/public/test/render_view_fake_resources_test.cc index 476fac7..2046348 100644 --- a/content/public/test/render_view_fake_resources_test.cc +++ b/content/public/test/render_view_fake_resources_test.cc @@ -17,6 +17,7 @@ #include "content/renderer/renderer_webkitplatformsupport_impl.h" #include "content/test/mock_render_process.h" #include "googleurl/src/gurl.h" +#include "net/base/net_errors.h" #include "net/base/upload_data.h" #include "net/http/http_response_headers.h" #include "net/url_request/url_request_status.h" @@ -177,7 +178,8 @@ void RenderViewFakeResourcesTest::OnRequestResource( ASSERT_TRUE(channel_->Send(new ResourceMsg_RequestComplete( message.routing_id(), request_id, - net::URLRequestStatus(), + net::OK, + false, std::string(), base::TimeTicks()))); } diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index ad0d19a..2bd91fe 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -3147,10 +3147,6 @@ void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame, // from being dumb, WebCore doesn't expect it and it will cause a crash. if (error.reason == net::ERR_ABORTED) return; - // Don't display an error message if the request was handled by an - // external protocol handler. - if (error.reason == net::ERR_UNKNOWN_URL_SCHEME) - return; // Make sure we never show errors in view source mode. frame->enableViewSourceMode(false); diff --git a/net/url_request/url_fetcher_impl_unittest.cc b/net/url_request/url_fetcher_impl_unittest.cc index d68586d..a94e887 100644 --- a/net/url_request/url_fetcher_impl_unittest.cc +++ b/net/url_request/url_fetcher_impl_unittest.cc @@ -552,6 +552,7 @@ void URLFetcherStopOnRedirectTest::OnURLFetchComplete( callback_called_ = true; EXPECT_EQ(GURL(kRedirectTarget), source->GetURL()); EXPECT_EQ(URLRequestStatus::CANCELED, source->GetStatus().status()); + EXPECT_EQ(ERR_ABORTED, source->GetStatus().error()); EXPECT_EQ(301, source->GetResponseCode()); CleanupAfterFetchComplete(); } diff --git a/net/url_request/url_request_status.h b/net/url_request/url_request_status.h index 5cf1218..521a3d45 100644 --- a/net/url_request/url_request_status.h +++ b/net/url_request/url_request_status.h @@ -22,11 +22,6 @@ class URLRequestStatus { // completed. IO_PENDING, - // Request was successful but was handled by an external program, so there - // is no response data. This usually means the current page should not be - // navigated, but no error should be displayed. |error_| will be 0. - HANDLED_EXTERNALLY, - // Request was cancelled programatically. CANCELED, @@ -44,9 +39,7 @@ class URLRequestStatus { void set_error(int e) { error_ = e; } // Returns true if the status is success, which makes some calling code more - // convenient because this is the most common test. Note that we do NOT treat - // HANDLED_EXTERNALLY as success. For everything except user notifications, - // this value should be handled like an error (processing should stop). + // convenient because this is the most common test. bool is_success() const { return status_ == SUCCESS || status_ == IO_PENDING; } diff --git a/webkit/appcache/appcache_request_handler.cc b/webkit/appcache/appcache_request_handler.cc index 7673273..b8bbb9c 100644 --- a/webkit/appcache/appcache_request_handler.cc +++ b/webkit/appcache/appcache_request_handler.cc @@ -126,8 +126,7 @@ AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForResponse( if (!found_fallback_entry_.has_response_id()) return NULL; - if (request->status().status() == net::URLRequestStatus::CANCELED || - request->status().status() == net::URLRequestStatus::HANDLED_EXTERNALLY) { + if (request->status().status() == net::URLRequestStatus::CANCELED) { // 6.9.6, step 4: But not if the user canceled the download. return NULL; } diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h index e699574..2deec26 100644 --- a/webkit/glue/resource_loader_bridge.h +++ b/webkit/glue/resource_loader_bridge.h @@ -275,8 +275,8 @@ class ResourceLoaderBridge { SyncLoadResponse(); ~SyncLoadResponse(); - // The response status. - net::URLRequestStatus status; + // The response error code. + int error_code; // The final URL of the response. This may differ from the request URL in // the case of a server redirect. @@ -335,9 +335,10 @@ class ResourceLoaderBridge { virtual void OnReceivedCachedMetadata(const char* data, int len) { } // Called when the response is complete. This method signals completion of - // the resource load.ff + // the resource load. virtual void OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time) = 0; diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index cb4793c..7606719 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -123,11 +123,11 @@ class HeaderFlattener : public WebHTTPHeaderVisitor { bool GetInfoFromDataURL(const GURL& url, ResourceResponseInfo* info, std::string* data, - net::URLRequestStatus* status) { + int* error_code) { std::string mime_type; std::string charset; if (net::DataURL::Parse(url, &mime_type, &charset, data)) { - *status = net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0); + *error_code = net::OK; // Assure same time for all time fields of data: URLs. Time now = Time::Now(); info->load_timing.base_time = now; @@ -144,8 +144,7 @@ bool GetInfoFromDataURL(const GURL& url, return true; } - *status = net::URLRequestStatus(net::URLRequestStatus::FAILED, - net::ERR_INVALID_URL); + *error_code = net::ERR_INVALID_URL; return false; } @@ -299,7 +298,8 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>, int data_length, int encoded_data_length); virtual void OnReceivedCachedMetadata(const char* data, int len); - virtual void OnCompletedRequest(const net::URLRequestStatus& status, + virtual void OnCompletedRequest(int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time); @@ -364,7 +364,7 @@ void WebURLLoaderImpl::Context::Start( std::string data; GetInfoFromDataURL(sync_load_response->url, sync_load_response, &sync_load_response->data, - &sync_load_response->status); + &sync_load_response->error_code); } else { AddRef(); // Balanced in OnCompletedRequest MessageLoop::current()->PostTask(FROM_HERE, @@ -637,7 +637,8 @@ void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( } void WebURLLoaderImpl::Context::OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, + bool was_ignored_by_handler, const std::string& security_info, const base::TimeTicks& completion_time) { if (ftp_listing_delegate_.get()) { @@ -654,15 +655,7 @@ void WebURLLoaderImpl::Context::OnCompletedRequest( completed_bridge_.swap(bridge_); if (client_) { - if (status.status() != net::URLRequestStatus::SUCCESS) { - int error_code; - if (status.status() == net::URLRequestStatus::HANDLED_EXTERNALLY) { - // By marking this request as aborted we insure that we don't navigate - // to an error page. - error_code = net::ERR_ABORTED; - } else { - error_code = status.error(); - } + if (error_code != net::OK) { WebURLError error; if (error_code == net::ERR_ABORTED) { error.isCancellation = true; @@ -718,16 +711,17 @@ bool WebURLLoaderImpl::Context::CanHandleDataURL(const GURL& url) const { void WebURLLoaderImpl::Context::HandleDataURL() { ResourceResponseInfo info; - net::URLRequestStatus status; + int error_code; std::string data; - if (GetInfoFromDataURL(request_.url(), &info, &data, &status)) { + if (GetInfoFromDataURL(request_.url(), &info, &data, &error_code)) { OnReceivedResponse(info); if (!data.empty()) OnReceivedData(data.data(), data.size(), 0); } - OnCompletedRequest(status, info.security_info, base::TimeTicks::Now()); + OnCompletedRequest(error_code, false, info.security_info, + base::TimeTicks::Now()); } // WebURLLoaderImpl ----------------------------------------------------------- @@ -752,13 +746,11 @@ void WebURLLoaderImpl::loadSynchronously(const WebURLRequest& request, // TODO(tc): For file loads, we may want to include a more descriptive // status code or status text. - const net::URLRequestStatus::Status& status = - sync_load_response.status.status(); - if (status != net::URLRequestStatus::SUCCESS && - status != net::URLRequestStatus::HANDLED_EXTERNALLY) { + int error_code = sync_load_response.error_code; + if (error_code != net::OK) { response.setURL(final_url); error.domain = WebString::fromUTF8(net::kErrorDomain); - error.reason = sync_load_response.status.error(); + error.reason = error_code; error.unreachableURL = final_url; return; } diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc index 1be9a36..46554f3 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc @@ -398,11 +398,12 @@ class RequestProxy peer_->OnDownloadedData(bytes_read); } - void NotifyCompletedRequest(const net::URLRequestStatus& status, + void NotifyCompletedRequest(int error_code, const std::string& security_info, const base::TimeTicks& complete_time) { if (peer_) { - peer_->OnCompletedRequest(status, security_info, complete_time); + peer_->OnCompletedRequest(error_code, false, security_info, + complete_time); DropPeer(); // ensure no further notifications } } @@ -533,14 +534,14 @@ class RequestProxy base::Bind(&RequestProxy::NotifyReceivedData, this, bytes_read)); } - virtual void OnCompletedRequest(const net::URLRequestStatus& status, + virtual void OnCompletedRequest(int error_code, const std::string& security_info, const base::TimeTicks& complete_time) { if (download_to_file_) file_stream_.CloseSync(); owner_loop_->PostTask( FROM_HERE, - base::Bind(&RequestProxy::NotifyCompletedRequest, this, status, + base::Bind(&RequestProxy::NotifyCompletedRequest, this, error_code, security_info, complete_time)); } @@ -604,7 +605,8 @@ class RequestProxy // was a file request and encountered an error, then we need to use the // |failed_file_request_status_|. Otherwise use request_'s status. OnCompletedRequest(failed_file_request_status_.get() ? - *failed_file_request_status_ : request_->status(), + failed_file_request_status_->error() : + request_->status().error(), std::string(), base::TimeTicks()); request_.reset(); // destroy on the io thread } @@ -824,12 +826,12 @@ class SyncRequestProxy : public RequestProxy { } virtual void OnCompletedRequest( - const net::URLRequestStatus& status, + int error_code, const std::string& security_info, const base::TimeTicks& complete_time) OVERRIDE { if (download_to_file_) file_stream_.CloseSync(); - result_->status = status; + result_->error_code = error_code; event_.Signal(); } |