diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-18 01:50:31 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-18 01:50:31 +0000 |
commit | 9ca245e3b2d0e2271c7124d3aceb8179903718e2 (patch) | |
tree | aa5fdbad23bd9a91cb117c1610064242d8a00985 /webkit | |
parent | a2f013ebcd62eae5238ca4ee84b9d21e34197fd8 (diff) | |
download | chromium_src-9ca245e3b2d0e2271c7124d3aceb8179903718e2.zip chromium_src-9ca245e3b2d0e2271c7124d3aceb8179903718e2.tar.gz chromium_src-9ca245e3b2d0e2271c7124d3aceb8179903718e2.tar.bz2 |
Implement a proxy for URL util. Some of the implementation that doesn't need to
be proxied moved into a new shared_impl file, which required a decent amount of
glue to make it callable from both the implementation and the proxy. The payoff
here is only marginal since the code is fairly simple, but I decided this is
still better than duplication.
This also includes some comments from my audio patch that I forgot in that CL.
BUG=none
TEST=ppapi_tests run out of process pass
Review URL: http://codereview.chromium.org/6676045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78646 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/ppapi/plugin_delegate.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_audio_impl.cc | 6 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_audio_impl.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_url_util_impl.cc | 93 |
4 files changed, 42 insertions, 63 deletions
diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index f8185cf..1effed1 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -226,7 +226,8 @@ class PluginDelegate { virtual PlatformVideoDecoder* CreateVideoDecoder( const PP_VideoDecoderConfig_Dev& decoder_config) = 0; - // The caller will own the pointer returned from this. + // The caller is responsible for calling Shutdown() on the returned pointer + // to clean up the corresponding resources allocated during this call. virtual PlatformAudio* CreateAudio(uint32_t sample_rate, uint32_t sample_count, PlatformAudio::Client* client) = 0; diff --git a/webkit/plugins/ppapi/ppb_audio_impl.cc b/webkit/plugins/ppapi/ppb_audio_impl.cc index 1a36e70..0d4f852 100644 --- a/webkit/plugins/ppapi/ppb_audio_impl.cc +++ b/webkit/plugins/ppapi/ppb_audio_impl.cc @@ -220,7 +220,11 @@ PPB_Audio_Impl::PPB_Audio_Impl(PluginInstance* instance) } PPB_Audio_Impl::~PPB_Audio_Impl() { - // Calling ShutDown() makes sure StreamCreated cannot be called anymore. + // Calling ShutDown() makes sure StreamCreated cannot be called anymore and + // releases the audio data associated with the pointer. Note however, that + // until ShutDown returns, StreamCreated may still be called. This will be + // OK since we'll just immediately clean up the data it stored later in this + // destructor. if (audio_) { audio_->ShutDown(); audio_ = NULL; diff --git a/webkit/plugins/ppapi/ppb_audio_impl.h b/webkit/plugins/ppapi/ppb_audio_impl.h index cc0c112..9590034 100644 --- a/webkit/plugins/ppapi/ppb_audio_impl.h +++ b/webkit/plugins/ppapi/ppb_audio_impl.h @@ -81,7 +81,8 @@ class PPB_Audio_Impl : public Resource, // AudioConfig used for creating this Audio object. scoped_refptr<PPB_AudioConfig_Impl> config_; - // PluginDelegate audio object that we delegate audio IPC through. + // PluginDelegate audio object that we delegate audio IPC through. We don't + // own this pointer but are responsible for calling Shutdown on it. PluginDelegate::PlatformAudio* audio_; // Is a create callback pending to fire? diff --git a/webkit/plugins/ppapi/ppb_url_util_impl.cc b/webkit/plugins/ppapi/ppb_url_util_impl.cc index 4faf30f..674dafd 100644 --- a/webkit/plugins/ppapi/ppb_url_util_impl.cc +++ b/webkit/plugins/ppapi/ppb_url_util_impl.cc @@ -6,6 +6,8 @@ #include "googleurl/src/gurl.h" #include "ppapi/c/dev/ppb_url_util_dev.h" +#include "ppapi/c/ppb_var.h" +#include "ppapi/shared_impl/url_util_impl.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" @@ -14,6 +16,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" #include "webkit/plugins/ppapi/common.h" +#include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/resource_tracker.h" #include "webkit/plugins/ppapi/string.h" @@ -22,39 +25,23 @@ namespace webkit { namespace ppapi { -namespace { +using pp::shared_impl::URLUtilImpl; -void ConvertComponent(const url_parse::Component& input, - PP_URLComponent_Dev* output) { - output->begin = input.begin; - output->len = input.len; -} +namespace { -// Output can be NULL to specify "do nothing." This rule is followed by all the -// url util functions, so we implement it once here. -void ConvertComponents(const url_parse::Parsed& input, - PP_URLComponents_Dev* output) { - if (!output) - return; - - ConvertComponent(input.scheme, &output->scheme); - ConvertComponent(input.username, &output->username); - ConvertComponent(input.password, &output->password); - ConvertComponent(input.host, &output->host); - ConvertComponent(input.port, &output->port); - ConvertComponent(input.path, &output->path); - ConvertComponent(input.query, &output->query); - ConvertComponent(input.ref, &output->ref); +// Returns the PP_Module associated with the given string, or 0 on failure. +PP_Module GetModuleFromVar(PP_Var string_var) { + scoped_refptr<StringVar> str(StringVar::FromPPVar(string_var)); + if (!str) + return 0; + return str->module()->pp_module(); } -// Used for returning the given GURL from a PPAPI function, with an optional -// out param indicating the components. -PP_Var GenerateURLReturn(PluginModule* module, const GURL& url, - PP_URLComponents_Dev* components) { - if (!url.is_valid()) - return PP_MakeNull(); - ConvertComponents(url.parsed_for_possibly_invalid_spec(), components); - return StringVar::StringToPPVar(module, url.possibly_invalid_spec()); +const std::string* StringFromVar(PP_Var var) { + scoped_refptr<StringVar> string(StringVar::FromPPVar(var)); + if (!string) + return NULL; + return &string->value(); } // Sets |*security_origin| to be the WebKit security origin associated with the @@ -77,27 +64,19 @@ bool SecurityOriginForInstance(PP_Instance instance_id, } PP_Var Canonicalize(PP_Var url, PP_URLComponents_Dev* components) { - scoped_refptr<StringVar> url_string(StringVar::FromPPVar(url)); - if (!url_string) - return PP_MakeNull(); - return GenerateURLReturn(url_string->module(), - GURL(url_string->value()), components); + return URLUtilImpl::Canonicalize(&StringFromVar, + Var::GetInterface()->VarFromUtf8, + GetModuleFromVar(url), + url, components); } PP_Var ResolveRelativeToURL(PP_Var base_url, PP_Var relative, PP_URLComponents_Dev* components) { - scoped_refptr<StringVar> base_url_string(StringVar::FromPPVar(base_url)); - scoped_refptr<StringVar> relative_string(StringVar::FromPPVar(relative)); - if (!base_url_string || !relative_string) - return PP_MakeNull(); - - GURL base_gurl(base_url_string->value()); - if (!base_gurl.is_valid()) - return PP_MakeNull(); - return GenerateURLReturn(base_url_string->module(), - base_gurl.Resolve(relative_string->value()), - components); + return URLUtilImpl::ResolveRelativeToURL(&StringFromVar, + Var::GetInterface()->VarFromUtf8, + GetModuleFromVar(base_url), + base_url, relative, components); } PP_Var ResolveRelativeToDocument(PP_Instance instance_id, @@ -113,23 +92,15 @@ PP_Var ResolveRelativeToDocument(PP_Instance instance_id, WebKit::WebElement plugin_element = instance->container()->element(); GURL document_url = plugin_element.document().baseURL(); - return GenerateURLReturn(instance->module(), - document_url.Resolve(relative_string->value()), - components); + return URLUtilImpl::GenerateURLReturn( + Var::GetInterface()->VarFromUtf8, + instance->module()->pp_module(), + document_url.Resolve(relative_string->value()), + components); } PP_Bool IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { - scoped_refptr<StringVar> url_a_string(StringVar::FromPPVar(url_a)); - scoped_refptr<StringVar> url_b_string(StringVar::FromPPVar(url_b)); - if (!url_a_string || !url_b_string) - return PP_FALSE; - - GURL gurl_a(url_a_string->value()); - GURL gurl_b(url_b_string->value()); - if (!gurl_a.is_valid() || !gurl_b.is_valid()) - return PP_FALSE; - - return BoolToPPBool(gurl_a.GetOrigin() == gurl_b.GetOrigin()); + return URLUtilImpl::IsSameSecurityOrigin(&StringFromVar, url_a, url_b); } PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) { @@ -170,7 +141,9 @@ PP_Var GetDocumentURL(PP_Instance instance_id, if (!frame) return PP_MakeNull(); - return GenerateURLReturn(instance->module(), frame->url(), components); + return URLUtilImpl::GenerateURLReturn(Var::GetInterface()->VarFromUtf8, + instance->module()->pp_module(), + frame->url(), components); } const PPB_URLUtil_Dev ppb_url_util = { |