| 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> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 namespace content { | 104 namespace content { |
| 105 | 105 |
| 106 typedef int32_t (*InitializeBrokerFunc) | 106 typedef int32_t (*InitializeBrokerFunc) |
| 107 (PP_ConnectInstance_Func* connect_instance_func); | 107 (PP_ConnectInstance_Func* connect_instance_func); |
| 108 | 108 |
| 109 PpapiThread::PpapiThread(const base::CommandLine& command_line, bool is_broker) | 109 PpapiThread::PpapiThread(const base::CommandLine& command_line, bool is_broker) |
| 110 : is_broker_(is_broker), | 110 : is_broker_(is_broker), |
| 111 plugin_globals_(GetIOTaskRunner()), | 111 plugin_globals_(GetIOTaskRunner()), |
| 112 connect_instance_func_(NULL), | 112 connect_instance_func_(NULL), |
| 113 local_pp_module_(base::RandInt(0, std::numeric_limits<PP_Module>::max())), | 113 local_pp_module_(base::RandInt(0, std::numeric_limits<PP_Module>::max())), |
| 114 next_plugin_dispatcher_id_(1) { | 114 next_plugin_dispatcher_id_(1), |
| 115 field_trial_syncer_(this) { |
| 115 plugin_globals_.SetPluginProxyDelegate(this); | 116 plugin_globals_.SetPluginProxyDelegate(this); |
| 116 plugin_globals_.set_command_line( | 117 plugin_globals_.set_command_line( |
| 117 command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs)); | 118 command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs)); |
| 118 | 119 |
| 119 blink_platform_impl_.reset(new PpapiBlinkPlatformImpl); | 120 blink_platform_impl_.reset(new PpapiBlinkPlatformImpl); |
| 120 blink::Platform::initialize(blink_platform_impl_.get()); | 121 blink::Platform::initialize(blink_platform_impl_.get()); |
| 121 | 122 |
| 122 if (!is_broker_) { | 123 if (!is_broker_) { |
| 123 scoped_refptr<ppapi::proxy::PluginMessageFilter> plugin_filter( | 124 scoped_refptr<ppapi::proxy::PluginMessageFilter> plugin_filter( |
| 124 new ppapi::proxy::PluginMessageFilter( | 125 new ppapi::proxy::PluginMessageFilter( |
| 125 NULL, plugin_globals_.resource_reply_thread_registrar())); | 126 NULL, plugin_globals_.resource_reply_thread_registrar())); |
| 126 channel()->AddFilter(plugin_filter.get()); | 127 channel()->AddFilter(plugin_filter.get()); |
| 127 plugin_globals_.RegisterResourceMessageFilters(plugin_filter.get()); | 128 plugin_globals_.RegisterResourceMessageFilters(plugin_filter.get()); |
| 128 } | 129 } |
| 129 | 130 |
| 130 // In single process, browser main loop set up the discardable memory | 131 // In single process, browser main loop set up the discardable memory |
| 131 // allocator. | 132 // allocator. |
| 132 if (!command_line.HasSwitch(switches::kSingleProcess)) { | 133 if (!command_line.HasSwitch(switches::kSingleProcess)) { |
| 133 base::DiscardableMemoryAllocator::SetInstance( | 134 base::DiscardableMemoryAllocator::SetInstance( |
| 134 ChildThreadImpl::discardable_shared_memory_manager()); | 135 ChildThreadImpl::discardable_shared_memory_manager()); |
| 135 } | 136 } |
| 137 field_trial_syncer_.InitFieldTrialObserving(command_line, |
| 138 switches::kSingleProcess); |
| 136 } | 139 } |
| 137 | 140 |
| 138 PpapiThread::~PpapiThread() { | 141 PpapiThread::~PpapiThread() { |
| 139 } | 142 } |
| 140 | 143 |
| 141 void PpapiThread::Shutdown() { | 144 void PpapiThread::Shutdown() { |
| 142 ChildThreadImpl::Shutdown(); | 145 ChildThreadImpl::Shutdown(); |
| 143 | 146 |
| 144 ppapi::proxy::PluginGlobals::Get()->ResetPluginProxyDelegate(); | 147 ppapi::proxy::PluginGlobals::Get()->ResetPluginProxyDelegate(); |
| 145 if (plugin_entry_points_.shutdown_module) | 148 if (plugin_entry_points_.shutdown_module) |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 volatile int* null_pointer = nullptr; | 479 volatile int* null_pointer = nullptr; |
| 477 *null_pointer = 0; | 480 *null_pointer = 0; |
| 478 } | 481 } |
| 479 | 482 |
| 480 void PpapiThread::OnHang() { | 483 void PpapiThread::OnHang() { |
| 481 // Intentionally hang upon the request of the browser. | 484 // Intentionally hang upon the request of the browser. |
| 482 for (;;) | 485 for (;;) |
| 483 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); | 486 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
| 484 } | 487 } |
| 485 | 488 |
| 489 void PpapiThread::OnFieldTrialGroupFinalized(const std::string& trial_name, |
| 490 const std::string& group_name) { |
| 491 // IPC to the browser process to tell it the specified trial was activated. |
| 492 Send(new PpapiHostMsg_FieldTrialActivated(trial_name)); |
| 493 } |
| 494 |
| 486 bool PpapiThread::SetupChannel(base::ProcessId renderer_pid, | 495 bool PpapiThread::SetupChannel(base::ProcessId renderer_pid, |
| 487 int renderer_child_id, | 496 int renderer_child_id, |
| 488 bool incognito, | 497 bool incognito, |
| 489 IPC::ChannelHandle* handle) { | 498 IPC::ChannelHandle* handle) { |
| 490 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); | 499 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); |
| 491 mojo::MessagePipe pipe; | 500 mojo::MessagePipe pipe; |
| 492 | 501 |
| 493 ppapi::proxy::ProxyChannel* dispatcher = NULL; | 502 ppapi::proxy::ProxyChannel* dispatcher = NULL; |
| 494 bool init_result = false; | 503 bool init_result = false; |
| 495 if (is_broker_) { | 504 if (is_broker_) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 GetHistogramName(is_broker_, "LoadTime", path), | 580 GetHistogramName(is_broker_, "LoadTime", path), |
| 572 base::TimeDelta::FromMilliseconds(1), | 581 base::TimeDelta::FromMilliseconds(1), |
| 573 base::TimeDelta::FromSeconds(10), | 582 base::TimeDelta::FromSeconds(10), |
| 574 50, | 583 50, |
| 575 base::HistogramBase::kUmaTargetedHistogramFlag); | 584 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 576 | 585 |
| 577 histogram->AddTime(load_time); | 586 histogram->AddTime(load_time); |
| 578 } | 587 } |
| 579 | 588 |
| 580 } // namespace content | 589 } // namespace content |
| OLD | NEW |