diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-27 20:28:18 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-27 20:28:18 +0000 |
commit | 246fc49935cd37deba43624861f236acc016aa48 (patch) | |
tree | 8dbc89fc8304cfa0409dc83ccb8b94b01d3def8f /ppapi/proxy/ppapi_param_traits.cc | |
parent | 906960ba1d7a27bb458fca480a20aa33c61ebdb6 (diff) | |
download | chromium_src-246fc49935cd37deba43624861f236acc016aa48.zip chromium_src-246fc49935cd37deba43624861f236acc016aa48.tar.gz chromium_src-246fc49935cd37deba43624861f236acc016aa48.tar.bz2 |
PPAPI/NaCl: Make NaClIPCAdapter transfer handles more generally
This does a couple of things:
- It defines a new wrapper for passing any kind of handle through the PPAPI proxy (SerializedHandle).
- It updates nacl_ipc_adapter to have a more general way to pick apart messages based on their static types (which include the types of all the params).
- It adds support for PPB_Graphics2D and PPB_Graphics3D to the NaCl IPC proxy (e.g., NaCl SDK examples pi_generator and tumbler work in the new proxy with this patch).
The downside is it requires pulling parts of ppapi/shared_impl and ppapi/proxy in to the NaCl Win64 build.
BUG=116317
TEST=
Review URL: https://chromiumcodereview.appspot.com/10828023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153531 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/ppapi_param_traits.cc')
-rw-r--r-- | ppapi/proxy/ppapi_param_traits.cc | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/ppapi/proxy/ppapi_param_traits.cc b/ppapi/proxy/ppapi_param_traits.cc index 87ce4fc..bcb2df0 100644 --- a/ppapi/proxy/ppapi_param_traits.cc +++ b/ppapi/proxy/ppapi_param_traits.cc @@ -312,7 +312,62 @@ void ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> >::Log( std::string* l) { } -#if !defined(OS_NACL) +// SerializedHandle ------------------------------------------------------------ + +// static +void ParamTraits<ppapi::proxy::SerializedHandle>::Write(Message* m, + const param_type& p) { + ppapi::proxy::SerializedHandle::WriteHeader(p.header(), m); + switch (p.type()) { + case ppapi::proxy::SerializedHandle::SHARED_MEMORY: + ParamTraits<base::SharedMemoryHandle>::Write(m, p.shmem()); + break; + case ppapi::proxy::SerializedHandle::SOCKET: + ParamTraits<IPC::PlatformFileForTransit>::Write(m, p.descriptor()); + break; + case ppapi::proxy::SerializedHandle::INVALID: + break; + // No default so the compiler will warn on new types. + } +} + +// static +bool ParamTraits<ppapi::proxy::SerializedHandle>::Read(const Message* m, + PickleIterator* iter, + param_type* r) { + ppapi::proxy::SerializedHandle::Header header; + if (!ppapi::proxy::SerializedHandle::ReadHeader(iter, &header)) + return false; + switch (header.type) { + case ppapi::proxy::SerializedHandle::SHARED_MEMORY: { + base::SharedMemoryHandle handle; + if (ParamTraits<base::SharedMemoryHandle>::Read(m, iter, &handle)) { + r->set_shmem(handle, header.size); + return true; + } + break; + } + case ppapi::proxy::SerializedHandle::SOCKET: { + IPC::PlatformFileForTransit socket; + if (ParamTraits<IPC::PlatformFileForTransit>::Read(m, iter, &socket)) { + r->set_socket(socket); + return true; + } + break; + } + case ppapi::proxy::SerializedHandle::INVALID: + return true; + // No default so the compiler will warn us if a new type is added. + } + return false; +} + +// static +void ParamTraits<ppapi::proxy::SerializedHandle>::Log(const param_type& p, + std::string* l) { +} + +#if !defined(OS_NACL) && !defined(NACL_WIN64) // PPBFlash_DrawGlyphs_Params -------------------------------------------------- // static void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write( @@ -507,6 +562,6 @@ bool ParamTraits<ppapi::PPB_X509Certificate_Fields>::Read(const Message* m, void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, std::string* l) { } -#endif // !defined(OS_NACL) +#endif // !defined(OS_NACL) && !defined(NACL_WIN64) } // namespace IPC |