Index: content/child/npapi/plugin_url_fetcher.cc |
diff --git a/content/child/npapi/plugin_url_fetcher.cc b/content/child/npapi/plugin_url_fetcher.cc |
index ffa01d493a6dbf75414064f4af813b4ff7773da1..d1c5c248a22dc48776305874f22cd339d1f67d3e 100644 |
--- a/content/child/npapi/plugin_url_fetcher.cc |
+++ b/content/child/npapi/plugin_url_fetcher.cc |
@@ -24,6 +24,7 @@ |
#include "third_party/WebKit/public/platform/WebURLLoaderClient.h" |
#include "third_party/WebKit/public/platform/WebURLResponse.h" |
#include "webkit/child/multipart_response_delegate.h" |
+#include "webkit/child/resource_loader_bridge.h" |
#include "webkit/common/resource_response_info.h" |
namespace content { |
@@ -102,8 +103,7 @@ |
resource_id_(resource_id), |
copy_stream_data_(copy_stream_data), |
data_offset_(0), |
- pending_failure_notification_(false), |
- request_id_(-1) { |
+ pending_failure_notification_(false) { |
RequestInfo request_info; |
request_info.method = method; |
request_info.url = url; |
@@ -143,28 +143,25 @@ |
request_info.headers = std::string("Range: ") + range; |
} |
- ResourceDispatcher* dispatcher = |
- ChildThread::current()->resource_dispatcher(); |
- |
- scoped_refptr<ResourceRequestBody> request_body = new ResourceRequestBody; |
- |
- if (!body.empty()) |
+ bridge_.reset(ChildThread::current()->resource_dispatcher()->CreateBridge( |
+ request_info)); |
+ if (!body.empty()) { |
+ scoped_refptr<ResourceRequestBody> request_body = |
+ new ResourceRequestBody; |
request_body->AppendBytes(&body[0], body.size()); |
- |
- request_id_ = dispatcher->StartAsync(request_info, request_body, this); |
+ bridge_->SetRequestBody(request_body.get()); |
+ } |
+ |
+ bridge_->Start(this); |
// TODO(jam): range requests |
} |
PluginURLFetcher::~PluginURLFetcher() { |
- if (request_id_ >= 0) { |
- ChildThread::current()->resource_dispatcher()->RemovePendingRequest( |
- request_id_); |
- } |
} |
void PluginURLFetcher::Cancel() { |
- ChildThread::current()->resource_dispatcher()->Cancel(request_id_); |
+ bridge_->Cancel(); |
// Due to races and nested event loops, PluginURLFetcher may still receive |
// events from the bridge before being destroyed. Do not forward additional |
@@ -180,13 +177,10 @@ |
if (!plugin_stream_) |
return; |
- ResourceDispatcher* dispatcher = |
- ChildThread::current()->resource_dispatcher(); |
- |
if (allow) { |
- dispatcher->SetDefersLoading(request_id_, false); |
- } else { |
- dispatcher->Cancel(request_id_); |
+ bridge_->SetDefersLoading(false); |
+ } else { |
+ bridge_->Cancel(); |
plugin_stream_->DidFail(resource_id_); // That will delete |this|. |
} |
} |
@@ -237,9 +231,7 @@ |
} |
} else { |
// Pause the request while we ask the plugin what to do about the redirect. |
- ResourceDispatcher* dispatcher = |
- ChildThread::current()->resource_dispatcher(); |
- dispatcher->SetDefersLoading(request_id_, true); |
+ bridge_->SetDefersLoading(true); |
plugin_stream_->WillSendRequest(url_, response_code); |
} |