Index: content/child/resource_dispatcher.cc |
diff --git a/content/child/resource_dispatcher.cc b/content/child/resource_dispatcher.cc |
index ad64cd12964a823bf6c25f7626cacaa49d8adb98..7119d7eb2749a3cc6b52f0f3c20a13b5f5ea0863 100644 |
--- a/content/child/resource_dispatcher.cc |
+++ b/content/child/resource_dispatcher.cc |
@@ -28,10 +28,8 @@ |
#include "net/base/net_util.h" |
#include "net/base/request_priority.h" |
#include "net/http/http_response_headers.h" |
-#include "webkit/child/resource_loader_bridge.h" |
#include "webkit/common/resource_type.h" |
-using webkit_glue::ResourceLoaderBridge; |
using webkit_glue::ResourceResponseInfo; |
namespace content { |
@@ -47,10 +45,7 @@ void RemoteToLocalTimeTicks( |
*time = converter.ToLocalTimeTicks(remote_time).ToTimeTicks(); |
} |
- |
-} // namespace |
- |
-static void CrashOnMapFailure() { |
+void CrashOnMapFailure() { |
#if defined(OS_WIN) |
DWORD last_err = GetLastError(); |
base::debug::Alias(&last_err); |
@@ -59,7 +54,7 @@ static void CrashOnMapFailure() { |
} |
// Each resource request is assigned an ID scoped to this process. |
-static int MakeRequestID() { |
+int MakeRequestID() { |
// NOTE: The resource_dispatcher_host also needs probably unique |
// request_ids, so they count down from -2 (-1 is a special we're |
// screwed value), while the renderer process counts up. |
@@ -67,21 +62,20 @@ static int MakeRequestID() { |
return next_request_id++; |
} |
-// ResourceLoaderBridge implementation ---------------------------------------- |
+} // namespace |
-class IPCResourceLoaderBridge : public ResourceLoaderBridge { |
+class ResourceDispatcher::IPCResourceLoaderBridge { |
public: |
IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, |
const RequestInfo& request_info); |
virtual ~IPCResourceLoaderBridge(); |
- // ResourceLoaderBridge |
- virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE; |
- virtual bool Start(RequestPeer* peer) OVERRIDE; |
- virtual void Cancel() OVERRIDE; |
- virtual void SetDefersLoading(bool value) OVERRIDE; |
- virtual void DidChangePriority(net::RequestPriority new_priority) OVERRIDE; |
- virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE; |
+ void SetRequestBody(ResourceRequestBody* request_body); |
+ bool Start(RequestPeer* peer); |
+ void Cancel(); |
+ void SetDefersLoading(bool value); |
+ void DidChangePriority(net::RequestPriority new_priority); |
+ void SyncLoad(SyncLoadResponse* response); |
private: |
RequestPeer* peer_; |
@@ -106,7 +100,7 @@ class IPCResourceLoaderBridge : public ResourceLoaderBridge { |
bool is_synchronous_request_; |
}; |
-IPCResourceLoaderBridge::IPCResourceLoaderBridge( |
+ResourceDispatcher::IPCResourceLoaderBridge::IPCResourceLoaderBridge( |
ResourceDispatcher* dispatcher, |
const RequestInfo& request_info) |
: peer_(NULL), |
@@ -154,7 +148,7 @@ IPCResourceLoaderBridge::IPCResourceLoaderBridge( |
frame_origin_ = extra_data->frame_origin(); |
} |
-IPCResourceLoaderBridge::~IPCResourceLoaderBridge() { |
+ResourceDispatcher::IPCResourceLoaderBridge::~IPCResourceLoaderBridge() { |
// we remove our hook for the resource dispatcher only when going away, since |
// it doesn't keep track of whether we've force terminated the request |
if (request_id_ >= 0) { |
@@ -169,14 +163,14 @@ IPCResourceLoaderBridge::~IPCResourceLoaderBridge() { |
} |
} |
-void IPCResourceLoaderBridge::SetRequestBody( |
+void ResourceDispatcher::IPCResourceLoaderBridge::SetRequestBody( |
ResourceRequestBody* request_body) { |
DCHECK(request_id_ == -1) << "request already started"; |
request_.request_body = request_body; |
} |
// Writes a footer on the message and sends it |
-bool IPCResourceLoaderBridge::Start(RequestPeer* peer) { |
+bool ResourceDispatcher::IPCResourceLoaderBridge::Start(RequestPeer* peer) { |
if (request_id_ != -1) { |
NOTREACHED() << "Starting a request twice"; |
return false; |
@@ -195,7 +189,7 @@ bool IPCResourceLoaderBridge::Start(RequestPeer* peer) { |
new ResourceHostMsg_RequestResource(routing_id_, request_id_, request_)); |
} |
-void IPCResourceLoaderBridge::Cancel() { |
+void ResourceDispatcher::IPCResourceLoaderBridge::Cancel() { |
if (request_id_ < 0) { |
NOTREACHED() << "Trying to cancel an unstarted request"; |
return; |
@@ -209,7 +203,7 @@ void IPCResourceLoaderBridge::Cancel() { |
// to be flushed, and will then cause a complete message to be sent. |
} |
-void IPCResourceLoaderBridge::SetDefersLoading(bool value) { |
+void ResourceDispatcher::IPCResourceLoaderBridge::SetDefersLoading(bool value) { |
if (request_id_ < 0) { |
NOTREACHED() << "Trying to (un)defer an unstarted request"; |
return; |
@@ -218,7 +212,7 @@ void IPCResourceLoaderBridge::SetDefersLoading(bool value) { |
dispatcher_->SetDefersLoading(request_id_, value); |
} |
-void IPCResourceLoaderBridge::DidChangePriority( |
+void ResourceDispatcher::IPCResourceLoaderBridge::DidChangePriority( |
net::RequestPriority new_priority) { |
if (request_id_ < 0) { |
NOTREACHED() << "Trying to change priority of an unstarted request"; |
@@ -228,7 +222,8 @@ void IPCResourceLoaderBridge::DidChangePriority( |
dispatcher_->DidChangePriority(routing_id_, request_id_, new_priority); |
} |
-void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { |
+void ResourceDispatcher::IPCResourceLoaderBridge::SyncLoad( |
+ SyncLoadResponse* response) { |
if (request_id_ != -1) { |
NOTREACHED() << "Starting a request twice"; |
response->error_code = net::ERR_FAILED; |
@@ -316,6 +311,41 @@ bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { |
return true; |
} |
+void ResourceDispatcher::CreateBridge(const RequestInfo& info) { |
+ bridge_.reset(new IPCResourceLoaderBridge(this, info)); |
+} |
+ |
+void ResourceDispatcher::SetRequestBody(ResourceRequestBody* request_body) { |
+ if (bridge_) |
+ bridge_->SetRequestBody(request_body); |
+} |
+ |
+bool ResourceDispatcher::Start(RequestPeer* peer) { |
+ if (bridge_) |
+ return bridge_->Start(peer); |
+ return false; |
+} |
+ |
+void ResourceDispatcher::Cancel() { |
+ if (bridge_) |
+ bridge_->Cancel(); |
+} |
+ |
+void ResourceDispatcher::SetDefersLoading(bool value) { |
+ if (bridge_) |
+ bridge_->SetDefersLoading(value); |
+} |
+ |
+void ResourceDispatcher::DidChangePriority(net::RequestPriority new_priority) { |
+ if (bridge_) |
+ bridge_->DidChangePriority(new_priority); |
+} |
+ |
+void ResourceDispatcher::SyncLoad(SyncLoadResponse* response) { |
+ if (bridge_) |
+ bridge_->SyncLoad(response); |
+} |
+ |
ResourceDispatcher::PendingRequestInfo* |
ResourceDispatcher::GetPendingRequestInfo(int request_id) { |
PendingRequestList::iterator it = pending_requests_.find(request_id); |
@@ -691,11 +721,6 @@ void ResourceDispatcher::FlushDeferredMessages(int request_id) { |
} |
} |
-ResourceLoaderBridge* ResourceDispatcher::CreateBridge( |
- const RequestInfo& request_info) { |
- return new IPCResourceLoaderBridge(this, request_info); |
-} |
- |
void ResourceDispatcher::ToResourceResponseInfo( |
const PendingRequestInfo& request_info, |
const ResourceResponseHead& browser_info, |