Merge definitions of PlatformFileToInt and IntToPlatformFile to one place.

BUG=none
TEST=normal browsing on m17


Review URL: http://codereview.chromium.org/8585013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111447 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ppapi/proxy/broker_dispatcher.cc b/ppapi/proxy/broker_dispatcher.cc
index 30cee185..c3f3b47bc 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 @@
         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 e3b9b057..9427bb34 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 @@
   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 2e5775b1..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 @@
   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..657c5f5e 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.