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

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

Issue 197693003: Replace --ppapi-keep-alive-throttle command line switch with IPC parameter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move literal to .h to avoid static initializer Created 6 years, 9 months 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 | « ppapi/proxy/plugin_globals.cc ('k') | ppapi/proxy/ppapi_messages.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ppapi/proxy/plugin_main_irt.h" 5 #include "ppapi/proxy/plugin_main_irt.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 14 matching lines...) Expand all
25 #include "ipc/ipc_channel_handle.h" 25 #include "ipc/ipc_channel_handle.h"
26 #include "ipc/ipc_logging.h" 26 #include "ipc/ipc_logging.h"
27 #include "ipc/ipc_message.h" 27 #include "ipc/ipc_message.h"
28 #include "ppapi/c/ppp.h" 28 #include "ppapi/c/ppp.h"
29 #include "ppapi/c/ppp_instance.h" 29 #include "ppapi/c/ppp_instance.h"
30 #include "ppapi/proxy/plugin_dispatcher.h" 30 #include "ppapi/proxy/plugin_dispatcher.h"
31 #include "ppapi/proxy/plugin_globals.h" 31 #include "ppapi/proxy/plugin_globals.h"
32 #include "ppapi/proxy/plugin_message_filter.h" 32 #include "ppapi/proxy/plugin_message_filter.h"
33 #include "ppapi/proxy/plugin_proxy_delegate.h" 33 #include "ppapi/proxy/plugin_proxy_delegate.h"
34 #include "ppapi/proxy/resource_reply_thread_registrar.h" 34 #include "ppapi/proxy/resource_reply_thread_registrar.h"
35 #include "ppapi/shared_impl/ppapi_switches.h"
36 #include "ppapi/shared_impl/ppb_audio_shared.h" 35 #include "ppapi/shared_impl/ppb_audio_shared.h"
37 36
38 #if defined(__native_client__) 37 #if defined(__native_client__)
39 #include "native_client/src/public/chrome_main.h" 38 #include "native_client/src/public/chrome_main.h"
40 #include "native_client/src/shared/srpc/nacl_srpc.h" 39 #include "native_client/src/shared/srpc/nacl_srpc.h"
41 #endif 40 #endif
42 41
43 #if defined(IPC_MESSAGE_LOG_ENABLED) 42 #if defined(IPC_MESSAGE_LOG_ENABLED)
44 #include "base/containers/hash_tables.h" 43 #include "base/containers/hash_tables.h"
45 44
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 108 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
110 virtual void OnChannelError() OVERRIDE; 109 virtual void OnChannelError() OVERRIDE;
111 110
112 // IPC::Sender implementation 111 // IPC::Sender implementation
113 virtual bool Send(IPC::Message* message) OVERRIDE; 112 virtual bool Send(IPC::Message* message) OVERRIDE;
114 113
115 private: 114 private:
116 void OnMsgInitializeNaClDispatcher(const ppapi::PpapiNaClPluginArgs& args); 115 void OnMsgInitializeNaClDispatcher(const ppapi::PpapiNaClPluginArgs& args);
117 void OnPluginDispatcherMessageReceived(const IPC::Message& msg); 116 void OnPluginDispatcherMessageReceived(const IPC::Message& msg);
118 117
119 void SetPpapiKeepAliveThrottleFromCommandLine();
120
121 std::set<PP_Instance> instances_; 118 std::set<PP_Instance> instances_;
122 std::map<uint32, PluginDispatcher*> plugin_dispatchers_; 119 std::map<uint32, PluginDispatcher*> plugin_dispatchers_;
123 uint32 next_plugin_dispatcher_id_; 120 uint32 next_plugin_dispatcher_id_;
124 scoped_refptr<base::MessageLoopProxy> message_loop_; 121 scoped_refptr<base::MessageLoopProxy> message_loop_;
125 base::WaitableEvent shutdown_event_; 122 base::WaitableEvent shutdown_event_;
126 scoped_ptr<IPC::SyncChannel> channel_; 123 scoped_ptr<IPC::SyncChannel> channel_;
127 }; 124 };
128 125
129 PpapiDispatcher::PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop) 126 PpapiDispatcher::PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop)
130 : next_plugin_dispatcher_id_(0), 127 : next_plugin_dispatcher_id_(0),
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 command_line_and_logging_initialized = true; 239 command_line_and_logging_initialized = true;
243 CommandLine::Init(0, NULL); 240 CommandLine::Init(0, NULL);
244 for (size_t i = 0; i < args.switch_names.size(); ++i) { 241 for (size_t i = 0; i < args.switch_names.size(); ++i) {
245 DCHECK(i < args.switch_values.size()); 242 DCHECK(i < args.switch_values.size());
246 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 243 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
247 args.switch_names[i], args.switch_values[i]); 244 args.switch_names[i], args.switch_values[i]);
248 } 245 }
249 logging::LoggingSettings settings; 246 logging::LoggingSettings settings;
250 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 247 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
251 logging::InitLogging(settings); 248 logging::InitLogging(settings);
252 SetPpapiKeepAliveThrottleFromCommandLine(); 249
250 ppapi::proxy::PluginGlobals::Get()
251 ->set_keepalive_throttle_interval_milliseconds(
252 args.keepalive_throttle_interval_milliseconds);
253 253
254 // Tell the process-global GetInterface which interfaces it can return to the 254 // Tell the process-global GetInterface which interfaces it can return to the
255 // plugin. 255 // plugin.
256 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions( 256 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions(
257 args.permissions); 257 args.permissions);
258 258
259 int32_t error = ::PPP_InitializeModule( 259 int32_t error = ::PPP_InitializeModule(
260 0 /* module */, 260 0 /* module */,
261 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); 261 &ppapi::proxy::PluginDispatcher::GetBrowserInterface);
262 if (error) 262 if (error)
(...skipping 24 matching lines...) Expand all
287 if (!msg.ReadUInt32(&iter, &id)) { 287 if (!msg.ReadUInt32(&iter, &id)) {
288 NOTREACHED(); 288 NOTREACHED();
289 return; 289 return;
290 } 290 }
291 std::map<uint32, ppapi::proxy::PluginDispatcher*>::iterator dispatcher = 291 std::map<uint32, ppapi::proxy::PluginDispatcher*>::iterator dispatcher =
292 plugin_dispatchers_.find(id); 292 plugin_dispatchers_.find(id);
293 if (dispatcher != plugin_dispatchers_.end()) 293 if (dispatcher != plugin_dispatchers_.end())
294 dispatcher->second->OnMessageReceived(msg); 294 dispatcher->second->OnMessageReceived(msg);
295 } 295 }
296 296
297 void PpapiDispatcher::SetPpapiKeepAliveThrottleFromCommandLine() {
298 unsigned keepalive_throttle_interval_milliseconds = 0;
299 if (base::StringToUint(
300 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
301 switches::kPpapiKeepAliveThrottle),
302 &keepalive_throttle_interval_milliseconds)) {
303 ppapi::proxy::PluginGlobals::Get()->
304 set_keepalive_throttle_interval_milliseconds(
305 keepalive_throttle_interval_milliseconds);
306 }
307 }
308
309 } // namespace 297 } // namespace
310 298
311 void SetIPCFileDescriptors(int ipc_browser_fd, int ipc_renderer_fd) { 299 void SetIPCFileDescriptors(int ipc_browser_fd, int ipc_renderer_fd) {
312 g_nacl_ipc_browser_fd = ipc_browser_fd; 300 g_nacl_ipc_browser_fd = ipc_browser_fd;
313 g_nacl_ipc_renderer_fd = ipc_renderer_fd; 301 g_nacl_ipc_renderer_fd = ipc_renderer_fd;
314 } 302 }
315 303
316 void PpapiPluginRegisterThreadCreator( 304 void PpapiPluginRegisterThreadCreator(
317 const struct PP_ThreadFunctions* thread_functions) { 305 const struct PP_ThreadFunctions* thread_functions) {
318 #if defined(__native_client__) 306 #if defined(__native_client__)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 341 }
354 #endif 342 #endif
355 343
356 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); 344 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy());
357 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); 345 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher);
358 346
359 loop.Run(); 347 loop.Run();
360 348
361 return 0; 349 return 0;
362 } 350 }
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_globals.cc ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698