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

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

Issue 6493004: Implement basic crash detection and shutdown handling for out of process PPAP... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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/plugin_dispatcher.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/logging.h" 9 #include "base/logging.h"
10 #include "ppapi/c/private/ppb_proxy_private.h"
10 #include "ppapi/c/dev/ppb_var_deprecated.h" 11 #include "ppapi/c/dev/ppb_var_deprecated.h"
11 #include "ppapi/proxy/host_var_serialization_rules.h" 12 #include "ppapi/proxy/host_var_serialization_rules.h"
12 #include "ppapi/proxy/ppapi_messages.h" 13 #include "ppapi/proxy/ppapi_messages.h"
13 14
14 namespace pp { 15 namespace pp {
15 namespace proxy { 16 namespace proxy {
16 17
17 namespace { 18 namespace {
18 19
19 typedef std::map<PP_Instance, HostDispatcher*> InstanceToDispatcherMap; 20 typedef std::map<PP_Instance, HostDispatcher*> InstanceToDispatcherMap;
20 InstanceToDispatcherMap* g_instance_to_dispatcher = NULL; 21 InstanceToDispatcherMap* g_instance_to_dispatcher = NULL;
21 22
22 } // namespace 23 } // namespace
23 24
24 HostDispatcher::HostDispatcher(base::ProcessHandle remote_process_handle, 25 HostDispatcher::HostDispatcher(base::ProcessHandle remote_process_handle,
25 PP_Module module, 26 PP_Module module,
26 GetInterfaceFunc local_get_interface) 27 GetInterfaceFunc local_get_interface)
27 : Dispatcher(remote_process_handle, local_get_interface) { 28 : Dispatcher(remote_process_handle, local_get_interface),
28 set_pp_module(module); 29 pp_module_(module),
30 ppb_proxy_(NULL) {
29 const PPB_Var_Deprecated* var_interface = 31 const PPB_Var_Deprecated* var_interface =
30 static_cast<const PPB_Var_Deprecated*>( 32 static_cast<const PPB_Var_Deprecated*>(
31 local_get_interface(PPB_VAR_DEPRECATED_INTERFACE)); 33 local_get_interface(PPB_VAR_DEPRECATED_INTERFACE));
32 SetSerializationRules(new HostVarSerializationRules(var_interface, module)); 34 SetSerializationRules(new HostVarSerializationRules(var_interface, module));
33 35
34 memset(plugin_interface_support_, 0, 36 memset(plugin_interface_support_, 0,
35 sizeof(PluginInterfaceSupport) * INTERFACE_ID_COUNT); 37 sizeof(PluginInterfaceSupport) * INTERFACE_ID_COUNT);
36 } 38 }
37 39
38 HostDispatcher::~HostDispatcher() { 40 HostDispatcher::~HostDispatcher() {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 104 }
103 105
104 proxy = info->create_proxy(this, local_interface); 106 proxy = info->create_proxy(this, local_interface);
105 target_proxies_[info->id].reset(proxy); 107 target_proxies_[info->id].reset(proxy);
106 } 108 }
107 109
108 return proxy->OnMessageReceived(msg); 110 return proxy->OnMessageReceived(msg);
109 } 111 }
110 112
111 void HostDispatcher::OnChannelError() { 113 void HostDispatcher::OnChannelError() {
112 // TODO(brettw) plugin has crashed, handle this. 114 Dispatcher::OnChannelError(); // Stop using the channel.
115
116 // Tell the host about the crash so it can clean up.
117 GetPPBProxy()->PluginCrashed(pp_module());
113 } 118 }
114 119
115 const void* HostDispatcher::GetProxiedInterface(const std::string& interface) { 120 const void* HostDispatcher::GetProxiedInterface(const std::string& interface) {
116 // First see if we even have a proxy for this interface. 121 // First see if we even have a proxy for this interface.
117 const InterfaceProxy::Info* info = GetPPPInterfaceInfo(interface); 122 const InterfaceProxy::Info* info = GetPPPInterfaceInfo(interface);
118 if (!info) 123 if (!info)
119 return NULL; 124 return NULL;
120 125
121 if (plugin_interface_support_[static_cast<int>(info->id)] != 126 if (plugin_interface_support_[static_cast<int>(info->id)] !=
122 INTERFACE_UNQUERIED) { 127 INTERFACE_UNQUERIED) {
123 // Already queried the plugin if it supports this interface. 128 // Already queried the plugin if it supports this interface.
124 if (plugin_interface_support_[info->id] == INTERFACE_SUPPORTED) 129 if (plugin_interface_support_[info->id] == INTERFACE_SUPPORTED)
125 return info->interface; 130 return info->interface;
126 return NULL; 131 return NULL;
127 } 132 }
128 133
129 // Need to re-query. Cache the result so we only do this once. 134 // Need to re-query. Cache the result so we only do this once.
130 bool supported = false; 135 bool supported = false;
131 Send(new PpapiMsg_SupportsInterface(interface, &supported)); 136 Send(new PpapiMsg_SupportsInterface(interface, &supported));
132 plugin_interface_support_[static_cast<int>(info->id)] = 137 plugin_interface_support_[static_cast<int>(info->id)] =
133 supported ? INTERFACE_SUPPORTED : INTERFACE_UNSUPPORTED; 138 supported ? INTERFACE_SUPPORTED : INTERFACE_UNSUPPORTED;
134 139
135 if (supported) 140 if (supported)
136 return info->interface; 141 return info->interface;
137 return NULL; 142 return NULL;
138 } 143 }
139 144
145 const PPB_Proxy_Private* HostDispatcher::GetPPBProxy() {
146 if (!ppb_proxy_) {
147 ppb_proxy_ = reinterpret_cast<const PPB_Proxy_Private*>(
148 GetLocalInterface(PPB_PROXY_PRIVATE_INTERFACE));
149 }
150 return ppb_proxy_;
151 }
152
140 } // namespace proxy 153 } // namespace proxy
141 } // namespace pp 154 } // namespace pp
142 155
OLDNEW
« no previous file with comments | « ppapi/proxy/host_dispatcher.h ('k') | ppapi/proxy/plugin_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698