summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerikchen <erikchen@chromium.org>2016-02-22 12:28:12 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-22 20:29:25 +0000
commita1faef23466e8786b2733c0f24902c9cc5363bfb (patch)
tree8174fb0e1984aa16d324d498bb0d9122c2a4c068
parent3a29bc21c7060ce68061dc68f2f72511730b10d7 (diff)
downloadchromium_src-a1faef23466e8786b2733c0f24902c9cc5363bfb.zip
chromium_src-a1faef23466e8786b2733c0f24902c9cc5363bfb.tar.gz
chromium_src-a1faef23466e8786b2733c0f24902c9cc5363bfb.tar.bz2
Remove the method BrokerDuplicateSharedMemoryHandle.
Now that Chrome IPC brokers SharedMemoryHandles, there is no need for consumers of Chrome IPC to manually duplicate handles into the destination process. BUG=493414 Review URL: https://codereview.chromium.org/1674123002 Cr-Commit-Position: refs/heads/master@{#376797}
-rw-r--r--content/common/gpu/client/gpu_channel_host.cc19
-rw-r--r--content/common/sandbox_init_mac.cc8
-rw-r--r--content/common/sandbox_init_win.cc15
-rw-r--r--content/ppapi_plugin/ppapi_thread.cc19
-rw-r--r--content/public/common/sandbox_init.h11
-rw-r--r--content/renderer/npapi/webplugin_delegate_proxy.cc5
-rw-r--r--content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc9
-rw-r--r--ppapi/proxy/ppb_image_data_proxy.cc19
-rw-r--r--ppapi/proxy/ppb_image_data_proxy.h1
-rw-r--r--ppapi/proxy/serialized_structs.h4
10 files changed, 2 insertions, 108 deletions
diff --git a/content/common/gpu/client/gpu_channel_host.cc b/content/common/gpu/client/gpu_channel_host.cc
index 58bc54e..b0aeda3 100644
--- a/content/common/gpu/client/gpu_channel_host.cc
+++ b/content/common/gpu/client/gpu_channel_host.cc
@@ -354,26 +354,7 @@ base::SharedMemoryHandle GpuChannelHost::ShareToGpuProcess(
if (IsLost())
return base::SharedMemory::NULLHandle();
-#if defined(OS_WIN) || defined(OS_MACOSX)
- // Windows and Mac need to explicitly duplicate the handle out to another
- // process.
- base::SharedMemoryHandle target_handle;
- base::ProcessId peer_pid;
- {
- AutoLock lock(context_lock_);
- if (!channel_)
- return base::SharedMemory::NULLHandle();
- peer_pid = channel_->GetPeerPID();
- }
- bool success = BrokerDuplicateSharedMemoryHandle(source_handle, peer_pid,
- &target_handle);
- if (!success)
- return base::SharedMemory::NULLHandle();
-
- return target_handle;
-#else
return base::SharedMemory::DuplicateHandle(source_handle);
-#endif // defined(OS_WIN) || defined(OS_MACOSX)
}
int32_t GpuChannelHost::ReserveTransferBufferId() {
diff --git a/content/common/sandbox_init_mac.cc b/content/common/sandbox_init_mac.cc
index c49aa80..5d088e3 100644
--- a/content/common/sandbox_init_mac.cc
+++ b/content/common/sandbox_init_mac.cc
@@ -75,12 +75,4 @@ bool InitializeSandbox() {
return InitializeSandbox(sandbox_type, allowed_dir);
}
-bool BrokerDuplicateSharedMemoryHandle(
- const base::SharedMemoryHandle& source_handle,
- base::ProcessId target_process_id,
- base::SharedMemoryHandle* target_handle) {
- *target_handle = base::SharedMemory::DuplicateHandle(source_handle);
- return base::SharedMemory::IsHandleValid(*target_handle);
-}
-
} // namespace content
diff --git a/content/common/sandbox_init_win.cc b/content/common/sandbox_init_win.cc
index 78c1fef..16e3e4a 100644
--- a/content/common/sandbox_init_win.cc
+++ b/content/common/sandbox_init_win.cc
@@ -42,19 +42,4 @@ bool InitializeSandbox(sandbox::SandboxInterfaceInfo* sandbox_info) {
return InitTargetServices(target_services);
}
-bool BrokerDuplicateSharedMemoryHandle(
- const base::SharedMemoryHandle& source_handle,
- base::ProcessId target_process_id,
- base::SharedMemoryHandle* target_handle) {
- HANDLE duped_handle;
- if (!BrokerDuplicateHandle(
- source_handle.GetHandle(), target_process_id, &duped_handle,
- FILE_MAP_READ | FILE_MAP_WRITE | SECTION_QUERY, 0)) {
- return false;
- }
-
- *target_handle = base::SharedMemoryHandle(duped_handle, target_process_id);
- return true;
-}
-
} // namespace content
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc
index f9d5cff..35d56e2 100644
--- a/content/ppapi_plugin/ppapi_thread.cc
+++ b/content/ppapi_plugin/ppapi_thread.cc
@@ -208,27 +208,8 @@ IPC::PlatformFileForTransit PpapiThread::ShareHandleWithRemote(
base::SharedMemoryHandle PpapiThread::ShareSharedMemoryHandleWithRemote(
const base::SharedMemoryHandle& handle,
base::ProcessId remote_pid) {
-#if defined(OS_WIN)
- if (peer_handle_.IsValid()) {
- DCHECK(is_broker_);
- IPC::PlatformFileForTransit platform_file = IPC::GetFileHandleForProcess(
- handle.GetHandle(), peer_handle_.Get(), false);
- base::ProcessId pid = base::GetProcId(peer_handle_.Get());
- return base::SharedMemoryHandle(platform_file, pid);
- }
-#endif
-
DCHECK(remote_pid != base::kNullProcessId);
-#if defined(OS_WIN) || defined(OS_MACOSX)
- base::SharedMemoryHandle duped_handle;
- bool success =
- BrokerDuplicateSharedMemoryHandle(handle, remote_pid, &duped_handle);
- if (success)
- return duped_handle;
- return base::SharedMemory::NULLHandle();
-#else
return base::SharedMemory::DuplicateHandle(handle);
-#endif // defined(OS_WIN) || defined(OS_MACOSX)
}
std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() {
diff --git a/content/public/common/sandbox_init.h b/content/public/common/sandbox_init.h
index 1a31233..071facda 100644
--- a/content/public/common/sandbox_init.h
+++ b/content/public/common/sandbox_init.h
@@ -28,17 +28,6 @@ struct SandboxInterfaceInfo;
namespace content {
class SandboxedProcessLauncherDelegate;
-#if defined(OS_WIN) || defined(OS_MACOSX)
-// This function allows a sandboxed process to duplicate a SharedMemoryHandle
-// to itself or to another process. The duplicated SharedMemoryHandle has the
-// same access rights as the original. Returns true on success, false
-// otherwise.
-CONTENT_EXPORT bool BrokerDuplicateSharedMemoryHandle(
- const base::SharedMemoryHandle& source_handle,
- base::ProcessId target_process_id,
- base::SharedMemoryHandle* target_handle);
-#endif // defined(OS_WIN) || defined(OS_MACOSX)
-
#if defined(OS_WIN)
// Initialize the sandbox for renderer, gpu, utility, worker, nacl, and plugin
diff --git a/content/renderer/npapi/webplugin_delegate_proxy.cc b/content/renderer/npapi/webplugin_delegate_proxy.cc
index 68a69544..2b177c0 100644
--- a/content/renderer/npapi/webplugin_delegate_proxy.cc
+++ b/content/renderer/npapi/webplugin_delegate_proxy.cc
@@ -355,11 +355,8 @@ static void CopySharedMemoryHandleForMessage(
const base::SharedMemoryHandle& handle_in,
base::SharedMemoryHandle* handle_out,
base::ProcessId peer_pid) {
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_WIN)
*handle_out = base::SharedMemory::DuplicateHandle(handle_in);
-#elif defined(OS_WIN)
- // On Windows we need to duplicate the handle for the plugin process.
- BrokerDuplicateSharedMemoryHandle(handle_in, peer_pid, handle_out);
#else
#error Shared memory copy not implemented.
#endif
diff --git a/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc b/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc
index 8b294ab..9b03415 100644
--- a/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc
+++ b/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc
@@ -40,16 +40,7 @@ base::SharedMemoryHandle
PepperProxyChannelDelegateImpl::ShareSharedMemoryHandleWithRemote(
const base::SharedMemoryHandle& handle,
base::ProcessId remote_pid) {
-#if defined(OS_WIN) || defined(OS_MACOSX)
- base::SharedMemoryHandle duped_handle;
- bool success =
- BrokerDuplicateSharedMemoryHandle(handle, remote_pid, &duped_handle);
- if (success)
- return duped_handle;
- return base::SharedMemory::NULLHandle();
-#else
return base::SharedMemory::DuplicateHandle(handle);
-#endif // defined(OS_WIN) || defined(OS_MACOSX)
}
} // namespace content
diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc
index 4142f65..5e4ebe1 100644
--- a/ppapi/proxy/ppb_image_data_proxy.cc
+++ b/ppapi/proxy/ppb_image_data_proxy.cc
@@ -376,8 +376,7 @@ PlatformImageData::PlatformImageData(const HostResource& resource,
ImageHandle handle)
: ImageData(resource, PPB_ImageData_Shared::PLATFORM, desc) {
#if defined(OS_WIN)
- transport_dib_.reset(TransportDIB::CreateWithHandle(
- base::SharedMemoryHandle(handle, base::GetCurrentProcId())));
+ transport_dib_.reset(TransportDIB::CreateWithHandle(handle));
#else
transport_dib_.reset(TransportDIB::Map(handle));
#endif // defined(OS_WIN)
@@ -420,19 +419,7 @@ SkCanvas* PlatformImageData::GetCanvas() {
// static
ImageHandle PlatformImageData::NullHandle() {
-#if defined(OS_WIN)
- return NULL;
-#else
return ImageHandle();
-#endif
-}
-
-ImageHandle PlatformImageData::HandleFromInt(int32_t i) {
-#if defined(OS_WIN)
- return reinterpret_cast<ImageHandle>(i);
-#else
- return ImageHandle(i, false);
-#endif
}
#endif // !defined(OS_NACL)
@@ -633,11 +620,7 @@ void PPB_ImageData_Proxy::OnHostMsgCreatePlatform(
desc, &image_handle, &byte_count);
result->SetHostResource(instance, resource);
if (resource) {
-#if defined(OS_WIN)
- *result_image_handle = image_handle.GetHandle();
-#else
*result_image_handle = image_handle;
-#endif
} else {
*result_image_handle = PlatformImageData::NullHandle();
}
diff --git a/ppapi/proxy/ppb_image_data_proxy.h b/ppapi/proxy/ppb_image_data_proxy.h
index 82abb4a..46fb9af 100644
--- a/ppapi/proxy/ppb_image_data_proxy.h
+++ b/ppapi/proxy/ppb_image_data_proxy.h
@@ -98,7 +98,6 @@ class PPAPI_PROXY_EXPORT PlatformImageData : public ImageData {
SkCanvas* GetCanvas() override;
static ImageHandle NullHandle();
- static ImageHandle HandleFromInt(int32_t i);
private:
scoped_ptr<TransportDIB> transport_dib_;
diff --git a/ppapi/proxy/serialized_structs.h b/ppapi/proxy/serialized_structs.h
index 3820056..bec991f 100644
--- a/ppapi/proxy/serialized_structs.h
+++ b/ppapi/proxy/serialized_structs.h
@@ -134,11 +134,7 @@ struct PPB_AudioEncodeParameters {
};
// TODO(raymes): Make ImageHandle compatible with SerializedHandle.
-#if defined(OS_WIN)
-typedef HANDLE ImageHandle;
-#else
typedef base::SharedMemoryHandle ImageHandle;
-#endif
} // namespace proxy
} // namespace ppapi