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 "content/ppapi_plugin/broker_process_dispatcher.h" | 5 #include "content/ppapi_plugin/broker_process_dispatcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 site_vector.clear(); | 70 site_vector.clear(); |
71 } | 71 } |
72 context->dispatcher->OnGetPermissionSettingsCompleted( | 72 context->dispatcher->OnGetPermissionSettingsCompleted( |
73 context->request_id, PP_ToBool(success), default_permission, site_vector); | 73 context->request_id, PP_ToBool(success), default_permission, site_vector); |
74 } | 74 } |
75 | 75 |
76 } // namespace | 76 } // namespace |
77 | 77 |
78 BrokerProcessDispatcher::BrokerProcessDispatcher( | 78 BrokerProcessDispatcher::BrokerProcessDispatcher( |
79 PP_GetInterface_Func get_plugin_interface, | 79 PP_GetInterface_Func get_plugin_interface, |
80 PP_ConnectInstance_Func connect_instance) | 80 PP_ConnectInstance_Func connect_instance, |
81 bool peer_is_browser) | |
81 : ppapi::proxy::BrokerSideDispatcher(connect_instance), | 82 : ppapi::proxy::BrokerSideDispatcher(connect_instance), |
82 get_plugin_interface_(get_plugin_interface), | 83 get_plugin_interface_(get_plugin_interface), |
83 flash_browser_operations_1_3_(NULL), | 84 flash_browser_operations_1_3_(NULL), |
84 flash_browser_operations_1_2_(NULL), | 85 flash_browser_operations_1_2_(NULL), |
85 flash_browser_operations_1_0_(NULL) { | 86 flash_browser_operations_1_0_(NULL), |
87 peer_is_browser_(peer_is_browser) { | |
86 if (get_plugin_interface) { | 88 if (get_plugin_interface) { |
87 flash_browser_operations_1_0_ = | 89 flash_browser_operations_1_0_ = |
88 static_cast<const PPP_Flash_BrowserOperations_1_0*>( | 90 static_cast<const PPP_Flash_BrowserOperations_1_0*>( |
89 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0)); | 91 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0)); |
90 | 92 |
91 flash_browser_operations_1_2_ = | 93 flash_browser_operations_1_2_ = |
92 static_cast<const PPP_Flash_BrowserOperations_1_2*>( | 94 static_cast<const PPP_Flash_BrowserOperations_1_2*>( |
93 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2)); | 95 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2)); |
94 | 96 |
95 flash_browser_operations_1_3_ = | 97 flash_browser_operations_1_3_ = |
96 static_cast<const PPP_Flash_BrowserOperations_1_3*>( | 98 static_cast<const PPP_Flash_BrowserOperations_1_3*>( |
97 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3)); | 99 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3)); |
98 } | 100 } |
99 } | 101 } |
100 | 102 |
101 BrokerProcessDispatcher::~BrokerProcessDispatcher() { | 103 BrokerProcessDispatcher::~BrokerProcessDispatcher() { |
102 DVLOG(1) << "BrokerProcessDispatcher::~BrokerProcessDispatcher()"; | 104 DVLOG(1) << "BrokerProcessDispatcher::~BrokerProcessDispatcher()"; |
103 // Don't free the process right away. This timer allows the child process | 105 // Don't free the process right away. This timer allows the child process |
104 // to be re-used if the user rapidly goes to a new page that requires this | 106 // to be re-used if the user rapidly goes to a new page that requires this |
105 // plugin. This is the case for common plugins where they may be used on a | 107 // plugin. This is the case for common plugins where they may be used on a |
106 // source and destination page of a navigation. We don't want to tear down | 108 // source and destination page of a navigation. We don't want to tear down |
107 // and re-start processes each time in these cases. | 109 // and re-start processes each time in these cases. |
108 process_ref_.ReleaseWithDelay( | 110 process_ref_.ReleaseWithDelay( |
109 base::TimeDelta::FromSeconds(kBrokerReleaseTimeSeconds)); | 111 base::TimeDelta::FromSeconds(kBrokerReleaseTimeSeconds)); |
110 } | 112 } |
111 | 113 |
112 bool BrokerProcessDispatcher::OnMessageReceived(const IPC::Message& msg) { | 114 bool BrokerProcessDispatcher::OnMessageReceived(const IPC::Message& msg) { |
115 if (BrokerSideDispatcher::OnMessageReceived(msg)) | |
116 return true; | |
117 | |
118 if (!peer_is_browser_) | |
jschuh
2016/06/16 21:08:36
This seems like a case where we want to terminate
yzshen1
2016/06/16 22:23:15
I agree that it would be nice if we can kill the p
| |
119 return false; | |
120 | |
121 bool handled = true; | |
113 IPC_BEGIN_MESSAGE_MAP(BrokerProcessDispatcher, msg) | 122 IPC_BEGIN_MESSAGE_MAP(BrokerProcessDispatcher, msg) |
114 IPC_MESSAGE_HANDLER(PpapiMsg_GetSitesWithData, OnGetSitesWithData) | 123 IPC_MESSAGE_HANDLER(PpapiMsg_GetSitesWithData, OnGetSitesWithData) |
115 IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnClearSiteData) | 124 IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnClearSiteData) |
116 IPC_MESSAGE_HANDLER(PpapiMsg_DeauthorizeContentLicenses, | 125 IPC_MESSAGE_HANDLER(PpapiMsg_DeauthorizeContentLicenses, |
117 OnDeauthorizeContentLicenses) | 126 OnDeauthorizeContentLicenses) |
118 IPC_MESSAGE_HANDLER(PpapiMsg_GetPermissionSettings, OnGetPermissionSettings) | 127 IPC_MESSAGE_HANDLER(PpapiMsg_GetPermissionSettings, |
128 OnGetPermissionSettings) | |
119 IPC_MESSAGE_HANDLER(PpapiMsg_SetDefaultPermission, OnSetDefaultPermission) | 129 IPC_MESSAGE_HANDLER(PpapiMsg_SetDefaultPermission, OnSetDefaultPermission) |
120 IPC_MESSAGE_HANDLER(PpapiMsg_SetSitePermission, OnSetSitePermission) | 130 IPC_MESSAGE_HANDLER(PpapiMsg_SetSitePermission, OnSetSitePermission) |
121 IPC_MESSAGE_UNHANDLED(return BrokerSideDispatcher::OnMessageReceived(msg)) | 131 IPC_MESSAGE_UNHANDLED(handled = false) |
122 IPC_END_MESSAGE_MAP() | 132 IPC_END_MESSAGE_MAP() |
123 return true; | 133 return handled; |
124 } | 134 } |
125 | 135 |
126 void BrokerProcessDispatcher::OnGetPermissionSettingsCompleted( | 136 void BrokerProcessDispatcher::OnGetPermissionSettingsCompleted( |
127 uint32_t request_id, | 137 uint32_t request_id, |
128 bool success, | 138 bool success, |
129 PP_Flash_BrowserOperations_Permission default_permission, | 139 PP_Flash_BrowserOperations_Permission default_permission, |
130 const ppapi::FlashSiteSettings& sites) { | 140 const ppapi::FlashSiteSettings& sites) { |
131 Send(new PpapiHostMsg_GetPermissionSettingsResult( | 141 Send(new PpapiHostMsg_GetPermissionSettingsResult( |
132 request_id, success, default_permission, sites)); | 142 request_id, success, default_permission, sites)); |
133 } | 143 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 data_str.c_str(), setting_type, | 332 data_str.c_str(), setting_type, |
323 static_cast<uint32_t>(sites.size()), site_array.get()); | 333 static_cast<uint32_t>(sites.size()), site_array.get()); |
324 | 334 |
325 return PP_ToBool(result); | 335 return PP_ToBool(result); |
326 } | 336 } |
327 | 337 |
328 return false; | 338 return false; |
329 } | 339 } |
330 | 340 |
331 } // namespace content | 341 } // namespace content |
OLD | NEW |