summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/renderer/pepper_plugin_delegate_impl.cc18
-rw-r--r--ppapi/ppapi_shared.gypi2
-rw-r--r--ppapi/proxy/broker_dispatcher.cc18
-rw-r--r--ppapi/proxy/ppb_audio_input_proxy.cc18
-rw-r--r--ppapi/proxy/ppb_audio_proxy.cc18
-rw-r--r--ppapi/proxy/ppb_broker_proxy.cc29
-rw-r--r--ppapi/shared_impl/platform_file.cc31
-rw-r--r--ppapi/shared_impl/platform_file.h19
-rw-r--r--webkit/plugins/ppapi/ppb_broker_impl.cc18
9 files changed, 70 insertions, 101 deletions
diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc
index ee5124a..65645f1 100644
--- a/content/renderer/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper_plugin_delegate_impl.cc
@@ -54,6 +54,7 @@
#include "ppapi/c/private/ppb_flash_net_connector.h"
#include "ppapi/proxy/host_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/platform_file.h"
#include "ppapi/shared_impl/ppapi_preferences.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserCompletion.h"
@@ -81,16 +82,6 @@ using WebKit::WebView;
namespace {
-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
-}
-
base::SyncSocket::Handle DuplicateHandle(base::SyncSocket::Handle handle) {
base::SyncSocket::Handle out_handle = base::kInvalidPlatformFileValue;
#if defined(OS_WIN)
@@ -722,7 +713,8 @@ PpapiBrokerImpl::~PpapiBrokerImpl() {
base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr = i->second;
if (weak_ptr) {
weak_ptr->BrokerConnected(
- PlatformFileToInt(base::kInvalidPlatformFileValue), PP_ERROR_ABORTED);
+ ppapi::PlatformFileToInt(base::kInvalidPlatformFileValue),
+ PP_ERROR_ABORTED);
}
}
pending_connects_.clear();
@@ -809,7 +801,7 @@ void PpapiBrokerImpl::OnBrokerChannelConnected(
base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>& weak_ptr = i->second;
if (weak_ptr) {
weak_ptr->BrokerConnected(
- PlatformFileToInt(base::kInvalidPlatformFileValue),
+ ppapi::PlatformFileToInt(base::kInvalidPlatformFileValue),
PP_ERROR_FAILED);
}
}
@@ -845,7 +837,7 @@ void PpapiBrokerImpl::ConnectPluginToBroker(
// That message handler will then call client->BrokerConnected() with the
// saved pipe handle.
// Temporarily, just call back.
- client->BrokerConnected(PlatformFileToInt(plugin_handle), result);
+ client->BrokerConnected(ppapi::PlatformFileToInt(plugin_handle), result);
}
PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderViewImpl* render_view)
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index 8565396..02bb69a 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -60,6 +60,8 @@
'shared_impl/opengles2_impl.cc',
'shared_impl/opengles2_impl.h',
'shared_impl/ppapi_globals.cc',
+ 'shared_impl/platform_file.cc',
+ 'shared_impl/platform_file.h',
'shared_impl/ppapi_globals.h',
'shared_impl/ppapi_preferences.cc',
'shared_impl/ppapi_preferences.h',
diff --git a/ppapi/proxy/broker_dispatcher.cc b/ppapi/proxy/broker_dispatcher.cc
index 30cee18..c3f3b47 100644
--- a/ppapi/proxy/broker_dispatcher.cc
+++ b/ppapi/proxy/broker_dispatcher.cc
@@ -7,24 +7,11 @@
#include "base/sync_socket.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/platform_file.h"
namespace ppapi {
namespace proxy {
-namespace {
-
-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
-
BrokerDispatcher::BrokerDispatcher(base::ProcessHandle remote_process_handle,
PP_ConnectInstance_Func connect_instance)
: ProxyChannel(remote_process_handle),
@@ -66,7 +53,8 @@ void BrokerDispatcher::OnMsgConnectToPlugin(
IPC::PlatformFileForTransitToPlatformFile(handle);
if (connect_instance_) {
- *result = connect_instance_(instance, PlatformFileToInt(socket_handle));
+ *result = connect_instance_(instance,
+ ppapi::PlatformFileToInt(socket_handle));
} else {
*result = PP_ERROR_FAILED;
// Close the handle since there is no other owner.
diff --git a/ppapi/proxy/ppb_audio_input_proxy.cc b/ppapi/proxy/ppb_audio_input_proxy.cc
index e3b9b05..9427bb3 100644
--- a/ppapi/proxy/ppb_audio_input_proxy.cc
+++ b/ppapi/proxy/ppb_audio_input_proxy.cc
@@ -16,6 +16,7 @@
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/api_id.h"
#include "ppapi/shared_impl/audio_input_impl.h"
+#include "ppapi/shared_impl/platform_file.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/thunk/enter.h"
@@ -23,6 +24,7 @@
#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
+using ppapi::IntToPlatformFile;
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_AudioInput_API;
using ppapi::thunk::PPB_AudioConfig_API;
@@ -116,22 +118,6 @@ int32_t AudioInput::GetSharedMemory(int* shm_handle, uint32_t* shm_size) {
return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface.
}
-namespace {
-
-base::PlatformFile IntToPlatformFile(int32_t handle) {
- // TODO(piman/brettw): Change trusted interface to return a PP_FileHandle,
- // those casts are ugly.
-#if defined(OS_WIN)
- return reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle));
-#elif defined(OS_POSIX)
- return handle;
-#else
- #error Not implemented.
-#endif
-}
-
-} // namespace
-
PPB_AudioInput_Proxy::PPB_AudioInput_Proxy(Dispatcher* dispatcher)
: InterfaceProxy(dispatcher),
callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
diff --git a/ppapi/proxy/ppb_audio_proxy.cc b/ppapi/proxy/ppb_audio_proxy.cc
index 2e5775b..a5bf668 100644
--- a/ppapi/proxy/ppb_audio_proxy.cc
+++ b/ppapi/proxy/ppb_audio_proxy.cc
@@ -16,6 +16,7 @@
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/api_id.h"
#include "ppapi/shared_impl/audio_impl.h"
+#include "ppapi/shared_impl/platform_file.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/thunk/ppb_audio_config_api.h"
@@ -23,6 +24,7 @@
#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
+using ppapi::IntToPlatformFile;
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_Audio_API;
using ppapi::thunk::PPB_AudioConfig_API;
@@ -115,22 +117,6 @@ int32_t Audio::GetSharedMemory(int* shm_handle, uint32_t* shm_size) {
return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface.
}
-namespace {
-
-base::PlatformFile IntToPlatformFile(int32_t handle) {
- // TODO(piman/brettw): Change trusted interface to return a PP_FileHandle,
- // those casts are ugly.
-#if defined(OS_WIN)
- return reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle));
-#elif defined(OS_POSIX)
- return handle;
-#else
- #error Not implemented.
-#endif
-}
-
-} // namespace
-
PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher)
: InterfaceProxy(dispatcher),
callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
diff --git a/ppapi/proxy/ppb_broker_proxy.cc b/ppapi/proxy/ppb_broker_proxy.cc
index d65af66..657c5f5 100644
--- a/ppapi/proxy/ppb_broker_proxy.cc
+++ b/ppapi/proxy/ppb_broker_proxy.cc
@@ -10,46 +10,25 @@
#include "ppapi/proxy/enter_proxy.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/platform_file.h"
#include "ppapi/thunk/ppb_broker_api.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
+using ppapi::IntToPlatformFile;
+using ppapi::PlatformFileToInt;
using ppapi::thunk::PPB_Broker_API;
namespace ppapi {
namespace proxy {
-namespace {
-
-base::PlatformFile IntToPlatformFile(int32_t handle) {
-#if defined(OS_WIN)
- return reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle));
-#elif defined(OS_POSIX)
- return handle;
-#else
- #error Not implemented.
-#endif
-}
-
-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
-
class Broker : public PPB_Broker_API, public Resource {
public:
explicit Broker(const HostResource& resource);
virtual ~Broker();
- // Resource overries.
+ // Resource overrides.
virtual PPB_Broker_API* AsPPB_Broker_API() OVERRIDE;
// PPB_Broker_API implementation.
diff --git a/ppapi/shared_impl/platform_file.cc b/ppapi/shared_impl/platform_file.cc
new file mode 100644
index 0000000..fe9c2ff
--- /dev/null
+++ b/ppapi/shared_impl/platform_file.cc
@@ -0,0 +1,31 @@
+// Copyright (c) 2011 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/platform_file.h"
+
+namespace ppapi {
+
+// TODO(piman/brettw): Change trusted interface to return a PP_FileHandle,
+// those casts are ugly.
+base::PlatformFile IntToPlatformFile(int32_t handle) {
+#if defined(OS_WIN)
+ return reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle));
+#elif defined(OS_POSIX)
+ return handle;
+#else
+ #error Not implemented.
+#endif
+}
+
+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 ppapi
diff --git a/ppapi/shared_impl/platform_file.h b/ppapi/shared_impl/platform_file.h
new file mode 100644
index 0000000..d2313ec
--- /dev/null
+++ b/ppapi/shared_impl/platform_file.h
@@ -0,0 +1,19 @@
+// Copyright (c) 2011 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_SHARED_IMPL_PLATFORM_FILE_H_
+#define PPAPI_SHARED_IMPL_PLATFORM_FILE_H_
+
+#include "base/platform_file.h"
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/shared_impl/ppapi_shared_export.h"
+
+namespace ppapi {
+
+PPAPI_SHARED_EXPORT base::PlatformFile IntToPlatformFile(int32_t handle);
+PPAPI_SHARED_EXPORT int32_t PlatformFileToInt(base::PlatformFile handle);
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_PLATFORM_FILE_H_
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.cc b/webkit/plugins/ppapi/ppb_broker_impl.cc
index 7d897c7..9696899 100644
--- a/webkit/plugins/ppapi/ppb_broker_impl.cc
+++ b/webkit/plugins/ppapi/ppb_broker_impl.cc
@@ -5,31 +5,17 @@
#include "webkit/plugins/ppapi/ppb_broker_impl.h"
#include "base/logging.h"
+#include "ppapi/shared_impl/platform_file.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/resource_helper.h"
+using ::ppapi::PlatformFileToInt;
using ::ppapi::thunk::PPB_Broker_API;
namespace webkit {
namespace ppapi {
-namespace {
-
-// 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 ------------------------------------------------------
PPB_Broker_Impl::PPB_Broker_Impl(PP_Instance instance)