| 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 <stddef.h> |
| 8 |
| 7 #include <limits> | 9 #include <limits> |
| 8 | 10 |
| 9 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 10 #include "base/cpu.h" | 12 #include "base/cpu.h" |
| 11 #include "base/debug/alias.h" | 13 #include "base/debug/alias.h" |
| 12 #include "base/debug/crash_logging.h" | 14 #include "base/debug/crash_logging.h" |
| 13 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 14 #include "base/logging.h" | 16 #include "base/logging.h" |
| 15 #include "base/memory/discardable_memory_allocator.h" | 17 #include "base/memory/discardable_memory_allocator.h" |
| 16 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 17 #include "base/metrics/sparse_histogram.h" | 19 #include "base/metrics/sparse_histogram.h" |
| 18 #include "base/rand_util.h" | 20 #include "base/rand_util.h" |
| 19 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/threading/platform_thread.h" | 23 #include "base/threading/platform_thread.h" |
| 22 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 23 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
| 26 #include "build/build_config.h" |
| 24 #include "content/child/browser_font_resource_trusted.h" | 27 #include "content/child/browser_font_resource_trusted.h" |
| 25 #include "content/child/child_discardable_shared_memory_manager.h" | 28 #include "content/child/child_discardable_shared_memory_manager.h" |
| 26 #include "content/child/child_process.h" | 29 #include "content/child/child_process.h" |
| 27 #include "content/common/child_process_messages.h" | 30 #include "content/common/child_process_messages.h" |
| 28 #include "content/common/sandbox_util.h" | 31 #include "content/common/sandbox_util.h" |
| 29 #include "content/ppapi_plugin/broker_process_dispatcher.h" | 32 #include "content/ppapi_plugin/broker_process_dispatcher.h" |
| 30 #include "content/ppapi_plugin/plugin_process_dispatcher.h" | 33 #include "content/ppapi_plugin/plugin_process_dispatcher.h" |
| 31 #include "content/ppapi_plugin/ppapi_blink_platform_impl.h" | 34 #include "content/ppapi_plugin/ppapi_blink_platform_impl.h" |
| 32 #include "content/public/common/content_client.h" | 35 #include "content/public/common/content_client.h" |
| 33 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnLoadPlugin) | 166 IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnLoadPlugin) |
| 164 IPC_MESSAGE_HANDLER(PpapiMsg_CreateChannel, OnCreateChannel) | 167 IPC_MESSAGE_HANDLER(PpapiMsg_CreateChannel, OnCreateChannel) |
| 165 IPC_MESSAGE_HANDLER(PpapiMsg_SetNetworkState, OnSetNetworkState) | 168 IPC_MESSAGE_HANDLER(PpapiMsg_SetNetworkState, OnSetNetworkState) |
| 166 IPC_MESSAGE_HANDLER(PpapiMsg_Crash, OnCrash) | 169 IPC_MESSAGE_HANDLER(PpapiMsg_Crash, OnCrash) |
| 167 IPC_MESSAGE_HANDLER(PpapiMsg_Hang, OnHang) | 170 IPC_MESSAGE_HANDLER(PpapiMsg_Hang, OnHang) |
| 168 IPC_MESSAGE_UNHANDLED(handled = false) | 171 IPC_MESSAGE_UNHANDLED(handled = false) |
| 169 IPC_END_MESSAGE_MAP() | 172 IPC_END_MESSAGE_MAP() |
| 170 return handled; | 173 return handled; |
| 171 } | 174 } |
| 172 | 175 |
| 173 void PpapiThread::OnChannelConnected(int32 peer_pid) { | 176 void PpapiThread::OnChannelConnected(int32_t peer_pid) { |
| 174 ChildThreadImpl::OnChannelConnected(peer_pid); | 177 ChildThreadImpl::OnChannelConnected(peer_pid); |
| 175 #if defined(OS_WIN) | 178 #if defined(OS_WIN) |
| 176 if (is_broker_) | 179 if (is_broker_) |
| 177 peer_handle_.Set(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, peer_pid)); | 180 peer_handle_.Set(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, peer_pid)); |
| 178 #endif | 181 #endif |
| 179 } | 182 } |
| 180 | 183 |
| 181 base::SingleThreadTaskRunner* PpapiThread::GetIPCTaskRunner() { | 184 base::SingleThreadTaskRunner* PpapiThread::GetIPCTaskRunner() { |
| 182 return ChildProcess::current()->io_task_runner(); | 185 return ChildProcess::current()->io_task_runner(); |
| 183 } | 186 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 ppapi::proxy::Connection connection, | 258 ppapi::proxy::Connection connection, |
| 256 PP_Instance instance, | 259 PP_Instance instance, |
| 257 const PP_BrowserFont_Trusted_Description& desc, | 260 const PP_BrowserFont_Trusted_Description& desc, |
| 258 const ppapi::Preferences& prefs) { | 261 const ppapi::Preferences& prefs) { |
| 259 if (!BrowserFontResource_Trusted::IsPPFontDescriptionValid(desc)) | 262 if (!BrowserFontResource_Trusted::IsPPFontDescriptionValid(desc)) |
| 260 return 0; | 263 return 0; |
| 261 return (new BrowserFontResource_Trusted( | 264 return (new BrowserFontResource_Trusted( |
| 262 connection, instance, desc, prefs))->GetReference(); | 265 connection, instance, desc, prefs))->GetReference(); |
| 263 } | 266 } |
| 264 | 267 |
| 265 uint32 PpapiThread::Register( | 268 uint32_t PpapiThread::Register( |
| 266 ppapi::proxy::PluginDispatcher* plugin_dispatcher) { | 269 ppapi::proxy::PluginDispatcher* plugin_dispatcher) { |
| 267 if (!plugin_dispatcher || | 270 if (!plugin_dispatcher || |
| 268 plugin_dispatchers_.size() >= std::numeric_limits<uint32>::max()) { | 271 plugin_dispatchers_.size() >= std::numeric_limits<uint32_t>::max()) { |
| 269 return 0; | 272 return 0; |
| 270 } | 273 } |
| 271 | 274 |
| 272 uint32 id = 0; | 275 uint32_t id = 0; |
| 273 do { | 276 do { |
| 274 // Although it is unlikely, make sure that we won't cause any trouble when | 277 // Although it is unlikely, make sure that we won't cause any trouble when |
| 275 // the counter overflows. | 278 // the counter overflows. |
| 276 id = next_plugin_dispatcher_id_++; | 279 id = next_plugin_dispatcher_id_++; |
| 277 } while (id == 0 || | 280 } while (id == 0 || |
| 278 plugin_dispatchers_.find(id) != plugin_dispatchers_.end()); | 281 plugin_dispatchers_.find(id) != plugin_dispatchers_.end()); |
| 279 plugin_dispatchers_[id] = plugin_dispatcher; | 282 plugin_dispatchers_[id] = plugin_dispatcher; |
| 280 return id; | 283 return id; |
| 281 } | 284 } |
| 282 | 285 |
| 283 void PpapiThread::Unregister(uint32 plugin_dispatcher_id) { | 286 void PpapiThread::Unregister(uint32_t plugin_dispatcher_id) { |
| 284 plugin_dispatchers_.erase(plugin_dispatcher_id); | 287 plugin_dispatchers_.erase(plugin_dispatcher_id); |
| 285 } | 288 } |
| 286 | 289 |
| 287 void PpapiThread::OnLoadPlugin(const base::FilePath& path, | 290 void PpapiThread::OnLoadPlugin(const base::FilePath& path, |
| 288 const ppapi::PpapiPermissions& permissions) { | 291 const ppapi::PpapiPermissions& permissions) { |
| 289 // In case of crashes, the crash dump doesn't indicate which plugin | 292 // In case of crashes, the crash dump doesn't indicate which plugin |
| 290 // it came from. | 293 // it came from. |
| 291 base::debug::SetCrashKeyValue("ppapi_path", path.MaybeAsASCII()); | 294 base::debug::SetCrashKeyValue("ppapi_path", path.MaybeAsASCII()); |
| 292 | 295 |
| 293 SavePluginName(path); | 296 SavePluginName(path); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 GetHistogramName(is_broker_, "LoadTime", path), | 622 GetHistogramName(is_broker_, "LoadTime", path), |
| 620 base::TimeDelta::FromMilliseconds(1), | 623 base::TimeDelta::FromMilliseconds(1), |
| 621 base::TimeDelta::FromSeconds(10), | 624 base::TimeDelta::FromSeconds(10), |
| 622 50, | 625 50, |
| 623 base::HistogramBase::kUmaTargetedHistogramFlag); | 626 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 624 | 627 |
| 625 histogram->AddTime(load_time); | 628 histogram->AddTime(load_time); |
| 626 } | 629 } |
| 627 | 630 |
| 628 } // namespace content | 631 } // namespace content |
| OLD | NEW |