Commit 5a77eca1 authored by xhwang@chromium.org's avatar xhwang@chromium.org

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
parent 5f903b63
......@@ -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)
......
......@@ -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',
......
......@@ -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.
......
......@@ -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)) {
......
......@@ -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)) {
......
......@@ -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.
......
// 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
// 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_
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment