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/plugin/plugin_channel.h" | 5 #include "content/plugin/plugin_channel.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 base::AutoLock auto_lock(modal_dialog_event_map_lock_); | 60 base::AutoLock auto_lock(modal_dialog_event_map_lock_); |
61 if (!modal_dialog_event_map_.count(render_view_id)) { | 61 if (!modal_dialog_event_map_.count(render_view_id)) { |
62 NOTREACHED(); | 62 NOTREACHED(); |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 if (--(modal_dialog_event_map_[render_view_id].refcount)) | 66 if (--(modal_dialog_event_map_[render_view_id].refcount)) |
67 return; | 67 return; |
68 | 68 |
69 // Delete the event when the stack unwinds as it could be in use now. | 69 // Delete the event when the stack unwinds as it could be in use now. |
70 MessageLoop::current()->DeleteSoon( | 70 base::MessageLoop::current()->DeleteSoon( |
71 FROM_HERE, modal_dialog_event_map_[render_view_id].event); | 71 FROM_HERE, modal_dialog_event_map_[render_view_id].event); |
72 modal_dialog_event_map_.erase(render_view_id); | 72 modal_dialog_event_map_.erase(render_view_id); |
73 } | 73 } |
74 | 74 |
75 bool Send(IPC::Message* message) { | 75 bool Send(IPC::Message* message) { |
76 // Need this function for the IPC_MESSAGE_HANDLER_DELAY_REPLY macro. | 76 // Need this function for the IPC_MESSAGE_HANDLER_DELAY_REPLY macro. |
77 return channel_->Send(message); | 77 return channel_->Send(message); |
78 } | 78 } |
79 | 79 |
80 // IPC::ChannelProxy::MessageFilter: | 80 // IPC::ChannelProxy::MessageFilter: |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 int PluginChannel::GenerateRouteID() { | 193 int PluginChannel::GenerateRouteID() { |
194 static int last_id = 0; | 194 static int last_id = 0; |
195 return ++last_id; | 195 return ++last_id; |
196 } | 196 } |
197 | 197 |
198 base::WaitableEvent* PluginChannel::GetModalDialogEvent(int render_view_id) { | 198 base::WaitableEvent* PluginChannel::GetModalDialogEvent(int render_view_id) { |
199 return filter_->GetModalDialogEvent(render_view_id); | 199 return filter_->GetModalDialogEvent(render_view_id); |
200 } | 200 } |
201 | 201 |
202 PluginChannel::~PluginChannel() { | 202 PluginChannel::~PluginChannel() { |
203 MessageLoop::current()->PostDelayedTask( | 203 base::MessageLoop::current()->PostDelayedTask( |
204 FROM_HERE, | 204 FROM_HERE, |
205 base::Bind(&PluginReleaseCallback), | 205 base::Bind(&PluginReleaseCallback), |
206 base::TimeDelta::FromMinutes(kPluginReleaseTimeMinutes)); | 206 base::TimeDelta::FromMinutes(kPluginReleaseTimeMinutes)); |
207 } | 207 } |
208 | 208 |
209 void PluginChannel::CleanUp() { | 209 void PluginChannel::CleanUp() { |
210 // We need to clean up the stubs so that they call NPPDestroy. This will | 210 // We need to clean up the stubs so that they call NPPDestroy. This will |
211 // also lead to them releasing their reference on this object so that it can | 211 // also lead to them releasing their reference on this object so that it can |
212 // be deleted. | 212 // be deleted. |
213 for (size_t i = 0; i < plugin_stubs_.size(); ++i) | 213 for (size_t i = 0; i < plugin_stubs_.size(); ++i) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 scoped_refptr<MessageFilter> filter(filter_); | 273 scoped_refptr<MessageFilter> filter(filter_); |
274 int render_view_id = | 274 int render_view_id = |
275 plugin_stubs_[i]->webplugin()->host_render_view_routing_id(); | 275 plugin_stubs_[i]->webplugin()->host_render_view_routing_id(); |
276 plugin_stubs_.erase(plugin_stubs_.begin() + i); | 276 plugin_stubs_.erase(plugin_stubs_.begin() + i); |
277 Send(reply_msg); | 277 Send(reply_msg); |
278 RemoveRoute(instance_id); | 278 RemoveRoute(instance_id); |
279 // NOTE: *this* might be deleted as a result of calling RemoveRoute. | 279 // NOTE: *this* might be deleted as a result of calling RemoveRoute. |
280 // Don't release the modal dialog event right away, but do it after the | 280 // Don't release the modal dialog event right away, but do it after the |
281 // stack unwinds since the plugin can be destroyed later if it's in use | 281 // stack unwinds since the plugin can be destroyed later if it's in use |
282 // right now. | 282 // right now. |
283 MessageLoop::current()->PostNonNestableTask(FROM_HERE, base::Bind( | 283 base::MessageLoop::current()->PostNonNestableTask( |
284 &MessageFilter::ReleaseModalDialogEvent, filter.get(), | 284 FROM_HERE, |
285 render_view_id)); | 285 base::Bind(&MessageFilter::ReleaseModalDialogEvent, |
| 286 filter.get(), |
| 287 render_view_id)); |
286 return; | 288 return; |
287 } | 289 } |
288 } | 290 } |
289 | 291 |
290 NOTREACHED() << "Couldn't find WebPluginDelegateStub to destroy"; | 292 NOTREACHED() << "Couldn't find WebPluginDelegateStub to destroy"; |
291 } | 293 } |
292 | 294 |
293 void PluginChannel::OnGenerateRouteID(int* route_id) { | 295 void PluginChannel::OnGenerateRouteID(int* route_id) { |
294 *route_id = GenerateRouteID(); | 296 *route_id = GenerateRouteID(); |
295 } | 297 } |
(...skipping 16 matching lines...) Expand all Loading... |
312 : base::StringPrintf("\"%s\"", site_str); | 314 : base::StringPrintf("\"%s\"", site_str); |
313 VLOG(1) << "NPP_ClearSiteData(" << site_name << ", " << flags << ", " | 315 VLOG(1) << "NPP_ClearSiteData(" << site_name << ", " << flags << ", " |
314 << max_age << ") returned " << err; | 316 << max_age << ") returned " << err; |
315 success = (err == NPERR_NO_ERROR); | 317 success = (err == NPERR_NO_ERROR); |
316 } | 318 } |
317 } | 319 } |
318 Send(new PluginHostMsg_ClearSiteDataResult(success)); | 320 Send(new PluginHostMsg_ClearSiteDataResult(success)); |
319 } | 321 } |
320 | 322 |
321 } // namespace content | 323 } // namespace content |
OLD | NEW |