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); |
136 } | 138 } |
137 | 139 |
138 PpapiThread::~PpapiThread() { | 140 PpapiThread::~PpapiThread() { |
139 } | 141 } |
140 | 142 |
141 void PpapiThread::Shutdown() { | 143 void PpapiThread::Shutdown() { |
142 ChildThreadImpl::Shutdown(); | 144 ChildThreadImpl::Shutdown(); |
143 | 145 |
144 ppapi::proxy::PluginGlobals::Get()->ResetPluginProxyDelegate(); | 146 ppapi::proxy::PluginGlobals::Get()->ResetPluginProxyDelegate(); |
145 if (plugin_entry_points_.shutdown_module) | 147 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; | 478 volatile int* null_pointer = nullptr; |
477 *null_pointer = 0; | 479 *null_pointer = 0; |
478 } | 480 } |
479 | 481 |
480 void PpapiThread::OnHang() { | 482 void PpapiThread::OnHang() { |
481 // Intentionally hang upon the request of the browser. | 483 // Intentionally hang upon the request of the browser. |
482 for (;;) | 484 for (;;) |
483 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); | 485 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
484 } | 486 } |
485 | 487 |
| 488 void PpapiThread::OnFieldTrialGroupFinalized(const std::string& trial_name, |
| 489 const std::string& group_name) { |
| 490 // IPC to the browser process to tell it the specified trial was activated. |
| 491 Send(new PpapiHostMsg_FieldTrialActivated(trial_name)); |
| 492 } |
| 493 |
486 bool PpapiThread::SetupChannel(base::ProcessId renderer_pid, | 494 bool PpapiThread::SetupChannel(base::ProcessId renderer_pid, |
487 int renderer_child_id, | 495 int renderer_child_id, |
488 bool incognito, | 496 bool incognito, |
489 IPC::ChannelHandle* handle) { | 497 IPC::ChannelHandle* handle) { |
490 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); | 498 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); |
491 mojo::MessagePipe pipe; | 499 mojo::MessagePipe pipe; |
492 | 500 |
493 ppapi::proxy::ProxyChannel* dispatcher = NULL; | 501 ppapi::proxy::ProxyChannel* dispatcher = NULL; |
494 bool init_result = false; | 502 bool init_result = false; |
495 if (is_broker_) { | 503 if (is_broker_) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 GetHistogramName(is_broker_, "LoadTime", path), | 579 GetHistogramName(is_broker_, "LoadTime", path), |
572 base::TimeDelta::FromMilliseconds(1), | 580 base::TimeDelta::FromMilliseconds(1), |
573 base::TimeDelta::FromSeconds(10), | 581 base::TimeDelta::FromSeconds(10), |
574 50, | 582 50, |
575 base::HistogramBase::kUmaTargetedHistogramFlag); | 583 base::HistogramBase::kUmaTargetedHistogramFlag); |
576 | 584 |
577 histogram->AddTime(load_time); | 585 histogram->AddTime(load_time); |
578 } | 586 } |
579 | 587 |
580 } // namespace content | 588 } // namespace content |
OLD | NEW |