| 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 "ppapi/proxy/plugin_globals.h" | 5 #include "ppapi/proxy/plugin_globals.h" |
| 6 | 6 |
| 7 #include "base/task_runner.h" | 7 #include "base/task_runner.h" |
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
| 10 #include "ipc/ipc_sender.h" | 10 #include "ipc/ipc_sender.h" |
| 11 #include "ppapi/proxy/plugin_dispatcher.h" | 11 #include "ppapi/proxy/plugin_dispatcher.h" |
| 12 #include "ppapi/proxy/plugin_message_filter.h" |
| 12 #include "ppapi/proxy/plugin_proxy_delegate.h" | 13 #include "ppapi/proxy/plugin_proxy_delegate.h" |
| 13 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
| 14 #include "ppapi/proxy/ppb_message_loop_proxy.h" | 15 #include "ppapi/proxy/ppb_message_loop_proxy.h" |
| 15 #include "ppapi/proxy/resource_reply_thread_registrar.h" | 16 #include "ppapi/proxy/resource_reply_thread_registrar.h" |
| 17 #include "ppapi/proxy/udp_socket_filter.h" |
| 16 #include "ppapi/shared_impl/ppapi_constants.h" | 18 #include "ppapi/shared_impl/ppapi_constants.h" |
| 17 #include "ppapi/shared_impl/proxy_lock.h" | 19 #include "ppapi/shared_impl/proxy_lock.h" |
| 18 #include "ppapi/thunk/enter.h" | 20 #include "ppapi/thunk/enter.h" |
| 19 | 21 |
| 20 namespace ppapi { | 22 namespace ppapi { |
| 21 namespace proxy { | 23 namespace proxy { |
| 22 | 24 |
| 23 // It performs necessary locking/unlocking of the proxy lock, and forwards all | 25 // It performs necessary locking/unlocking of the proxy lock, and forwards all |
| 24 // messages to the underlying sender. | 26 // messages to the underlying sender. |
| 25 class PluginGlobals::BrowserSender : public IPC::Sender { | 27 class PluginGlobals::BrowserSender : public IPC::Sender { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 PluginGlobals* PluginGlobals::plugin_globals_ = NULL; | 54 PluginGlobals* PluginGlobals::plugin_globals_ = NULL; |
| 53 | 55 |
| 54 PluginGlobals::PluginGlobals() | 56 PluginGlobals::PluginGlobals() |
| 55 : ppapi::PpapiGlobals(), | 57 : ppapi::PpapiGlobals(), |
| 56 plugin_proxy_delegate_(NULL), | 58 plugin_proxy_delegate_(NULL), |
| 57 callback_tracker_(new CallbackTracker), | 59 callback_tracker_(new CallbackTracker), |
| 58 resource_reply_thread_registrar_( | 60 resource_reply_thread_registrar_( |
| 59 new ResourceReplyThreadRegistrar(GetMainThreadMessageLoop())), | 61 new ResourceReplyThreadRegistrar(GetMainThreadMessageLoop())), |
| 62 udp_socket_filter_(new UDPSocketFilter()), |
| 60 plugin_recently_active_(false), | 63 plugin_recently_active_(false), |
| 61 keepalive_throttle_interval_milliseconds_( | 64 keepalive_throttle_interval_milliseconds_( |
| 62 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds), | 65 ppapi::kKeepaliveThrottleIntervalDefaultMilliseconds), |
| 63 weak_factory_(this) { | 66 weak_factory_(this) { |
| 64 DCHECK(!plugin_globals_); | 67 DCHECK(!plugin_globals_); |
| 65 plugin_globals_ = this; | 68 plugin_globals_ = this; |
| 66 | 69 |
| 67 // ResourceTracker asserts that we have the lock when we add new resources, | 70 // ResourceTracker asserts that we have the lock when we add new resources, |
| 68 // so we lock when creating the MessageLoopResource even though there is no | 71 // so we lock when creating the MessageLoopResource even though there is no |
| 69 // chance of race conditions. | 72 // chance of race conditions. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 void PluginGlobals::ResetPluginProxyDelegate() { | 232 void PluginGlobals::ResetPluginProxyDelegate() { |
| 230 DCHECK(plugin_proxy_delegate_); | 233 DCHECK(plugin_proxy_delegate_); |
| 231 plugin_proxy_delegate_ = NULL; | 234 plugin_proxy_delegate_ = NULL; |
| 232 browser_sender_.reset(); | 235 browser_sender_.reset(); |
| 233 } | 236 } |
| 234 | 237 |
| 235 MessageLoopResource* PluginGlobals::loop_for_main_thread() { | 238 MessageLoopResource* PluginGlobals::loop_for_main_thread() { |
| 236 return loop_for_main_thread_.get(); | 239 return loop_for_main_thread_.get(); |
| 237 } | 240 } |
| 238 | 241 |
| 242 void PluginGlobals::RegisterResourceMessageFilters( |
| 243 ppapi::proxy::PluginMessageFilter* plugin_filter) { |
| 244 plugin_filter->AddResourceMessageFilter(udp_socket_filter_.get()); |
| 245 } |
| 246 |
| 239 void PluginGlobals::set_keepalive_throttle_interval_milliseconds(unsigned i) { | 247 void PluginGlobals::set_keepalive_throttle_interval_milliseconds(unsigned i) { |
| 240 keepalive_throttle_interval_milliseconds_ = i; | 248 keepalive_throttle_interval_milliseconds_ = i; |
| 241 } | 249 } |
| 242 | 250 |
| 243 bool PluginGlobals::IsPluginGlobals() const { | 251 bool PluginGlobals::IsPluginGlobals() const { |
| 244 return true; | 252 return true; |
| 245 } | 253 } |
| 246 | 254 |
| 247 void PluginGlobals::OnReleaseKeepaliveThrottle() { | 255 void PluginGlobals::OnReleaseKeepaliveThrottle() { |
| 248 ppapi::ProxyLock::AssertAcquiredDebugOnly(); | 256 ppapi::ProxyLock::AssertAcquiredDebugOnly(); |
| 249 plugin_recently_active_ = false; | 257 plugin_recently_active_ = false; |
| 250 } | 258 } |
| 251 | 259 |
| 252 } // namespace proxy | 260 } // namespace proxy |
| 253 } // namespace ppapi | 261 } // namespace ppapi |
| OLD | NEW |