Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/plugin/plugin_channel.h" | 5 #include "chrome/plugin/plugin_channel.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lock.h" | 8 #include "base/lock.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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 scoped_refptr<WebPluginDelegateStub> stub = new WebPluginDelegateStub( | 215 scoped_refptr<WebPluginDelegateStub> stub = new WebPluginDelegateStub( |
| 216 mime_type, *instance_id, this); | 216 mime_type, *instance_id, this); |
| 217 AddRoute(*instance_id, stub, false); | 217 AddRoute(*instance_id, stub, false); |
| 218 plugin_stubs_.push_back(stub); | 218 plugin_stubs_.push_back(stub); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void PluginChannel::OnDestroyInstance(int instance_id, | 221 void PluginChannel::OnDestroyInstance(int instance_id, |
| 222 IPC::Message* reply_msg) { | 222 IPC::Message* reply_msg) { |
| 223 for (size_t i = 0; i < plugin_stubs_.size(); ++i) { | 223 for (size_t i = 0; i < plugin_stubs_.size(); ++i) { |
| 224 if (plugin_stubs_[i]->instance_id() == instance_id) { | 224 if (plugin_stubs_[i]->instance_id() == instance_id) { |
| 225 filter_->ReleaseModalDialogEvent( | 225 scoped_refptr<MessageFilter> filter(filter_); |
| 226 plugin_stubs_[i]->webplugin()->containing_window()); | 226 gfx::NativeViewId window = |
| 227 plugin_stubs_[i]->webplugin()->containing_window(); | |
| 227 plugin_stubs_.erase(plugin_stubs_.begin() + i); | 228 plugin_stubs_.erase(plugin_stubs_.begin() + i); |
| 229 Send(reply_msg); | |
| 228 RemoveRoute(instance_id); | 230 RemoveRoute(instance_id); |
| 229 Send(reply_msg); | 231 // NOTE: *this* might be deleted as a result of calling RemoveRoute. |
|
jam
2009/10/06 07:10:48
note: this was using *this* object after RemoveRou
| |
| 232 // Don't release the modal dialog event right away, but do it after the | |
| 233 // stack unwinds since the plugin can be destroyed later if it's in use | |
| 234 // right now. | |
| 235 MessageLoop::current()->PostNonNestableTask(FROM_HERE, NewRunnableMethod( | |
| 236 filter.get(), &MessageFilter::ReleaseModalDialogEvent, window)); | |
| 230 return; | 237 return; |
| 231 } | 238 } |
| 232 } | 239 } |
| 233 | 240 |
| 234 NOTREACHED() << "Couldn't find WebPluginDelegateStub to destroy"; | 241 NOTREACHED() << "Couldn't find WebPluginDelegateStub to destroy"; |
| 235 } | 242 } |
| 236 | 243 |
| 237 void PluginChannel::OnGenerateRouteID(int* route_id) { | 244 void PluginChannel::OnGenerateRouteID(int* route_id) { |
| 238 *route_id = GenerateRouteID(); | 245 *route_id = GenerateRouteID(); |
| 239 } | 246 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 int plugin_fd; | 296 int plugin_fd; |
| 290 IPC::SocketPair(&plugin_fd, &renderer_fd_); | 297 IPC::SocketPair(&plugin_fd, &renderer_fd_); |
| 291 IPC::AddChannelSocket(channel_name(), plugin_fd); | 298 IPC::AddChannelSocket(channel_name(), plugin_fd); |
| 292 #endif | 299 #endif |
| 293 if (!PluginChannelBase::Init(ipc_message_loop, create_pipe_now)) | 300 if (!PluginChannelBase::Init(ipc_message_loop, create_pipe_now)) |
| 294 return false; | 301 return false; |
| 295 | 302 |
| 296 channel_->AddFilter(filter_.get()); | 303 channel_->AddFilter(filter_.get()); |
| 297 return true; | 304 return true; |
| 298 } | 305 } |
| OLD | NEW |