OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/ppapi_plugin/ppapi_thread.h" | 5 #include "content/ppapi_plugin/ppapi_thread.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/cpu.h" | 10 #include "base/cpu.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 } | 195 } |
196 #endif | 196 #endif |
197 | 197 |
198 DCHECK(peer_pid != base::kNullProcessId); | 198 DCHECK(peer_pid != base::kNullProcessId); |
199 return BrokerGetFileHandleForProcess(handle, peer_pid, should_close_source); | 199 return BrokerGetFileHandleForProcess(handle, peer_pid, should_close_source); |
200 } | 200 } |
201 | 201 |
202 base::SharedMemoryHandle PpapiThread::ShareSharedMemoryHandleWithRemote( | 202 base::SharedMemoryHandle PpapiThread::ShareSharedMemoryHandleWithRemote( |
203 const base::SharedMemoryHandle& handle, | 203 const base::SharedMemoryHandle& handle, |
204 base::ProcessId remote_pid) { | 204 base::ProcessId remote_pid) { |
205 base::PlatformFile local_platform_file = | 205 #if defined(OS_WIN) |
206 #if defined(OS_POSIX) | 206 if (peer_handle_.IsValid()) { |
207 handle.fd; | 207 DCHECK(is_broker_); |
208 #elif defined(OS_WIN) | 208 return IPC::GetFileHandleForProcess(handle, peer_handle_.Get(), false); |
209 handle; | 209 } |
210 #endif | |
211 | |
212 DCHECK(remote_pid != base::kNullProcessId); | |
213 #if defined(OS_WIN) || defined(OS_MACOSX) | |
214 base::SharedMemoryHandle duped_handle; | |
piman
2015/06/03 17:44:44
nit: just initialize this with base::SharedMemory:
erikchen
2015/06/03 17:58:31
Your suggestion saves 3 lines of code, but it make
| |
215 bool success = | |
216 BrokerDuplicateSharedMemoryHandle(handle, remote_pid, &duped_handle); | |
217 if (success) | |
218 return duped_handle; | |
219 return base::SharedMemory::NULLHandle(); | |
210 #else | 220 #else |
211 #error Not implemented. | 221 return base::SharedMemory::DuplicateHandle(handle); |
212 #endif | 222 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
213 return PpapiThread::ShareHandleWithRemote(local_platform_file, remote_pid, | |
214 false); | |
215 } | 223 } |
216 | 224 |
217 std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { | 225 std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { |
218 return &globally_seen_instance_ids_; | 226 return &globally_seen_instance_ids_; |
219 } | 227 } |
220 | 228 |
221 IPC::Sender* PpapiThread::GetBrowserSender() { | 229 IPC::Sender* PpapiThread::GetBrowserSender() { |
222 return this; | 230 return this; |
223 } | 231 } |
224 | 232 |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
572 std::string("Plugin.Ppapi") + (is_broker_ ? "Broker" : "Plugin") + | 580 std::string("Plugin.Ppapi") + (is_broker_ ? "Broker" : "Plugin") + |
573 "LoadErrorCode_" + path.BaseName().MaybeAsASCII(); | 581 "LoadErrorCode_" + path.BaseName().MaybeAsASCII(); |
574 | 582 |
575 // For sparse histograms, we can use the macro, as it does not incorporate a | 583 // For sparse histograms, we can use the macro, as it does not incorporate a |
576 // static. | 584 // static. |
577 UMA_HISTOGRAM_SPARSE_SLOWLY(histogram_name, error.code); | 585 UMA_HISTOGRAM_SPARSE_SLOWLY(histogram_name, error.code); |
578 #endif | 586 #endif |
579 } | 587 } |
580 | 588 |
581 } // namespace content | 589 } // namespace content |
OLD | NEW |