Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: ppapi/proxy/plugin_main_nacl.cc

Issue 111563006: Test Keeping NaCl plugins used in app background pages alive when active. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « extensions/browser/process_manager.cc ('k') | ppapi/shared_impl/ppapi_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 // Need to include this before most other files because it defines 9 // Need to include this before most other files because it defines
10 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define 10 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define
11 // IPC_MESSAGE_MACROS_LOG_ENABLED so ppapi_messages.h will generate the 11 // IPC_MESSAGE_MACROS_LOG_ENABLED so ppapi_messages.h will generate the
12 // ViewMsgLog et al. functions. 12 // ViewMsgLog et al. functions.
13 13
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/strings/string_number_conversions.h"
16 #include "base/synchronization/waitable_event.h" 17 #include "base/synchronization/waitable_event.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "components/tracing/child_trace_message_filter.h" 19 #include "components/tracing/child_trace_message_filter.h"
19 #include "ipc/ipc_channel_handle.h" 20 #include "ipc/ipc_channel_handle.h"
20 #include "ipc/ipc_logging.h" 21 #include "ipc/ipc_logging.h"
21 #include "ipc/ipc_message.h" 22 #include "ipc/ipc_message.h"
22 #include "native_client/src/shared/srpc/nacl_srpc.h" 23 #include "native_client/src/shared/srpc/nacl_srpc.h"
23 #include "native_client/src/untrusted/irt/irt_ppapi.h" 24 #include "native_client/src/untrusted/irt/irt_ppapi.h"
24 #include "ppapi/c/ppp.h" 25 #include "ppapi/c/ppp.h"
25 #include "ppapi/c/ppp_instance.h" 26 #include "ppapi/c/ppp_instance.h"
26 #include "ppapi/native_client/src/shared/ppapi_proxy/ppruntime.h" 27 #include "ppapi/native_client/src/shared/ppapi_proxy/ppruntime.h"
27 #include "ppapi/proxy/plugin_dispatcher.h" 28 #include "ppapi/proxy/plugin_dispatcher.h"
28 #include "ppapi/proxy/plugin_globals.h" 29 #include "ppapi/proxy/plugin_globals.h"
29 #include "ppapi/proxy/plugin_message_filter.h" 30 #include "ppapi/proxy/plugin_message_filter.h"
30 #include "ppapi/proxy/plugin_proxy_delegate.h" 31 #include "ppapi/proxy/plugin_proxy_delegate.h"
31 #include "ppapi/proxy/resource_reply_thread_registrar.h" 32 #include "ppapi/proxy/resource_reply_thread_registrar.h"
33 #include "ppapi/shared_impl/ppapi_switches.h"
32 #include "ppapi/shared_impl/ppb_audio_shared.h" 34 #include "ppapi/shared_impl/ppb_audio_shared.h"
33 35
34 #if defined(IPC_MESSAGE_LOG_ENABLED) 36 #if defined(IPC_MESSAGE_LOG_ENABLED)
35 #include "base/containers/hash_tables.h" 37 #include "base/containers/hash_tables.h"
36 38
37 LogFunctionMap g_log_function_mapping; 39 LogFunctionMap g_log_function_mapping;
38 40
39 #define IPC_MESSAGE_MACROS_LOG_ENABLED 41 #define IPC_MESSAGE_MACROS_LOG_ENABLED
40 #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \ 42 #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
41 g_log_function_mapping[msg_id] = logger 43 g_log_function_mapping[msg_id] = logger
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 90
89 // IPC::Listener implementation. 91 // IPC::Listener implementation.
90 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 92 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
91 93
92 private: 94 private:
93 void OnMsgCreateNaClChannel(int renderer_id, 95 void OnMsgCreateNaClChannel(int renderer_id,
94 const ppapi::PpapiNaClChannelArgs& args, 96 const ppapi::PpapiNaClChannelArgs& args,
95 SerializedHandle handle); 97 SerializedHandle handle);
96 void OnPluginDispatcherMessageReceived(const IPC::Message& msg); 98 void OnPluginDispatcherMessageReceived(const IPC::Message& msg);
97 99
100 void SetPpapiKeepAliveThrottleFromCommandLine();
101
98 std::set<PP_Instance> instances_; 102 std::set<PP_Instance> instances_;
99 std::map<uint32, PluginDispatcher*> plugin_dispatchers_; 103 std::map<uint32, PluginDispatcher*> plugin_dispatchers_;
100 uint32 next_plugin_dispatcher_id_; 104 uint32 next_plugin_dispatcher_id_;
101 scoped_refptr<base::MessageLoopProxy> message_loop_; 105 scoped_refptr<base::MessageLoopProxy> message_loop_;
102 base::WaitableEvent shutdown_event_; 106 base::WaitableEvent shutdown_event_;
103 }; 107 };
104 108
105 PpapiDispatcher::PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop) 109 PpapiDispatcher::PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop)
106 : next_plugin_dispatcher_id_(0), 110 : next_plugin_dispatcher_id_(0),
107 message_loop_(io_loop), 111 message_loop_(io_loop),
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (!command_line_and_logging_initialized) { 205 if (!command_line_and_logging_initialized) {
202 CommandLine::Init(0, NULL); 206 CommandLine::Init(0, NULL);
203 for (size_t i = 0; i < args.switch_names.size(); ++i) { 207 for (size_t i = 0; i < args.switch_names.size(); ++i) {
204 DCHECK(i < args.switch_values.size()); 208 DCHECK(i < args.switch_values.size());
205 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 209 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
206 args.switch_names[i], args.switch_values[i]); 210 args.switch_names[i], args.switch_values[i]);
207 } 211 }
208 logging::LoggingSettings settings; 212 logging::LoggingSettings settings;
209 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 213 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
210 logging::InitLogging(settings); 214 logging::InitLogging(settings);
215 SetPpapiKeepAliveThrottleFromCommandLine();
211 command_line_and_logging_initialized = true; 216 command_line_and_logging_initialized = true;
212 } 217 }
213 // Tell the process-global GetInterface which interfaces it can return to the 218 // Tell the process-global GetInterface which interfaces it can return to the
214 // plugin. 219 // plugin.
215 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions( 220 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions(
216 args.permissions); 221 args.permissions);
217 ppapi::proxy::InterfaceList::SetSupportsDevChannel( 222 ppapi::proxy::InterfaceList::SetSupportsDevChannel(
218 args.supports_dev_channel); 223 args.supports_dev_channel);
219 224
220 int32_t error = ::PPP_InitializeModule( 225 int32_t error = ::PPP_InitializeModule(
(...skipping 24 matching lines...) Expand all
245 if (!msg.ReadUInt32(&iter, &id)) { 250 if (!msg.ReadUInt32(&iter, &id)) {
246 NOTREACHED(); 251 NOTREACHED();
247 return; 252 return;
248 } 253 }
249 std::map<uint32, ppapi::proxy::PluginDispatcher*>::iterator dispatcher = 254 std::map<uint32, ppapi::proxy::PluginDispatcher*>::iterator dispatcher =
250 plugin_dispatchers_.find(id); 255 plugin_dispatchers_.find(id);
251 if (dispatcher != plugin_dispatchers_.end()) 256 if (dispatcher != plugin_dispatchers_.end())
252 dispatcher->second->OnMessageReceived(msg); 257 dispatcher->second->OnMessageReceived(msg);
253 } 258 }
254 259
260 void PpapiDispatcher::SetPpapiKeepAliveThrottleFromCommandLine() {
261 unsigned keepalive_throttle_interval_milliseconds = 0;
262 if (base::StringToUint(
263 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
264 switches::kPpapiKeepAliveThrottle),
265 &keepalive_throttle_interval_milliseconds)) {
266 ppapi::proxy::PluginGlobals::Get()->
267 set_keepalive_throttle_interval_milliseconds(
268 keepalive_throttle_interval_milliseconds);
269 }
270 }
271
255 } // namespace 272 } // namespace
256 273
257 void PpapiPluginRegisterThreadCreator( 274 void PpapiPluginRegisterThreadCreator(
258 const struct PP_ThreadFunctions* thread_functions) { 275 const struct PP_ThreadFunctions* thread_functions) {
259 // Initialize all classes that need to create threads that call back into 276 // Initialize all classes that need to create threads that call back into
260 // user code. 277 // user code.
261 ppapi::PPB_Audio_Shared::SetThreadFunctions(thread_functions); 278 ppapi::PPB_Audio_Shared::SetThreadFunctions(thread_functions);
262 } 279 }
263 280
264 int PpapiPluginMain() { 281 int PpapiPluginMain() {
(...skipping 16 matching lines...) Expand all
281 return 1; 298 return 1;
282 } 299 }
283 300
284 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); 301 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy());
285 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); 302 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher);
286 303
287 loop.Run(); 304 loop.Run();
288 305
289 return 0; 306 return 0;
290 } 307 }
OLDNEW
« no previous file with comments | « extensions/browser/process_manager.cc ('k') | ppapi/shared_impl/ppapi_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698