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

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

Issue 10014013: Add a hang monitor for Pepper plugins (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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/host_dispatcher.h ('k') | ppapi/proxy/ppapi_proxy_test.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 "ppapi/proxy/host_dispatcher.h" 5 #include "ppapi/proxy/host_dispatcher.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 private: 57 private:
58 bool* var_; 58 bool* var_;
59 bool old_value_; 59 bool old_value_;
60 }; 60 };
61 61
62 } // namespace 62 } // namespace
63 63
64 HostDispatcher::HostDispatcher(base::ProcessHandle remote_process_handle, 64 HostDispatcher::HostDispatcher(base::ProcessHandle remote_process_handle,
65 PP_Module module, 65 PP_Module module,
66 GetInterfaceFunc local_get_interface) 66 GetInterfaceFunc local_get_interface,
67 SyncMessageStatusReceiver* sync_status)
67 : Dispatcher(remote_process_handle, local_get_interface), 68 : Dispatcher(remote_process_handle, local_get_interface),
69 sync_status_(sync_status),
68 pp_module_(module), 70 pp_module_(module),
69 ppb_proxy_(NULL), 71 ppb_proxy_(NULL),
70 allow_plugin_reentrancy_(false) { 72 allow_plugin_reentrancy_(false) {
71 if (!g_module_to_dispatcher) 73 if (!g_module_to_dispatcher)
72 g_module_to_dispatcher = new ModuleToDispatcherMap; 74 g_module_to_dispatcher = new ModuleToDispatcherMap;
73 (*g_module_to_dispatcher)[pp_module_] = this; 75 (*g_module_to_dispatcher)[pp_module_] = this;
74 76
75 SetSerializationRules(new HostVarSerializationRules); 77 SetSerializationRules(new HostVarSerializationRules);
76 78
77 ppb_proxy_ = reinterpret_cast<const PPB_Proxy_Private*>( 79 ppb_proxy_ = reinterpret_cast<const PPB_Proxy_Private*>(
78 local_get_interface(PPB_PROXY_PRIVATE_INTERFACE)); 80 local_get_interface(PPB_PROXY_PRIVATE_INTERFACE));
79 DCHECK(ppb_proxy_) << "The proxy interface should always be supported."; 81 DCHECK(ppb_proxy_) << "The proxy interface should always be supported.";
80 82
81 ppb_proxy_->SetReserveInstanceIDCallback(pp_module_, &ReserveInstanceID); 83 ppb_proxy_->SetReserveInstanceIDCallback(pp_module_, &ReserveInstanceID);
82 } 84 }
83 85
84 HostDispatcher::~HostDispatcher() { 86 HostDispatcher::~HostDispatcher() {
85 g_module_to_dispatcher->erase(pp_module_); 87 g_module_to_dispatcher->erase(pp_module_);
86 } 88 }
87 89
88 bool HostDispatcher::InitHostWithChannel( 90 bool HostDispatcher::InitHostWithChannel(
89 Delegate* delegate, 91 Delegate* delegate,
90 const IPC::ChannelHandle& channel_handle, 92 const IPC::ChannelHandle& channel_handle,
91 bool is_client, 93 bool is_client,
92 const ppapi::Preferences& preferences) { 94 const ppapi::Preferences& preferences) {
93 if (!Dispatcher::InitWithChannel(delegate, channel_handle, is_client)) 95 if (!Dispatcher::InitWithChannel(delegate, channel_handle, is_client))
94 return false; 96 return false;
97 AddIOThreadMessageFilter(sync_status_.get());
98
95 Send(new PpapiMsg_SetPreferences(preferences)); 99 Send(new PpapiMsg_SetPreferences(preferences));
96 return true; 100 return true;
97 } 101 }
98 102
99 // static 103 // static
100 HostDispatcher* HostDispatcher::GetForInstance(PP_Instance instance) { 104 HostDispatcher* HostDispatcher::GetForInstance(PP_Instance instance) {
101 if (!g_instance_to_dispatcher) 105 if (!g_instance_to_dispatcher)
102 return NULL; 106 return NULL;
103 InstanceToDispatcherMap::iterator found = g_instance_to_dispatcher->find( 107 InstanceToDispatcherMap::iterator found = g_instance_to_dispatcher->find(
104 instance); 108 instance);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if (msg->is_sync()) { 149 if (msg->is_sync()) {
146 // Don't allow sending sync messages during module shutdown. Seee the "else" 150 // Don't allow sending sync messages during module shutdown. Seee the "else"
147 // block below for why. 151 // block below for why.
148 CHECK(!PP_ToBool(ppb_proxy()->IsInModuleDestructor(pp_module()))); 152 CHECK(!PP_ToBool(ppb_proxy()->IsInModuleDestructor(pp_module())));
149 153
150 // Prevent the dispatcher from going away during sync calls. Scenarios 154 // Prevent the dispatcher from going away during sync calls. Scenarios
151 // where this could happen include a Send for a sync message which while 155 // where this could happen include a Send for a sync message which while
152 // waiting for the reply, dispatches an incoming ExecuteScript call which 156 // waiting for the reply, dispatches an incoming ExecuteScript call which
153 // destroys the plugin module and in turn the dispatcher. 157 // destroys the plugin module and in turn the dispatcher.
154 ScopedModuleReference scoped_ref(this); 158 ScopedModuleReference scoped_ref(this);
155 return Dispatcher::Send(msg); 159
160 sync_status_->BeginBlockOnSyncMessage();
161 bool result = Dispatcher::Send(msg);
162 sync_status_->EndBlockOnSyncMessage();
163
164 return result;
156 } else { 165 } else {
157 // We don't want to have a scoped ref for async message cases since since 166 // We don't want to have a scoped ref for async message cases since since
158 // async messages are sent during module desruction. In this case, the 167 // async messages are sent during module desruction. In this case, the
159 // module will have a 0 refcount and addrefing and releasing it will 168 // module will have a 0 refcount and addrefing and releasing it will
160 // reenter the destructor and it will crash. 169 // reenter the destructor and it will crash.
161 return Dispatcher::Send(msg); 170 return Dispatcher::Send(msg);
162 } 171 }
163 } 172 }
164 173
165 bool HostDispatcher::OnMessageReceived(const IPC::Message& msg) { 174 bool HostDispatcher::OnMessageReceived(const IPC::Message& msg) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 dispatcher_ = static_cast<HostDispatcher*>(dispatcher); 253 dispatcher_ = static_cast<HostDispatcher*>(dispatcher);
245 dispatcher_->ppb_proxy()->AddRefModule(dispatcher_->pp_module()); 254 dispatcher_->ppb_proxy()->AddRefModule(dispatcher_->pp_module());
246 } 255 }
247 256
248 ScopedModuleReference::~ScopedModuleReference() { 257 ScopedModuleReference::~ScopedModuleReference() {
249 dispatcher_->ppb_proxy()->ReleaseModule(dispatcher_->pp_module()); 258 dispatcher_->ppb_proxy()->ReleaseModule(dispatcher_->pp_module());
250 } 259 }
251 260
252 } // namespace proxy 261 } // namespace proxy
253 } // namespace ppapi 262 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/host_dispatcher.h ('k') | ppapi/proxy/ppapi_proxy_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698