diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-19 19:52:12 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-19 19:52:12 +0000 |
commit | 7b2f7297010c777f5adaa4b6131828a20496447a (patch) | |
tree | 67d307b8e93dd8f2f33d2268079ef33f403e104e /ppapi | |
parent | 060088c510e263ed73ed3be8d6c5a55292f9ff91 (diff) | |
download | chromium_src-7b2f7297010c777f5adaa4b6131828a20496447a.zip chromium_src-7b2f7297010c777f5adaa4b6131828a20496447a.tar.gz chromium_src-7b2f7297010c777f5adaa4b6131828a20496447a.tar.bz2 |
Convert url request info to new proxy API.
This splits out the helper functions in the in-process version to a new file: url_request_info_util. This will be moved to content/renderer when we move the url_loader.
The unit test was moved from webkit/plugins/ppapi to content/renderer/ppapi. I made it a browsertest which allowed the removal of a little boilerplate.
I had to add "internal" functions for loading stuff with just the data struct rather than a resource so the proxy doesn't have to create an in-process URLRequestInfo resource (which can't be created now when running out-of-process) just to create a request. This should be a little more efficient now anyway, and these duplicates will go away when such code moves to the new proxy design.
BUG=
Review URL: https://codereview.chromium.org/10913257
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/ppapi_proxy.gypi | 2 | ||||
-rw-r--r-- | ppapi/ppapi_shared.gypi | 4 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 10 | ||||
-rw-r--r-- | ppapi/proxy/ppb_flash_proxy.cc | 26 | ||||
-rw-r--r-- | ppapi/proxy/ppb_flash_proxy.h | 8 | ||||
-rw-r--r-- | ppapi/proxy/ppb_url_loader_proxy.cc | 21 | ||||
-rw-r--r-- | ppapi/proxy/ppb_url_loader_proxy.h | 4 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.cc | 8 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.h | 2 | ||||
-rw-r--r-- | ppapi/proxy/url_request_info_resource.cc (renamed from ppapi/shared_impl/ppb_url_request_info_shared.cc) | 107 | ||||
-rw-r--r-- | ppapi/proxy/url_request_info_resource.h | 55 | ||||
-rw-r--r-- | ppapi/shared_impl/url_request_info_data.cc | 70 | ||||
-rw-r--r-- | ppapi/shared_impl/url_request_info_data.h (renamed from ppapi/shared_impl/ppb_url_request_info_shared.h) | 65 | ||||
-rw-r--r-- | ppapi/thunk/ppb_flash_api.h | 12 | ||||
-rw-r--r-- | ppapi/thunk/ppb_url_loader_api.h | 7 | ||||
-rw-r--r-- | ppapi/thunk/ppb_url_request_info_api.h | 4 | ||||
-rw-r--r-- | ppapi/thunk/ppb_url_request_info_thunk.cc | 4 | ||||
-rw-r--r-- | ppapi/thunk/resource_creation_api.h | 4 |
18 files changed, 228 insertions, 185 deletions
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 9898a67..9f7ef25 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -153,6 +153,8 @@ 'proxy/proxy_object_var.h', 'proxy/resource_creation_proxy.cc', 'proxy/resource_creation_proxy.h', + 'proxy/url_request_info_resource.cc', + 'proxy/url_request_info_resource.h', 'proxy/var_serialization_rules.h', ], 'defines': [ diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 123ef37..25d0228 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -72,8 +72,6 @@ 'shared_impl/ppb_opengles2_shared.h', 'shared_impl/ppb_resource_array_shared.cc', 'shared_impl/ppb_resource_array_shared.h', - 'shared_impl/ppb_url_request_info_shared.cc', - 'shared_impl/ppb_url_request_info_shared.h', 'shared_impl/ppb_url_util_shared.cc', 'shared_impl/ppb_url_util_shared.h', 'shared_impl/ppb_var_shared.cc', @@ -101,6 +99,8 @@ 'shared_impl/time_conversion.h', 'shared_impl/tracked_callback.cc', 'shared_impl/tracked_callback.h', + 'shared_impl/url_request_info_data.cc', + 'shared_impl/url_request_info_data.h', 'shared_impl/var.cc', 'shared_impl/var.h', 'shared_impl/var_tracker.cc', diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index c20eb63..bd24ab2 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -46,11 +46,11 @@ #include "ppapi/shared_impl/ppb_device_ref_shared.h" #include "ppapi/shared_impl/ppb_input_event_shared.h" #include "ppapi/shared_impl/ppb_network_list_private_shared.h" -#include "ppapi/shared_impl/ppb_url_request_info_shared.h" #include "ppapi/shared_impl/ppb_view_shared.h" #include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h" #include "ppapi/shared_impl/private/ppb_host_resolver_shared.h" #include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" +#include "ppapi/shared_impl/url_request_info_data.h" #undef IPC_MESSAGE_EXPORT #define IPC_MESSAGE_EXPORT PPAPI_PROXY_EXPORT @@ -200,7 +200,7 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::HostPortPair) IPC_STRUCT_TRAITS_MEMBER(port) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(ppapi::PPB_URLRequestInfo_Data) +IPC_STRUCT_TRAITS_BEGIN(ppapi::URLRequestInfoData) IPC_STRUCT_TRAITS_MEMBER(url) IPC_STRUCT_TRAITS_MEMBER(method) IPC_STRUCT_TRAITS_MEMBER(headers) @@ -221,7 +221,7 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::PPB_URLRequestInfo_Data) IPC_STRUCT_TRAITS_MEMBER(body) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(ppapi::PPB_URLRequestInfo_Data::BodyItem) +IPC_STRUCT_TRAITS_BEGIN(ppapi::URLRequestInfoData::BodyItem) IPC_STRUCT_TRAITS_MEMBER(is_file) IPC_STRUCT_TRAITS_MEMBER(data) // Note: we don't serialize file_ref. @@ -1077,7 +1077,7 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBURLLoader_Create, ppapi::HostResource /* result */) IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBURLLoader_Open, ppapi::HostResource /* loader */, - ppapi::PPB_URLRequestInfo_Data /* request_data */) + ppapi::URLRequestInfoData /* request_data */) IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBURLLoader_FollowRedirect, ppapi::HostResource /* loader */) IPC_SYNC_MESSAGE_ROUTED1_1( @@ -1335,7 +1335,7 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlash_GetProxyForURL, ppapi::proxy::SerializedVar /* result */) IPC_SYNC_MESSAGE_ROUTED4_1(PpapiHostMsg_PPBFlash_Navigate, PP_Instance /* instance */, - ppapi::PPB_URLRequestInfo_Data /* request_data */, + ppapi::URLRequestInfoData /* request_data */, std::string /* target */, PP_Bool /* from_user_action */, int32_t /* result */) diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc index 3ea9c220..eeddaf3 100644 --- a/ppapi/proxy/ppb_flash_proxy.cc +++ b/ppapi/proxy/ppb_flash_proxy.cc @@ -202,12 +202,17 @@ int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, request_info, true); if (enter.failed()) return PP_ERROR_BADRESOURCE; + return Navigate(instance, enter.object()->GetData(), target, + from_user_action); +} +int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, + const URLRequestInfoData& data, + const char* target, + PP_Bool from_user_action) { int32_t result = PP_ERROR_FAILED; dispatcher()->Send(new PpapiHostMsg_PPBFlash_Navigate( - API_ID_PPB_FLASH, - instance, enter.object()->GetData(), target, from_user_action, - &result)); + API_ID_PPB_FLASH, instance, data, target, from_user_action, &result)); return result; } @@ -658,7 +663,7 @@ void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance, } void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, - const PPB_URLRequestInfo_Data& data, + const URLRequestInfoData& data, const std::string& target, PP_Bool from_user_action, int32_t* result) { @@ -684,19 +689,8 @@ void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, // It is safe, because it is essentially equivalent to NPN_GetURL, where Flash // would expect re-entrancy. When running in-process, it does re-enter here. host_dispatcher->set_allow_plugin_reentrancy(); - - // Make a temporary request resource. - thunk::EnterResourceCreation enter(instance); - if (enter.failed()) { - *result = PP_ERROR_FAILED; - return; - } - ScopedPPResource request_resource( - ScopedPPResource::PassRef(), - enter.functions()->CreateURLRequestInfo(instance, data)); - *result = enter_instance.functions()->GetFlashAPI()->Navigate( - instance, request_resource, target.c_str(), from_user_action); + instance, data, target.c_str(), from_user_action); } void PPB_Flash_Proxy::OnHostMsgRunMessageLoop(PP_Instance instance) { diff --git a/ppapi/proxy/ppb_flash_proxy.h b/ppapi/proxy/ppb_flash_proxy.h index 99dfabd..03ecf89 100644 --- a/ppapi/proxy/ppb_flash_proxy.h +++ b/ppapi/proxy/ppb_flash_proxy.h @@ -24,7 +24,7 @@ struct PPB_Flash_Print_1_0; namespace ppapi { -struct PPB_URLRequestInfo_Data; +struct URLRequestInfoData; namespace proxy { @@ -64,6 +64,10 @@ class PPB_Flash_Proxy : public InterfaceProxy, public PPB_Flash_Shared { PP_Resource request_info, const char* target, PP_Bool from_user_action) OVERRIDE; + virtual int32_t Navigate(PP_Instance instance, + const URLRequestInfoData& data, + const char* target, + PP_Bool from_user_action) OVERRIDE; virtual void RunMessageLoop(PP_Instance instance) OVERRIDE; virtual void QuitMessageLoop(PP_Instance instance) OVERRIDE; virtual double GetLocalTimeZoneOffset(PP_Instance instance, @@ -138,7 +142,7 @@ class PPB_Flash_Proxy : public InterfaceProxy, public PPB_Flash_Shared { const std::string& url, SerializedVarReturnValue result); void OnHostMsgNavigate(PP_Instance instance, - const PPB_URLRequestInfo_Data& data, + const URLRequestInfoData& data, const std::string& target, PP_Bool from_user_action, int32_t* result); diff --git a/ppapi/proxy/ppb_url_loader_proxy.cc b/ppapi/proxy/ppb_url_loader_proxy.cc index fbcfc17..94d8baf 100644 --- a/ppapi/proxy/ppb_url_loader_proxy.cc +++ b/ppapi/proxy/ppb_url_loader_proxy.cc @@ -27,6 +27,7 @@ #include "ppapi/shared_impl/tracked_callback.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_url_loader_api.h" +#include "ppapi/thunk/ppb_url_request_info_api.h" #include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" @@ -92,6 +93,8 @@ class URLLoader : public Resource, public PPB_URLLoader_API { // PPB_URLLoader_API implementation. virtual int32_t Open(PP_Resource request_id, scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual int32_t Open(const URLRequestInfoData& data, + scoped_refptr<TrackedCallback> callback) OVERRIDE; virtual int32_t FollowRedirect( scoped_refptr<TrackedCallback> callback) OVERRIDE; virtual PP_Bool GetUploadProgress(int64_t* bytes_sent, @@ -189,14 +192,18 @@ int32_t URLLoader::Open(PP_Resource request_id, " PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS."); return PP_ERROR_BADRESOURCE; } + return Open(enter.object()->GetData(), callback); +} +int32_t URLLoader::Open(const URLRequestInfoData& data, + scoped_refptr<TrackedCallback> callback) { if (TrackedCallback::IsPending(current_callback_)) return PP_ERROR_INPROGRESS; current_callback_ = callback; GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_Open( - API_ID_PPB_URL_LOADER, host_resource(), enter.object()->GetData())); + API_ID_PPB_URL_LOADER, host_resource(), data)); return PP_OK_COMPLETIONPENDING; } @@ -453,18 +460,10 @@ void PPB_URLLoader_Proxy::OnMsgCreate(PP_Instance instance, } void PPB_URLLoader_Proxy::OnMsgOpen(const HostResource& loader, - const PPB_URLRequestInfo_Data& data) { + const URLRequestInfoData& data) { EnterHostFromHostResourceForceCallback<PPB_URLLoader_API> enter( loader, callback_factory_, &PPB_URLLoader_Proxy::OnCallback, loader); - thunk::EnterResourceCreation enter_creation(loader.instance()); - if (enter.failed() || enter_creation.failed()) - return; - - ScopedPPResource request_resource( - ScopedPPResource::PassRef(), - enter_creation.functions()->CreateURLRequestInfo(loader.instance(), - data)); - enter.SetResult(enter.object()->Open(request_resource, enter.callback())); + enter.SetResult(enter.object()->Open(data, enter.callback())); // TODO(brettw) bug 73236 register for the status callbacks. } diff --git a/ppapi/proxy/ppb_url_loader_proxy.h b/ppapi/proxy/ppb_url_loader_proxy.h index dd0bb34..5e4e759 100644 --- a/ppapi/proxy/ppb_url_loader_proxy.h +++ b/ppapi/proxy/ppb_url_loader_proxy.h @@ -20,7 +20,7 @@ namespace ppapi { -struct PPB_URLRequestInfo_Data; +struct URLRequestInfoData; namespace proxy { @@ -58,7 +58,7 @@ class PPB_URLLoader_Proxy : public InterfaceProxy { void OnMsgCreate(PP_Instance instance, HostResource* result); void OnMsgOpen(const HostResource& loader, - const PPB_URLRequestInfo_Data& data); + const URLRequestInfoData& data); void OnMsgFollowRedirect(const HostResource& loader); void OnMsgGetResponseInfo(const HostResource& loader, HostResource* result); diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 4ed2946..7f3c809 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -38,12 +38,12 @@ #include "ppapi/proxy/ppb_video_decoder_proxy.h" #include "ppapi/proxy/ppb_x509_certificate_private_proxy.h" #include "ppapi/proxy/printing_resource.h" +#include "ppapi/proxy/url_request_info_resource.h" #include "ppapi/shared_impl/api_id.h" #include "ppapi/shared_impl/host_resource.h" #include "ppapi/shared_impl/ppb_audio_config_shared.h" #include "ppapi/shared_impl/ppb_input_event_shared.h" #include "ppapi/shared_impl/ppb_resource_array_shared.h" -#include "ppapi/shared_impl/ppb_url_request_info_shared.h" #include "ppapi/shared_impl/private/ppb_browser_font_trusted_shared.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" @@ -146,9 +146,9 @@ PP_Resource ResourceCreationProxy::CreateURLLoader(PP_Instance instance) { PP_Resource ResourceCreationProxy::CreateURLRequestInfo( PP_Instance instance, - const PPB_URLRequestInfo_Data& data) { - return (new PPB_URLRequestInfo_Shared(OBJECT_IS_PROXY, - instance, data))->GetReference(); + const URLRequestInfoData& data) { + return (new URLRequestInfoResource(GetConnection(), + instance, data))->GetReference(); } PP_Resource ResourceCreationProxy::CreateWheelInputEvent( diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index d0a0280..714441c 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -78,7 +78,7 @@ class ResourceCreationProxy : public InterfaceProxy, virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateURLRequestInfo( PP_Instance instance, - const PPB_URLRequestInfo_Data& data) OVERRIDE; + const URLRequestInfoData& data) OVERRIDE; virtual PP_Resource CreateWheelInputEvent( PP_Instance instance, PP_TimeTicks time_stamp, diff --git a/ppapi/shared_impl/ppb_url_request_info_shared.cc b/ppapi/proxy/url_request_info_resource.cc index 058b2be..19d02d7 100644 --- a/ppapi/shared_impl/ppb_url_request_info_shared.cc +++ b/ppapi/proxy/url_request_info_resource.cc @@ -2,99 +2,37 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ppapi/shared_impl/ppb_url_request_info_shared.h" +#include "ppapi/proxy/url_request_info_resource.h" -#include "base/string_util.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_file_ref_api.h" -using ppapi::thunk::EnterResourceNoLock; - namespace ppapi { +namespace proxy { -namespace { - -const int32_t kDefaultPrefetchBufferUpperThreshold = 100 * 1000 * 1000; -const int32_t kDefaultPrefetchBufferLowerThreshold = 50 * 1000 * 1000; - -} // namespace - -PPB_URLRequestInfo_Data::BodyItem::BodyItem() - : is_file(false), - start_offset(0), - number_of_bytes(-1), - expected_last_modified_time(0.0) { -} - -PPB_URLRequestInfo_Data::BodyItem::BodyItem(const std::string& data) - : is_file(false), - data(data), - start_offset(0), - number_of_bytes(-1), - expected_last_modified_time(0.0) { -} - -PPB_URLRequestInfo_Data::BodyItem::BodyItem( - Resource* file_ref, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time) - : is_file(true), - file_ref(file_ref), - file_ref_host_resource(file_ref->host_resource()), - start_offset(start_offset), - number_of_bytes(number_of_bytes), - expected_last_modified_time(expected_last_modified_time) { -} - -PPB_URLRequestInfo_Data::PPB_URLRequestInfo_Data() - : url(), - method(), - headers(), - stream_to_file(false), - follow_redirects(true), - record_download_progress(false), - record_upload_progress(false), - has_custom_referrer_url(false), - custom_referrer_url(), - allow_cross_origin_requests(false), - allow_credentials(false), - has_custom_content_transfer_encoding(false), - custom_content_transfer_encoding(), - has_custom_user_agent(false), - custom_user_agent(), - prefetch_buffer_upper_threshold(kDefaultPrefetchBufferUpperThreshold), - prefetch_buffer_lower_threshold(kDefaultPrefetchBufferLowerThreshold), - body() { -} - -PPB_URLRequestInfo_Data::~PPB_URLRequestInfo_Data() { -} - -PPB_URLRequestInfo_Shared::PPB_URLRequestInfo_Shared( - ResourceObjectType type, - PP_Instance instance, - const PPB_URLRequestInfo_Data& data) - : Resource(type, instance), +URLRequestInfoResource::URLRequestInfoResource(Connection connection, + PP_Instance instance, + const URLRequestInfoData& data) + : PluginResource(connection, instance), data_(data) { } -PPB_URLRequestInfo_Shared::~PPB_URLRequestInfo_Shared() { +URLRequestInfoResource::~URLRequestInfoResource() { } thunk::PPB_URLRequestInfo_API* -PPB_URLRequestInfo_Shared::AsPPB_URLRequestInfo_API() { +URLRequestInfoResource::AsPPB_URLRequestInfo_API() { return this; } -PP_Bool PPB_URLRequestInfo_Shared::SetProperty(PP_URLRequestProperty property, - PP_Var var) { +PP_Bool URLRequestInfoResource::SetProperty(PP_URLRequestProperty property, + PP_Var var) { // IMPORTANT: Do not do security validation of parameters at this level // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. This // code is used both in the plugin (which we don't trust) and in the renderer // (which we trust more). When running out-of-process, the plugin calls this - // function to configure the PPB_URLRequestInfo_Data, which is then sent to + // function to configure the URLRequestInfoData, which is then sent to // the renderer and *not* run through SetProperty again. // // This means that anything in the PPB_URLRequestInfo_Data needs to be @@ -131,21 +69,21 @@ PP_Bool PPB_URLRequestInfo_Shared::SetProperty(PP_URLRequestProperty property, return result; } -PP_Bool PPB_URLRequestInfo_Shared::AppendDataToBody(const void* data, - uint32_t len) { +PP_Bool URLRequestInfoResource::AppendDataToBody(const void* data, + uint32_t len) { if (len > 0) { - data_.body.push_back(PPB_URLRequestInfo_Data::BodyItem( + data_.body.push_back(URLRequestInfoData::BodyItem( std::string(static_cast<const char*>(data), len))); } return PP_TRUE; } -PP_Bool PPB_URLRequestInfo_Shared::AppendFileToBody( +PP_Bool URLRequestInfoResource::AppendFileToBody( PP_Resource file_ref, int64_t start_offset, int64_t number_of_bytes, PP_Time expected_last_modified_time) { - EnterResourceNoLock<thunk::PPB_FileRef_API> enter(file_ref, true); + thunk::EnterResourceNoLock<thunk::PPB_FileRef_API> enter(file_ref, true); if (enter.failed()) return PP_FALSE; @@ -157,7 +95,7 @@ PP_Bool PPB_URLRequestInfo_Shared::AppendFileToBody( if (start_offset < 0 || number_of_bytes < -1) return PP_FALSE; - data_.body.push_back(PPB_URLRequestInfo_Data::BodyItem( + data_.body.push_back(URLRequestInfoData::BodyItem( enter.resource(), start_offset, number_of_bytes, @@ -165,11 +103,11 @@ PP_Bool PPB_URLRequestInfo_Shared::AppendFileToBody( return PP_TRUE; } -const PPB_URLRequestInfo_Data& PPB_URLRequestInfo_Shared::GetData() const { +const URLRequestInfoData& URLRequestInfoResource::GetData() const { return data_; } -bool PPB_URLRequestInfo_Shared::SetUndefinedProperty( +bool URLRequestInfoResource::SetUndefinedProperty( PP_URLRequestProperty property) { // IMPORTANT: Do not do security validation of parameters at this level // without also adding them to PPB_URLRequestInfo_Impl::ValidateData. See @@ -192,7 +130,7 @@ bool PPB_URLRequestInfo_Shared::SetUndefinedProperty( } } -bool PPB_URLRequestInfo_Shared::SetBooleanProperty( +bool URLRequestInfoResource::SetBooleanProperty( PP_URLRequestProperty property, bool value) { // IMPORTANT: Do not do security validation of parameters at this level @@ -222,7 +160,7 @@ bool PPB_URLRequestInfo_Shared::SetBooleanProperty( } } -bool PPB_URLRequestInfo_Shared::SetIntegerProperty( +bool URLRequestInfoResource::SetIntegerProperty( PP_URLRequestProperty property, int32_t value) { // IMPORTANT: Do not do security validation of parameters at this level @@ -240,7 +178,7 @@ bool PPB_URLRequestInfo_Shared::SetIntegerProperty( } } -bool PPB_URLRequestInfo_Shared::SetStringProperty( +bool URLRequestInfoResource::SetStringProperty( PP_URLRequestProperty property, const std::string& value) { // IMPORTANT: Do not do security validation of parameters at this level @@ -273,4 +211,5 @@ bool PPB_URLRequestInfo_Shared::SetStringProperty( } } +} // namespace proxy } // namespace ppapi diff --git a/ppapi/proxy/url_request_info_resource.h b/ppapi/proxy/url_request_info_resource.h new file mode 100644 index 0000000..e3906a6 --- /dev/null +++ b/ppapi/proxy/url_request_info_resource.h @@ -0,0 +1,55 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_URL_REQUEST_INFO_RESOURCE_H_ +#define PPAPI_PROXY_URL_REQUEST_INFO_RESOURCE_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/shared_impl/url_request_info_data.h" +#include "ppapi/thunk/ppb_url_request_info_api.h" + +namespace ppapi { +namespace proxy { + +class PPAPI_PROXY_EXPORT URLRequestInfoResource + : public PluginResource, + public thunk::PPB_URLRequestInfo_API { + public: + URLRequestInfoResource(Connection connection, PP_Instance instance, + const URLRequestInfoData& data); + virtual ~URLRequestInfoResource(); + + // Resource overrides. + virtual thunk::PPB_URLRequestInfo_API* AsPPB_URLRequestInfo_API() OVERRIDE; + + // PPB_URLRequestInfo_API implementation. + virtual PP_Bool SetProperty(PP_URLRequestProperty property, + PP_Var var) OVERRIDE; + virtual PP_Bool AppendDataToBody(const void* data, uint32_t len) OVERRIDE; + virtual PP_Bool AppendFileToBody( + PP_Resource file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) OVERRIDE; + virtual const URLRequestInfoData& GetData() const OVERRIDE; + + bool SetUndefinedProperty(PP_URLRequestProperty property); + bool SetBooleanProperty(PP_URLRequestProperty property, bool value); + bool SetIntegerProperty(PP_URLRequestProperty property, int32_t value); + bool SetStringProperty(PP_URLRequestProperty property, + const std::string& value); + + private: + URLRequestInfoData data_; + + DISALLOW_COPY_AND_ASSIGN(URLRequestInfoResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_URL_REQUEST_INFO_RESOURCE_H_ diff --git a/ppapi/shared_impl/url_request_info_data.cc b/ppapi/shared_impl/url_request_info_data.cc new file mode 100644 index 0000000..8bb02a4 --- /dev/null +++ b/ppapi/shared_impl/url_request_info_data.cc @@ -0,0 +1,70 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/shared_impl/url_request_info_data.h" + +#include "ppapi/shared_impl/resource.h" + +namespace ppapi { + +namespace { + +const int32_t kDefaultPrefetchBufferUpperThreshold = 100 * 1000 * 1000; +const int32_t kDefaultPrefetchBufferLowerThreshold = 50 * 1000 * 1000; + +} // namespace + +URLRequestInfoData::BodyItem::BodyItem() + : is_file(false), + start_offset(0), + number_of_bytes(-1), + expected_last_modified_time(0.0) { +} + +URLRequestInfoData::BodyItem::BodyItem(const std::string& data) + : is_file(false), + data(data), + start_offset(0), + number_of_bytes(-1), + expected_last_modified_time(0.0) { +} + +URLRequestInfoData::BodyItem::BodyItem( + Resource* file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) + : is_file(true), + file_ref(file_ref), + file_ref_host_resource(file_ref->host_resource()), + start_offset(start_offset), + number_of_bytes(number_of_bytes), + expected_last_modified_time(expected_last_modified_time) { +} + +URLRequestInfoData::URLRequestInfoData() + : url(), + method(), + headers(), + stream_to_file(false), + follow_redirects(true), + record_download_progress(false), + record_upload_progress(false), + has_custom_referrer_url(false), + custom_referrer_url(), + allow_cross_origin_requests(false), + allow_credentials(false), + has_custom_content_transfer_encoding(false), + custom_content_transfer_encoding(), + has_custom_user_agent(false), + custom_user_agent(), + prefetch_buffer_upper_threshold(kDefaultPrefetchBufferUpperThreshold), + prefetch_buffer_lower_threshold(kDefaultPrefetchBufferLowerThreshold), + body() { +} + +URLRequestInfoData::~URLRequestInfoData() { +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_url_request_info_shared.h b/ppapi/shared_impl/url_request_info_data.h index a233708..501251a 100644 --- a/ppapi/shared_impl/ppb_url_request_info_shared.h +++ b/ppapi/shared_impl/url_request_info_data.h @@ -2,19 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ -#define PPAPI_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ +#ifndef PPAPI_SHARED_IMPL_URL_REQUEST_INFO_DATA_H_ +#define PPAPI_SHARED_IMPL_URL_REQUEST_INFO_DATA_H_ #include <string> #include <vector> -#include "base/compiler_specific.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_url_request_info_api.h" +#include "base/memory/ref_counted.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_time.h" +#include "ppapi/shared_impl/host_resource.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" namespace ppapi { -struct PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Data { +class Resource; + +struct PPAPI_SHARED_EXPORT URLRequestInfoData { struct PPAPI_SHARED_EXPORT BodyItem { BodyItem(); explicit BodyItem(const std::string& data); @@ -50,8 +54,8 @@ struct PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Data { // ppapi_messages.h }; - PPB_URLRequestInfo_Data(); - ~PPB_URLRequestInfo_Data(); + URLRequestInfoData(); + ~URLRequestInfoData(); std::string url; std::string method; @@ -88,49 +92,6 @@ struct PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Data { // ppapi_messages.h }; -class PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Shared - : public ::ppapi::Resource, - public ::ppapi::thunk::PPB_URLRequestInfo_API { - public: - PPB_URLRequestInfo_Shared(ResourceObjectType type, - PP_Instance instance, - const PPB_URLRequestInfo_Data& data); - ~PPB_URLRequestInfo_Shared(); - - // Resource overrides. - virtual thunk::PPB_URLRequestInfo_API* AsPPB_URLRequestInfo_API() OVERRIDE; - - // PPB_URLRequestInfo_API implementation. - virtual PP_Bool SetProperty(PP_URLRequestProperty property, - PP_Var var) OVERRIDE; - virtual PP_Bool AppendDataToBody(const void* data, uint32_t len) OVERRIDE; - virtual PP_Bool AppendFileToBody( - PP_Resource file_ref, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time) OVERRIDE; - virtual const PPB_URLRequestInfo_Data& GetData() const OVERRIDE; - - protected: - // Constructor used by the webkit implementation. - PPB_URLRequestInfo_Shared(PP_Instance instance, - const PPB_URLRequestInfo_Data& data); - - bool SetUndefinedProperty(PP_URLRequestProperty property); - bool SetBooleanProperty(PP_URLRequestProperty property, bool value); - bool SetIntegerProperty(PP_URLRequestProperty property, int32_t value); - bool SetStringProperty(PP_URLRequestProperty property, - const std::string& value); - - const PPB_URLRequestInfo_Data& data() const { return data_; } - PPB_URLRequestInfo_Data& data() { return data_; } - - private: - PPB_URLRequestInfo_Data data_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_URLRequestInfo_Shared); -}; - } // namespace ppapi -#endif // PPAPI_SHARED_IMPL_PPB_URL_REQUEST_INFO_SHARED_H_ +#endif // PPAPI_SHARED_IMPL_URL_REQUEST_INFO_DATA_H_ diff --git a/ppapi/thunk/ppb_flash_api.h b/ppapi/thunk/ppb_flash_api.h index 8e24e44..d39393e 100644 --- a/ppapi/thunk/ppb_flash_api.h +++ b/ppapi/thunk/ppb_flash_api.h @@ -11,6 +11,9 @@ #include "ppapi/thunk/ppapi_thunk_export.h" namespace ppapi { + +struct URLRequestInfoData; + namespace thunk { // This class collects all of the Flash interface-related APIs into one place. @@ -32,10 +35,19 @@ class PPAPI_THUNK_EXPORT PPB_Flash_API { const uint16_t glyph_indices[], const PP_Point glyph_advances[]) = 0; virtual PP_Var GetProxyForURL(PP_Instance instance, const char* url) = 0; + + // External function that takes a PPB_URLRequestInfo resource. virtual int32_t Navigate(PP_Instance instance, PP_Resource request_info, const char* target, PP_Bool from_user_action) = 0; + + // Internal navigate function that takes a URLRequestInfoData. + virtual int32_t Navigate(PP_Instance instance, + const URLRequestInfoData& data, + const char* target, + PP_Bool from_user_action) = 0; + virtual void RunMessageLoop(PP_Instance instance) = 0; virtual void QuitMessageLoop(PP_Instance instance) = 0; virtual double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) = 0; diff --git a/ppapi/thunk/ppb_url_loader_api.h b/ppapi/thunk/ppb_url_loader_api.h index be61166..f9628bb5 100644 --- a/ppapi/thunk/ppb_url_loader_api.h +++ b/ppapi/thunk/ppb_url_loader_api.h @@ -12,6 +12,7 @@ namespace ppapi { class TrackedCallback; +struct URLRequestInfoData; namespace thunk { @@ -19,8 +20,14 @@ class PPB_URLLoader_API { public: virtual ~PPB_URLLoader_API() {} + // Open given the resource ID of a PPB_URLRequestInfo resource. virtual int32_t Open(PP_Resource request_id, scoped_refptr<TrackedCallback> callback) = 0; + + // Internal open given a URLRequestInfoData. + virtual int32_t Open(const URLRequestInfoData& data, + scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t FollowRedirect(scoped_refptr<TrackedCallback> callback) = 0; virtual PP_Bool GetUploadProgress(int64_t* bytes_sent, int64_t* total_bytes_to_be_sent) = 0; diff --git a/ppapi/thunk/ppb_url_request_info_api.h b/ppapi/thunk/ppb_url_request_info_api.h index a3890b1..d9fc8c3 100644 --- a/ppapi/thunk/ppb_url_request_info_api.h +++ b/ppapi/thunk/ppb_url_request_info_api.h @@ -10,7 +10,7 @@ namespace ppapi { -struct PPB_URLRequestInfo_Data; +struct URLRequestInfoData; namespace thunk { @@ -27,7 +27,7 @@ class PPAPI_THUNK_EXPORT PPB_URLRequestInfo_API { PP_Time expected_last_modified_time) = 0; // Internal-only function for retrieving the current config. - virtual const PPB_URLRequestInfo_Data& GetData() const = 0; + virtual const URLRequestInfoData& GetData() const = 0; }; } // namespace thunk diff --git a/ppapi/thunk/ppb_url_request_info_thunk.cc b/ppapi/thunk/ppb_url_request_info_thunk.cc index 95d8b8b..19176c3 100644 --- a/ppapi/thunk/ppb_url_request_info_thunk.cc +++ b/ppapi/thunk/ppb_url_request_info_thunk.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ppapi/shared_impl/ppb_url_request_info_shared.h" +#include "ppapi/shared_impl/url_request_info_data.h" #include "ppapi/thunk/thunk.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_url_request_info_api.h" @@ -18,7 +18,7 @@ PP_Resource Create(PP_Instance instance) { if (enter.failed()) return 0; return enter.functions()->CreateURLRequestInfo( - instance, PPB_URLRequestInfo_Data()); + instance, URLRequestInfoData()); } PP_Bool IsURLRequestInfo(PP_Resource resource) { diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 5a51ea1..f513a60 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -28,7 +28,7 @@ struct PP_Size; namespace ppapi { -struct PPB_URLRequestInfo_Data; +struct URLRequestInfoData; namespace thunk { @@ -82,7 +82,7 @@ class ResourceCreationAPI { virtual PP_Resource CreateURLLoader(PP_Instance instance) = 0; virtual PP_Resource CreateURLRequestInfo( PP_Instance instance, - const PPB_URLRequestInfo_Data& data) = 0; + const URLRequestInfoData& data) = 0; virtual PP_Resource CreateWheelInputEvent( PP_Instance instance, PP_TimeTicks time_stamp, |