diff options
author | ddorwin@chromium.org <ddorwin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-17 00:13:22 +0000 |
---|---|---|
committer | ddorwin@chromium.org <ddorwin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-17 00:13:22 +0000 |
commit | ae971c2c0dea23a076b4320b0eaba69d2636ff4e (patch) | |
tree | fb3d3591130f13f4e6205c0b363dc09b5fd91d32 /webkit/plugins | |
parent | a3eba772e8722dd01052827357bba24656fbf651 (diff) | |
download | chromium_src-ae971c2c0dea23a076b4320b0eaba69d2636ff4e.zip chromium_src-ae971c2c0dea23a076b4320b0eaba69d2636ff4e.tar.gz chromium_src-ae971c2c0dea23a076b4320b0eaba69d2636ff4e.tar.bz2 |
Implemented PPB_Broker_Proxy.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6833002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81888 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/ppb_broker_impl.cc | 25 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_broker_impl.h | 1 |
2 files changed, 18 insertions, 8 deletions
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.cc b/webkit/plugins/ppapi/ppb_broker_impl.cc index 83912c5..959830a 100644 --- a/webkit/plugins/ppapi/ppb_broker_impl.cc +++ b/webkit/plugins/ppapi/ppb_broker_impl.cc @@ -59,6 +59,18 @@ const PPB_BrokerTrusted ppb_brokertrusted = { &GetHandle, }; +// TODO(ddorwin): Put conversion functions in a common place and/or add an +// invalid value to sync_socket.h. +int32_t PlatformFileToInt(base::PlatformFile handle) { +#if defined(OS_WIN) + return static_cast<int32_t>(reinterpret_cast<intptr_t>(handle)); +#elif defined(OS_POSIX) + return handle; +#else + #error Not implemented. +#endif +} + } // namespace // PPB_Broker_Impl ------------------------------------------------------ @@ -67,7 +79,7 @@ PPB_Broker_Impl::PPB_Broker_Impl(PluginInstance* instance) : Resource(instance), broker_(NULL), connect_callback_(), - pipe_handle_(0) { + pipe_handle_(PlatformFileToInt(base::kInvalidPlatformFileValue)) { } PPB_Broker_Impl::~PPB_Broker_Impl() { @@ -76,8 +88,8 @@ PPB_Broker_Impl::~PPB_Broker_Impl() { broker_ = NULL; } - // TODO(ddorwin): Should the plugin or Chrome free the handle? - pipe_handle_ = 0; + // The plugin owns the handle. + pipe_handle_ = PlatformFileToInt(base::kInvalidPlatformFileValue); } const PPB_BrokerTrusted* PPB_Broker_Impl::GetTrustedInterface() { @@ -108,10 +120,6 @@ int32_t PPB_Broker_Impl::Connect( int32_t PPB_Broker_Impl::GetHandle(int32_t* handle) { *handle = pipe_handle_; - - if (!*handle) - return PP_ERROR_FAILED; - return PP_OK; } @@ -119,6 +127,7 @@ PPB_Broker_Impl* PPB_Broker_Impl::AsPPB_Broker_Impl() { return this; } +// Transfers ownership of the handle to the plugin. void PPB_Broker_Impl::BrokerConnected(int32_t handle) { DCHECK(handle); pipe_handle_ = handle; @@ -128,7 +137,7 @@ void PPB_Broker_Impl::BrokerConnected(int32_t handle) { scoped_refptr<TrackedCompletionCallback> callback; callback.swap(connect_callback_); - callback->Run(0); // Will complete abortively if necessary. + callback->Run(PP_OK); // Will complete abortively if necessary. } } // namespace ppapi diff --git a/webkit/plugins/ppapi/ppb_broker_impl.h b/webkit/plugins/ppapi/ppb_broker_impl.h index 66454b9..2e7b0b6 100644 --- a/webkit/plugins/ppapi/ppb_broker_impl.h +++ b/webkit/plugins/ppapi/ppb_broker_impl.h @@ -44,6 +44,7 @@ class PPB_Broker_Impl : public Resource { scoped_refptr<TrackedCompletionCallback> connect_callback_; // Pipe handle for the plugin instance to use to communicate with the broker. + // Never owned by this object. int32_t pipe_handle_; DISALLOW_COPY_AND_ASSIGN(PPB_Broker_Impl); |