diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-29 22:35:33 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-29 22:35:33 +0000 |
commit | ea3d1d84be3d6f97bf50e76511c9e26af6895533 (patch) | |
tree | 94c73f600dcca23329221ad8c51e6a5158263f7e /chrome | |
parent | 403e46333b43009776a08273501e4ca8c5c06e12 (diff) | |
download | chromium_src-ea3d1d84be3d6f97bf50e76511c9e26af6895533.zip chromium_src-ea3d1d84be3d6f97bf50e76511c9e26af6895533.tar.gz chromium_src-ea3d1d84be3d6f97bf50e76511c9e26af6895533.tar.bz2 |
Fix passing pointers between processes.
BUG=31880
Review URL: http://codereview.chromium.org/558036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/common/plugin_messages.h | 74 | ||||
-rw-r--r-- | chrome/common/plugin_messages_internal.h | 44 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.cc | 33 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.h | 25 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.cc | 59 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.h | 35 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_pepper.cc | 34 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_pepper.h | 14 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 92 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.h | 23 |
10 files changed, 153 insertions, 280 deletions
diff --git a/chrome/common/plugin_messages.h b/chrome/common/plugin_messages.h index 736e55e..74de33f 100644 --- a/chrome/common/plugin_messages.h +++ b/chrome/common/plugin_messages.h @@ -42,25 +42,14 @@ struct PluginMsg_Init_Params { }; struct PluginHostMsg_URLRequest_Params { + std::string url; std::string method; - bool is_javascript_url; std::string target; std::vector<char> buffer; - bool is_file_data; - bool notify; - std::string url; - intptr_t notify_data; + int notify_id; bool popups_allowed; }; -struct PluginMsg_URLRequestReply_Params { - unsigned long resource_id; - GURL url; - bool notify_needed; - intptr_t notify_data; - intptr_t stream; -}; - struct PluginMsg_DidReceiveResponseParams { unsigned long id; std::string mime_type; @@ -163,45 +152,33 @@ template <> struct ParamTraits<PluginHostMsg_URLRequest_Params> { typedef PluginHostMsg_URLRequest_Params param_type; static void Write(Message* m, const param_type& p) { + WriteParam(m, p.url); WriteParam(m, p.method); - WriteParam(m, p.is_javascript_url); WriteParam(m, p.target); WriteParam(m, p.buffer); - WriteParam(m, p.is_file_data); - WriteParam(m, p.notify); - WriteParam(m, p.url); - WriteParam(m, p.notify_data); + WriteParam(m, p.notify_id); WriteParam(m, p.popups_allowed); } static bool Read(const Message* m, void** iter, param_type* p) { return + ReadParam(m, iter, &p->url) && ReadParam(m, iter, &p->method) && - ReadParam(m, iter, &p->is_javascript_url) && ReadParam(m, iter, &p->target) && ReadParam(m, iter, &p->buffer) && - ReadParam(m, iter, &p->is_file_data) && - ReadParam(m, iter, &p->notify) && - ReadParam(m, iter, &p->url) && - ReadParam(m, iter, &p->notify_data) && + ReadParam(m, iter, &p->notify_id) && ReadParam(m, iter, &p->popups_allowed); } static void Log(const param_type& p, std::wstring* l) { l->append(L"("); - LogParam(p.method, l); + LogParam(p.url, l); l->append(L", "); - LogParam(p.is_javascript_url, l); + LogParam(p.method, l); l->append(L", "); LogParam(p.target, l); l->append(L", "); LogParam(p.buffer, l); l->append(L", "); - LogParam(p.is_file_data, l); - l->append(L", "); - LogParam(p.notify, l); - l->append(L", "); - LogParam(p.url, l); - l->append(L", "); - LogParam(p.notify_data, l); + LogParam(p.notify_id, l); l->append(L", "); LogParam(p.popups_allowed, l); l->append(L")"); @@ -209,39 +186,6 @@ struct ParamTraits<PluginHostMsg_URLRequest_Params> { }; template <> -struct ParamTraits<PluginMsg_URLRequestReply_Params> { - typedef PluginMsg_URLRequestReply_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.resource_id); - WriteParam(m, p.url); - WriteParam(m, p.notify_needed); - WriteParam(m, p.notify_data); - WriteParam(m, p.stream); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->resource_id) && - ReadParam(m, iter, &p->url) && - ReadParam(m, iter, &p->notify_needed) && - ReadParam(m, iter, &p->notify_data) && - ReadParam(m, iter, &p->stream); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.resource_id, l); - l->append(L", "); - LogParam(p.url, l); - l->append(L", "); - LogParam(p.notify_needed, l); - l->append(L", "); - LogParam(p.notify_data, l); - l->append(L", "); - LogParam(p.stream, l); - l->append(L")"); - } -}; - -template <> struct ParamTraits<PluginMsg_DidReceiveResponseParams> { typedef PluginMsg_DidReceiveResponseParams param_type; static void Write(Message* m, const param_type& p) { diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index c220b8b..f65816c 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -202,14 +202,13 @@ IPC_BEGIN_MESSAGES(Plugin) base::SharedMemoryHandle /* shared_memory*/, size_t /* size */) - IPC_SYNC_MESSAGE_ROUTED0_2(PluginMsg_GetPluginScriptableObject, - int /* route_id */, - intptr_t /* npobject_ptr */) + IPC_SYNC_MESSAGE_ROUTED0_1(PluginMsg_GetPluginScriptableObject, + int /* route_id */) - IPC_SYNC_MESSAGE_ROUTED3_0(PluginMsg_DidFinishLoadWithReason, - GURL /* url */, - int /* reason */, - intptr_t /* notify_data */) + IPC_MESSAGE_ROUTED3(PluginMsg_DidFinishLoadWithReason, + GURL /* url */, + int /* reason */, + int /* notify_id */) // Updates the plugin location. IPC_MESSAGE_ROUTED1(PluginMsg_UpdateGeometry, @@ -244,12 +243,11 @@ IPC_BEGIN_MESSAGES(Plugin) IPC_MESSAGE_ROUTED1(PluginMsg_DidFail, unsigned long /* id */) - IPC_MESSAGE_ROUTED5(PluginMsg_SendJavaScriptStream, + IPC_MESSAGE_ROUTED4(PluginMsg_SendJavaScriptStream, GURL /* url */, std::string /* result */, bool /* success */, - bool /* notify required */, - intptr_t /* notify data */) + int /* notify_id */) IPC_MESSAGE_ROUTED2(PluginMsg_DidReceiveManualResponse, GURL /* url */, @@ -264,8 +262,14 @@ IPC_BEGIN_MESSAGES(Plugin) IPC_MESSAGE_ROUTED0(PluginMsg_InstallMissingPlugin) - IPC_SYNC_MESSAGE_ROUTED1_0(PluginMsg_HandleURLRequestReply, - PluginMsg_URLRequestReply_Params) + IPC_MESSAGE_ROUTED3(PluginMsg_HandleURLRequestReply, + unsigned long /* resource_id */, + GURL /* url */, + int /* notify_id */) + + IPC_MESSAGE_ROUTED2(PluginMsg_HTTPRangeRequestReply, + unsigned long /* resource_id */, + int /* range_request_id */) IPC_SYNC_MESSAGE_ROUTED0_1(PluginMsg_CreateCommandBuffer, int /* route_id */) @@ -307,15 +311,13 @@ IPC_BEGIN_MESSAGES(PluginHost) IPC_MESSAGE_ROUTED1(PluginHostMsg_InvalidateRect, gfx::Rect /* rect */) - IPC_SYNC_MESSAGE_ROUTED1_2(PluginHostMsg_GetWindowScriptNPObject, + IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_GetWindowScriptNPObject, int /* route id */, - bool /* success */, - intptr_t /* npobject_ptr */) + bool /* success */) - IPC_SYNC_MESSAGE_ROUTED1_2(PluginHostMsg_GetPluginElement, + IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_GetPluginElement, int /* route id */, - bool /* success */, - intptr_t /* npobject_ptr */) + bool /* success */) IPC_MESSAGE_ROUTED3(PluginHostMsg_SetCookie, GURL /* url */, @@ -356,12 +358,10 @@ IPC_BEGIN_MESSAGES(PluginHost) IPC_MESSAGE_ROUTED0(PluginHostMsg_CancelDocumentLoad) - IPC_MESSAGE_ROUTED5(PluginHostMsg_InitiateHTTPRangeRequest, + IPC_MESSAGE_ROUTED3(PluginHostMsg_InitiateHTTPRangeRequest, std::string /* url */, std::string /* range_info */, - intptr_t /* existing_stream */, - bool /* notify_needed */, - intptr_t /* notify_data */) + int /* range_request_id */) IPC_MESSAGE_ROUTED2(PluginHostMsg_DeferResourceLoading, unsigned long /* resource_id */, diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index 49c535c..1764366 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -130,6 +130,8 @@ void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(PluginMsg_InstallMissingPlugin, OnInstallMissingPlugin) IPC_MESSAGE_HANDLER(PluginMsg_HandleURLRequestReply, OnHandleURLRequestReply) + IPC_MESSAGE_HANDLER(PluginMsg_HTTPRangeRequestReply, + OnHTTPRangeRequestReply) IPC_MESSAGE_HANDLER(PluginMsg_CreateCommandBuffer, OnCreateCommandBuffer) IPC_MESSAGE_UNHANDLED_ERROR() @@ -237,8 +239,8 @@ void WebPluginDelegateStub::OnDidFail(int id) { } void WebPluginDelegateStub::OnDidFinishLoadWithReason( - const GURL& url, int reason, intptr_t notify_data) { - delegate_->DidFinishLoadWithReason(url, reason, notify_data); + const GURL& url, int reason, int notify_id) { + delegate_->DidFinishLoadWithReason(url, reason, notify_id); } void WebPluginDelegateStub::OnSetFocus() { @@ -304,9 +306,7 @@ void WebPluginDelegateStub::OnUpdateGeometry( ); } -void WebPluginDelegateStub::OnGetPluginScriptableObject( - int* route_id, - intptr_t* npobject_ptr) { +void WebPluginDelegateStub::OnGetPluginScriptableObject(int* route_id) { NPObject* object = delegate_->GetPluginScriptableObject(); if (!object) { *route_id = MSG_ROUTING_NONE; @@ -314,7 +314,6 @@ void WebPluginDelegateStub::OnGetPluginScriptableObject( } *route_id = channel_->GenerateRouteID(); - *npobject_ptr = reinterpret_cast<intptr_t>(object); // The stub will delete itself when the proxy tells it that it's released, or // otherwise when the channel is closed. new NPObjectStub( @@ -328,10 +327,8 @@ void WebPluginDelegateStub::OnGetPluginScriptableObject( void WebPluginDelegateStub::OnSendJavaScriptStream(const GURL& url, const std::string& result, bool success, - bool notify_needed, - intptr_t notify_data) { - delegate_->SendJavaScriptStream(url, result, success, notify_needed, - notify_data); + int notify_id) { + delegate_->SendJavaScriptStream(url, result, success, notify_id); } void WebPluginDelegateStub::OnDidReceiveManualResponse( @@ -404,11 +401,15 @@ void WebPluginDelegateStub::CreateSharedBuffer( } void WebPluginDelegateStub::OnHandleURLRequestReply( - const PluginMsg_URLRequestReply_Params& params) { + unsigned long resource_id, const GURL& url, int notify_id) { WebPluginResourceClient* resource_client = - delegate_->CreateResourceClient(params.resource_id, params.url, - params.notify_needed, - params.notify_data, - params.stream); - webplugin_->OnResourceCreated(params.resource_id, resource_client); + delegate_->CreateResourceClient(resource_id, url, notify_id); + webplugin_->OnResourceCreated(resource_id, resource_client); +} + +void WebPluginDelegateStub::OnHTTPRangeRequestReply( + unsigned long resource_id, int range_request_id) { + WebPluginResourceClient* resource_client = + delegate_->CreateSeekableResourceClient(resource_id, range_request_id); + webplugin_->OnResourceCreated(resource_id, resource_client); } diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index 34358fa..ddc8632 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -24,7 +24,6 @@ class WebPluginProxy; struct PluginMsg_Init_Params; struct PluginMsg_DidReceiveResponseParams; struct PluginMsg_UpdateGeometry_Param; -struct PluginMsg_URLRequestReply_Params; class WebCursor; namespace WebKit { @@ -59,32 +58,25 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, // Message handlers for the WebPluginDelegate calls that are proxied from the // renderer over the IPC channel. void OnInit(const PluginMsg_Init_Params& params, bool* result); - void OnWillSendRequest(int id, const GURL& url); void OnDidReceiveResponse(const PluginMsg_DidReceiveResponseParams& params); void OnDidReceiveData(int id, const std::vector<char>& buffer, int data_offset); void OnDidFinishLoading(int id); void OnDidFail(int id); - - void OnDidFinishLoadWithReason(const GURL& url, int reason, - intptr_t notify_data); + void OnDidFinishLoadWithReason(const GURL& url, int reason, int notify_id); void OnSetFocus(); void OnHandleInputEvent(const WebKit::WebInputEvent* event, bool* handled, WebCursor* cursor); - void OnPaint(const gfx::Rect& damaged_rect); void OnDidPaint(); - void OnPrint(base::SharedMemoryHandle* shared_memory, size_t* size); - void OnUpdateGeometry(const PluginMsg_UpdateGeometry_Param& param); - void OnGetPluginScriptableObject(int* route_id, intptr_t* npobject_ptr); + void OnGetPluginScriptableObject(int* route_id); void OnSendJavaScriptStream(const GURL& url, const std::string& result, - bool success, bool notify_needed, - intptr_t notify_data); - + bool success, + int notify_id); void OnDidReceiveManualResponse( const GURL& url, const PluginMsg_DidReceiveResponseParams& params); @@ -92,12 +84,11 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, void OnDidFinishManualLoading(); void OnDidManualLoadFail(); void OnInstallMissingPlugin(); - - void OnHandleURLRequestReply( - const PluginMsg_URLRequestReply_Params& params); - + void OnHandleURLRequestReply(unsigned long resource_id, + const GURL& url, + int notify_id); + void OnHTTPRangeRequestReply(unsigned long resource_id, int range_request_id); void OnCreateCommandBuffer(int* route_id); - void CreateSharedBuffer(size_t size, base::SharedMemory* shared_buf, base::SharedMemoryHandle* remote_handle); diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index 34091e9..a05113b 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -26,7 +26,6 @@ #include "chrome/plugin/npobject_util.h" #include "chrome/plugin/plugin_channel.h" #include "chrome/plugin/plugin_thread.h" -#include "chrome/plugin/webplugin_delegate_stub.h" #include "skia/ext/platform_device.h" #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" #include "webkit/glue/plugins/webplugin_delegate_impl.h" @@ -151,9 +150,8 @@ NPObject* WebPluginProxy::GetWindowScriptNPObject() { int npobject_route_id = channel_->GenerateRouteID(); bool success = false; - intptr_t npobject_ptr = NULL; Send(new PluginHostMsg_GetWindowScriptNPObject( - route_id_, npobject_route_id, &success, &npobject_ptr)); + route_id_, npobject_route_id, &success)); if (!success) return NULL; @@ -169,9 +167,7 @@ NPObject* WebPluginProxy::GetPluginElement() { int npobject_route_id = channel_->GenerateRouteID(); bool success = false; - intptr_t npobject_ptr = NULL; - Send(new PluginHostMsg_GetPluginElement( - route_id_, npobject_route_id, &success, &npobject_ptr)); + Send(new PluginHostMsg_GetPluginElement(route_id_, npobject_route_id, &success)); if (!success) return NULL; @@ -254,31 +250,20 @@ void WebPluginProxy::DidPaint() { InvalidateRect(damaged_rect_); } -void WebPluginProxy::OnResourceCreated(int resource_id, HANDLE cookie) { - WebPluginResourceClient* resource_client = - reinterpret_cast<WebPluginResourceClient*>(cookie); - if (!resource_client) { - NOTREACHED(); - return; - } - +void WebPluginProxy::OnResourceCreated(int resource_id, + WebPluginResourceClient* client) { DCHECK(resource_clients_.find(resource_id) == resource_clients_.end()); - resource_clients_[resource_id] = resource_client; + resource_clients_[resource_id] = client; } -void WebPluginProxy::HandleURLRequest(const char *method, - bool is_javascript_url, - const char* target, unsigned int len, - const char* buf, bool is_file_data, - bool notify, const char* url, - intptr_t notify_data, +void WebPluginProxy::HandleURLRequest(const char* url, + const char *method, + const char* target, + const char* buf, + unsigned int len, + int notify_id, bool popups_allowed) { - if (!url) { - NOTREACHED(); - return; - } - - if (!target && (0 == base::strcasecmp(method, "GET"))) { + if (!target && (0 == base::strcasecmp(method, "GET"))) { // Please refer to https://bugzilla.mozilla.org/show_bug.cgi?id=366082 // for more details on this. if (delegate_->GetQuirks() & @@ -293,8 +278,8 @@ void WebPluginProxy::HandleURLRequest(const char *method, } PluginHostMsg_URLRequest_Params params; + params.url = url; params.method = method; - params.is_javascript_url = is_javascript_url; if (target) params.target = std::string(target); @@ -303,10 +288,7 @@ void WebPluginProxy::HandleURLRequest(const char *method, memcpy(¶ms.buffer.front(), buf, len); } - params.is_file_data = is_file_data; - params.notify = notify; - params.url = url; - params.notify_data = notify_data; + params.notify_id = notify_id; params.popups_allowed = popups_allowed; Send(new PluginHostMsg_URLRequest(route_id_, params)); @@ -567,15 +549,10 @@ void WebPluginProxy::CancelDocumentLoad() { Send(new PluginHostMsg_CancelDocumentLoad(route_id_)); } -void WebPluginProxy::InitiateHTTPRangeRequest(const char* url, - const char* range_info, - intptr_t existing_stream, - bool notify_needed, - intptr_t notify_data) { - - Send(new PluginHostMsg_InitiateHTTPRangeRequest(route_id_, url, - range_info, existing_stream, - notify_needed, notify_data)); +void WebPluginProxy::InitiateHTTPRangeRequest( + const char* url, const char* range_info, int range_request_id) { + Send(new PluginHostMsg_InitiateHTTPRangeRequest( + route_id_, url, range_info, range_request_id)); } void WebPluginProxy::SetDeferResourceLoading(unsigned long resource_id, diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h index 4a91685..5fc699c 100644 --- a/chrome/plugin/webplugin_proxy.h +++ b/chrome/plugin/webplugin_proxy.h @@ -103,17 +103,17 @@ class WebPluginProxy : public webkit_glue::WebPlugin { // Callback from the renderer to let us know that a paint occurred. void DidPaint(); - // Notification received on a plugin issued resource request - // creation. - void OnResourceCreated(int resource_id, HANDLE cookie); - - void HandleURLRequest(const char *method, - bool is_javascript_url, - const char* target, unsigned int len, - const char* buf, bool is_file_data, - bool notify, const char* url, - intptr_t notify_data, bool popups_allowed); - + // Notification received on a plugin issued resource request creation. + void OnResourceCreated(int resource_id, + webkit_glue::WebPluginResourceClient* client); + + void HandleURLRequest(const char* url, + const char *method, + const char* target, + const char* buf, + unsigned int len, + int notify_id, + bool popups_allowed); void UpdateGeometry(const gfx::Rect& window_rect, const gfx::Rect& clip_rect, const TransportDIB::Handle& windowless_buffer, @@ -123,22 +123,13 @@ class WebPluginProxy : public webkit_glue::WebPlugin { int ack_key #endif ); - void CancelDocumentLoad(); - - void InitiateHTTPRangeRequest(const char* url, - const char* range_info, - intptr_t existing_stream, - bool notify_needed, - intptr_t notify_data); - + void InitiateHTTPRangeRequest( + const char* url, const char* range_info, int range_request_id); void SetDeferResourceLoading(unsigned long resource_id, bool defer); - bool IsOffTheRecord(); - void ResourceClientDeleted( webkit_glue::WebPluginResourceClient* resource_client); - gfx::NativeViewId containing_window() { return containing_window_; } private: diff --git a/chrome/renderer/webplugin_delegate_pepper.cc b/chrome/renderer/webplugin_delegate_pepper.cc index d25364f..b9b61fe 100644 --- a/chrome/renderer/webplugin_delegate_pepper.cc +++ b/chrome/renderer/webplugin_delegate_pepper.cc @@ -173,11 +173,8 @@ NPObject* WebPluginDelegatePepper::GetPluginScriptableObject() { } void WebPluginDelegatePepper::DidFinishLoadWithReason( - const GURL& url, - NPReason reason, - intptr_t notify_data) { - instance()->DidFinishLoadWithReason( - url, reason, reinterpret_cast<void*>(notify_data)); + const GURL& url, NPReason reason, int notify_id) { + instance()->DidFinishLoadWithReason(url, reason, notify_id); } int WebPluginDelegatePepper::GetProcessId() { @@ -189,10 +186,8 @@ void WebPluginDelegatePepper::SendJavaScriptStream( const GURL& url, const std::string& result, bool success, - bool notify_needed, - intptr_t notify_data) { - instance()->SendJavaScriptStream(url, result, success, notify_needed, - notify_data); + int notify_id) { + instance()->SendJavaScriptStream(url, result, success, notify_id); } void WebPluginDelegatePepper::DidReceiveManualResponse( @@ -220,22 +215,13 @@ FilePath WebPluginDelegatePepper::GetPluginPath() { } WebPluginResourceClient* WebPluginDelegatePepper::CreateResourceClient( - unsigned long resource_id, const GURL& url, bool notify_needed, - intptr_t notify_data, intptr_t existing_stream) { - // Stream already exists. This typically happens for range requests - // initiated via NPN_RequestRead. - if (existing_stream) { - NPAPI::PluginStream* plugin_stream = - reinterpret_cast<NPAPI::PluginStream*>(existing_stream); - - return plugin_stream->AsResourceClient(); - } + unsigned long resource_id, const GURL& url, int notify_id) { + return instance()->CreateStream(resource_id, url, std::string(), notify_id); +} - std::string mime_type; - NPAPI::PluginStreamUrl *stream = instance()->CreateStream( - resource_id, url, mime_type, notify_needed, - reinterpret_cast<void*>(notify_data)); - return stream; +WebPluginResourceClient* WebPluginDelegatePepper::CreateSeekableResourceClient( + unsigned long resource_id, int range_request_id) { + return instance()->GetRangeRequest(range_request_id); } NPError WebPluginDelegatePepper::Device2DQueryCapability(int32 capability, diff --git a/chrome/renderer/webplugin_delegate_pepper.h b/chrome/renderer/webplugin_delegate_pepper.h index b2ac3c6..b316789 100644 --- a/chrome/renderer/webplugin_delegate_pepper.h +++ b/chrome/renderer/webplugin_delegate_pepper.h @@ -53,12 +53,12 @@ class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate { WebKit::WebCursorInfo* cursor); virtual NPObject* GetPluginScriptableObject(); virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason, - intptr_t notify_data); + int notify_id); virtual int GetProcessId(); virtual void SendJavaScriptStream(const GURL& url, const std::string& result, - bool success, bool notify_needed, - intptr_t notify_data); + bool success, + int notify_id); virtual void DidReceiveManualResponse(const GURL& url, const std::string& mime_type, const std::string& headers, @@ -69,11 +69,9 @@ class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate { virtual void DidManualLoadFail(); virtual void InstallMissingPlugin(); virtual webkit_glue::WebPluginResourceClient* CreateResourceClient( - unsigned long resource_id, - const GURL& url, - bool notify_needed, - intptr_t notify_data, - intptr_t stream); + unsigned long resource_id, const GURL& url, int notify_id); + virtual webkit_glue::WebPluginResourceClient* CreateSeekableResourceClient( + unsigned long resource_id, int range_request_id); // WebPlugin2DDeviceDelegate implementation. virtual NPError Device2DQueryCapability(int32 capability, int32* value); diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 5cfe049..83666d5 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -66,31 +66,24 @@ class ResourceClientProxy : public webkit_glue::WebPluginResourceClient { public: ResourceClientProxy(PluginChannelHost* channel, int instance_id) : channel_(channel), instance_id_(instance_id), resource_id_(0), - notify_needed_(false), notify_data_(0), multibyte_response_expected_(false) { } ~ResourceClientProxy() { } - void Initialize(unsigned long resource_id, const GURL& url, - bool notify_needed, intptr_t notify_data, - intptr_t existing_stream) { + void Initialize(unsigned long resource_id, const GURL& url, int notify_id) { resource_id_ = resource_id; - url_ = url; - notify_needed_ = notify_needed; - notify_data_ = notify_data; - - PluginMsg_URLRequestReply_Params params; - params.resource_id = resource_id; - params.url = url_; - params.notify_needed = notify_needed_; - params.notify_data = notify_data_; - params.stream = existing_stream; - - multibyte_response_expected_ = (existing_stream != 0); + channel_->Send(new PluginMsg_HandleURLRequestReply( + instance_id_, resource_id, url, notify_id)); + } - channel_->Send(new PluginMsg_HandleURLRequestReply(instance_id_, params)); + void InitializeForSeekableStream(unsigned long resource_id, + int range_request_id) { + resource_id_ = resource_id; + multibyte_response_expected_ = true; + channel_->Send(new PluginMsg_HTTPRangeRequestReply( + instance_id_, resource_id, range_request_id)); } // PluginResourceClient implementation: @@ -154,9 +147,6 @@ class ResourceClientProxy : public webkit_glue::WebPluginResourceClient { scoped_refptr<PluginChannelHost> channel_; int instance_id_; unsigned long resource_id_; - GURL url_; - bool notify_needed_; - intptr_t notify_data_; // Set to true if the response expected is a multibyte response. // For e.g. response for a HTTP byte range request. bool multibyte_response_expected_; @@ -314,13 +304,9 @@ bool WebPluginDelegateProxy::Send(IPC::Message* msg) { void WebPluginDelegateProxy::SendJavaScriptStream(const GURL& url, const std::string& result, bool success, - bool notify_needed, - intptr_t notify_data) { - PluginMsg_SendJavaScriptStream* msg = - new PluginMsg_SendJavaScriptStream(instance_id_, url, result, - success, notify_needed, - notify_data); - Send(msg); + int notify_id) { + Send(new PluginMsg_SendJavaScriptStream( + instance_id_, url, result, success, notify_id)); } void WebPluginDelegateProxy::DidReceiveManualResponse( @@ -823,9 +809,7 @@ NPObject* WebPluginDelegateProxy::GetPluginScriptableObject() { return WebBindings::retainObject(npobject_); int route_id = MSG_ROUTING_NONE; - intptr_t npobject_ptr; - Send(new PluginMsg_GetPluginScriptableObject( - instance_id_, &route_id, &npobject_ptr)); + Send(new PluginMsg_GetPluginScriptableObject(instance_id_, &route_id)); if (route_id == MSG_ROUTING_NONE) return NULL; @@ -836,9 +820,9 @@ NPObject* WebPluginDelegateProxy::GetPluginScriptableObject() { } void WebPluginDelegateProxy::DidFinishLoadWithReason( - const GURL& url, NPReason reason, intptr_t notify_data) { + const GURL& url, NPReason reason, int notify_id) { Send(new PluginMsg_DidFinishLoadWithReason( - instance_id_, url, reason, notify_data)); + instance_id_, url, reason, notify_id)); } void WebPluginDelegateProxy::SetFocus() { @@ -909,7 +893,7 @@ void WebPluginDelegateProxy::OnInvalidateRect(const gfx::Rect& rect) { } void WebPluginDelegateProxy::OnGetWindowScriptNPObject( - int route_id, bool* success, intptr_t* npobject_ptr) { + int route_id, bool* success) { *success = false; NPObject* npobject = NULL; if (plugin_) @@ -923,11 +907,9 @@ void WebPluginDelegateProxy::OnGetWindowScriptNPObject( window_script_object_ = (new NPObjectStub( npobject, channel_host_.get(), route_id, 0, page_url_))->AsWeakPtr(); *success = true; - *npobject_ptr = reinterpret_cast<intptr_t>(npobject); } -void WebPluginDelegateProxy::OnGetPluginElement( - int route_id, bool* success, intptr_t* npobject_ptr) { +void WebPluginDelegateProxy::OnGetPluginElement(int route_id, bool* success) { *success = false; NPObject* npobject = NULL; if (plugin_) @@ -940,7 +922,6 @@ void WebPluginDelegateProxy::OnGetPluginElement( new NPObjectStub( npobject, channel_host_.get(), route_id, 0, page_url_); *success = true; - *npobject_ptr = reinterpret_cast<intptr_t>(npobject); } void WebPluginDelegateProxy::OnSetCookie(const GURL& url, @@ -1155,24 +1136,33 @@ void WebPluginDelegateProxy::OnHandleURLRequest( if (params.target.length()) target = params.target.c_str(); - plugin_->HandleURLRequest(params.method.c_str(), - params.is_javascript_url, target, - static_cast<unsigned int>(params.buffer.size()), - data, params.is_file_data, params.notify, - params.url.c_str(), params.notify_data, - params.popups_allowed); + plugin_->HandleURLRequest( + params.url.c_str(), params.method.c_str(), target, data, + static_cast<unsigned int>(params.buffer.size()), params.notify_id, + params.popups_allowed); } webkit_glue::WebPluginResourceClient* WebPluginDelegateProxy::CreateResourceClient( - unsigned long resource_id, const GURL& url, bool notify_needed, - intptr_t notify_data, intptr_t npstream) { + unsigned long resource_id, const GURL& url, int notify_id) { + if (!channel_host_) + return NULL; + + ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, + instance_id_); + proxy->Initialize(resource_id, url, notify_id); + return proxy; +} + +webkit_glue::WebPluginResourceClient* +WebPluginDelegateProxy::CreateSeekableResourceClient( + unsigned long resource_id, int range_request_id) { if (!channel_host_) return NULL; ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, instance_id_); - proxy->Initialize(resource_id, url, notify_needed, notify_data, npstream); + proxy->InitializeForSeekableStream(resource_id, range_request_id); return proxy; } @@ -1195,11 +1185,11 @@ void WebPluginDelegateProxy::OnCancelDocumentLoad() { } void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( - const std::string& url, const std::string& range_info, - intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { - plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), - existing_stream, notify_needed, - notify_data); + const std::string& url, + const std::string& range_info, + int range_request_id) { + plugin_->InitiateHTTPRangeRequest( + url.c_str(), range_info.c_str(), range_request_id); } void WebPluginDelegateProxy::OnDeferResourceLoading(unsigned long resource_id, diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index c884c9f..510f977 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -65,7 +65,7 @@ class WebPluginDelegateProxy virtual void Print(gfx::NativeDrawingContext context); virtual NPObject* GetPluginScriptableObject(); virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason, - intptr_t notify_data); + int notify_id); virtual void SetFocus(); virtual bool HandleInputEvent(const WebKit::WebInputEvent& event, WebKit::WebCursorInfo* cursor); @@ -80,8 +80,8 @@ class WebPluginDelegateProxy virtual void SendJavaScriptStream(const GURL& url, const std::string& result, - bool success, bool notify_needed, - intptr_t notify_data); + bool success, + int notify_id); virtual void DidReceiveManualResponse(const GURL& url, const std::string& mime_type, @@ -93,11 +93,9 @@ class WebPluginDelegateProxy virtual void DidManualLoadFail(); virtual void InstallMissingPlugin(); virtual webkit_glue::WebPluginResourceClient* CreateResourceClient( - unsigned long resource_id, - const GURL& url, - bool notify_needed, - intptr_t notify_data, - intptr_t existing_stream); + unsigned long resource_id, const GURL& url, int notify_id); + virtual webkit_glue::WebPluginResourceClient* CreateSeekableResourceClient( + unsigned long resource_id, int range_request_id); CommandBufferProxy* CreateCommandBuffer(); @@ -117,9 +115,8 @@ class WebPluginDelegateProxy void OnHandleURLRequest(const PluginHostMsg_URLRequest_Params& params); void OnCancelResource(int id); void OnInvalidateRect(const gfx::Rect& rect); - void OnGetWindowScriptNPObject(int route_id, bool* success, - intptr_t* npobject_ptr); - void OnGetPluginElement(int route_id, bool* success, intptr_t* npobject_ptr); + void OnGetWindowScriptNPObject(int route_id, bool* success); + void OnGetPluginElement(int route_id, bool* success); void OnSetCookie(const GURL& url, const GURL& first_party_for_cookies, const std::string& cookie); @@ -137,9 +134,7 @@ class WebPluginDelegateProxy void OnCancelDocumentLoad(); void OnInitiateHTTPRangeRequest(const std::string& url, const std::string& range_info, - intptr_t existing_stream, - bool notify_needed, - intptr_t notify_data); + int range_request_id); void OnDeferResourceLoading(unsigned long resource_id, bool defer); #if defined(OS_MACOSX) |