| Index: content/plugin/plugin_channel.cc
|
| diff --git a/content/plugin/plugin_channel.cc b/content/plugin/plugin_channel.cc
|
| index 3f544dae39402c557969e747ea6328166ef4396e..0fa7a6f65bfb84e0ad9b816fa3e5885d590c4a3b 100644
|
| --- a/content/plugin/plugin_channel.cc
|
| +++ b/content/plugin/plugin_channel.cc
|
| @@ -41,13 +41,6 @@ const int kPluginReleaseTimeMinutes = 5;
|
| class PluginChannel::MessageFilter : public IPC::ChannelProxy::MessageFilter {
|
| public:
|
| MessageFilter() : channel_(NULL) { }
|
| - ~MessageFilter() {
|
| - // Clean up in case of renderer crash.
|
| - for (ModalDialogEventMap::iterator i = modal_dialog_event_map_.begin();
|
| - i != modal_dialog_event_map_.end(); ++i) {
|
| - delete i->second.event;
|
| - }
|
| - }
|
|
|
| base::WaitableEvent* GetModalDialogEvent(
|
| gfx::NativeViewId containing_window) {
|
| @@ -83,7 +76,7 @@ class PluginChannel::MessageFilter : public IPC::ChannelProxy::MessageFilter {
|
| return channel_->Send(message);
|
| }
|
|
|
| - private:
|
| + // IPC::ChannelProxy::MessageFilter:
|
| void OnFilterAdded(IPC::Channel* channel) { channel_ = channel; }
|
|
|
| bool OnMessageReceived(const IPC::Message& message) {
|
| @@ -98,6 +91,18 @@ class PluginChannel::MessageFilter : public IPC::ChannelProxy::MessageFilter {
|
| message.type() == PluginMsg_ResetModalDialogEvent::ID;
|
| }
|
|
|
| +
|
| +
|
| + protected:
|
| + virtual ~MessageFilter() {
|
| + // Clean up in case of renderer crash.
|
| + for (ModalDialogEventMap::iterator i = modal_dialog_event_map_.begin();
|
| + i != modal_dialog_event_map_.end(); ++i) {
|
| + delete i->second.event;
|
| + }
|
| + }
|
| +
|
| + private:
|
| void OnInit(const PluginMsg_Init_Params& params, IPC::Message* reply_msg) {
|
| base::AutoLock auto_lock(modal_dialog_event_map_lock_);
|
| if (modal_dialog_event_map_.count(params.containing_window)) {
|
| @@ -160,24 +165,6 @@ void PluginChannel::NotifyRenderersOfPendingShutdown() {
|
| Broadcast(new PluginHostMsg_PluginShuttingDown());
|
| }
|
|
|
| -PluginChannel::PluginChannel()
|
| - : renderer_id_(-1),
|
| - in_send_(0),
|
| - incognito_(false),
|
| - filter_(new MessageFilter()) {
|
| - set_send_unblocking_only_during_unblock_dispatch();
|
| - ChildProcess::current()->AddRefProcess();
|
| - const CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| - log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
|
| -}
|
| -
|
| -PluginChannel::~PluginChannel() {
|
| - MessageLoop::current()->PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(&PluginReleaseCallback),
|
| - base::TimeDelta::FromMinutes(kPluginReleaseTimeMinutes));
|
| -}
|
| -
|
| bool PluginChannel::Send(IPC::Message* msg) {
|
| in_send_++;
|
| if (log_messages_) {
|
| @@ -197,6 +184,65 @@ bool PluginChannel::OnMessageReceived(const IPC::Message& msg) {
|
| return NPChannelBase::OnMessageReceived(msg);
|
| }
|
|
|
| +void PluginChannel::OnChannelError() {
|
| + NPChannelBase::OnChannelError();
|
| + CleanUp();
|
| +}
|
| +
|
| +int PluginChannel::GenerateRouteID() {
|
| + static int last_id = 0;
|
| + return ++last_id;
|
| +}
|
| +
|
| +base::WaitableEvent* PluginChannel::GetModalDialogEvent(
|
| + gfx::NativeViewId containing_window) {
|
| + return filter_->GetModalDialogEvent(containing_window);
|
| +}
|
| +
|
| +PluginChannel::~PluginChannel() {
|
| + MessageLoop::current()->PostDelayedTask(
|
| + FROM_HERE,
|
| + base::Bind(&PluginReleaseCallback),
|
| + base::TimeDelta::FromMinutes(kPluginReleaseTimeMinutes));
|
| +}
|
| +
|
| +void PluginChannel::CleanUp() {
|
| + // We need to clean up the stubs so that they call NPPDestroy. This will
|
| + // also lead to them releasing their reference on this object so that it can
|
| + // be deleted.
|
| + for (size_t i = 0; i < plugin_stubs_.size(); ++i)
|
| + RemoveRoute(plugin_stubs_[i]->instance_id());
|
| +
|
| + // Need to addref this object temporarily because otherwise removing the last
|
| + // stub will cause the destructor of this object to be called, however at
|
| + // that point plugin_stubs_ will have one element and its destructor will be
|
| + // called twice.
|
| + scoped_refptr<PluginChannel> me(this);
|
| +
|
| + plugin_stubs_.clear();
|
| +}
|
| +
|
| +bool PluginChannel::Init(base::MessageLoopProxy* ipc_message_loop,
|
| + bool create_pipe_now,
|
| + base::WaitableEvent* shutdown_event) {
|
| + if (!NPChannelBase::Init(ipc_message_loop, create_pipe_now, shutdown_event))
|
| + return false;
|
| +
|
| + channel_->AddFilter(filter_.get());
|
| + return true;
|
| +}
|
| +
|
| +PluginChannel::PluginChannel()
|
| + : renderer_id_(-1),
|
| + in_send_(0),
|
| + incognito_(false),
|
| + filter_(new MessageFilter()) {
|
| + set_send_unblocking_only_during_unblock_dispatch();
|
| + ChildProcess::current()->AddRefProcess();
|
| + const CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| + log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
|
| +}
|
| +
|
| bool PluginChannel::OnControlMessageReceived(const IPC::Message& msg) {
|
| bool handled = true;
|
| IPC_BEGIN_MESSAGE_MAP(PluginChannel, msg)
|
| @@ -247,11 +293,6 @@ void PluginChannel::OnGenerateRouteID(int* route_id) {
|
| *route_id = GenerateRouteID();
|
| }
|
|
|
| -int PluginChannel::GenerateRouteID() {
|
| - static int last_id = 0;
|
| - return ++last_id;
|
| -}
|
| -
|
| void PluginChannel::OnClearSiteData(const std::string& site,
|
| uint64 flags,
|
| uint64 max_age) {
|
| @@ -275,40 +316,3 @@ void PluginChannel::OnClearSiteData(const std::string& site,
|
| }
|
| Send(new PluginHostMsg_ClearSiteDataResult(success));
|
| }
|
| -
|
| -base::WaitableEvent* PluginChannel::GetModalDialogEvent(
|
| - gfx::NativeViewId containing_window) {
|
| - return filter_->GetModalDialogEvent(containing_window);
|
| -}
|
| -
|
| -void PluginChannel::OnChannelError() {
|
| - NPChannelBase::OnChannelError();
|
| - CleanUp();
|
| -}
|
| -
|
| -void PluginChannel::CleanUp() {
|
| - // We need to clean up the stubs so that they call NPPDestroy. This will
|
| - // also lead to them releasing their reference on this object so that it can
|
| - // be deleted.
|
| - for (size_t i = 0; i < plugin_stubs_.size(); ++i)
|
| - RemoveRoute(plugin_stubs_[i]->instance_id());
|
| -
|
| - // Need to addref this object temporarily because otherwise removing the last
|
| - // stub will cause the destructor of this object to be called, however at
|
| - // that point plugin_stubs_ will have one element and its destructor will be
|
| - // called twice.
|
| - scoped_refptr<PluginChannel> me(this);
|
| -
|
| - plugin_stubs_.clear();
|
| -}
|
| -
|
| -bool PluginChannel::Init(base::MessageLoopProxy* ipc_message_loop,
|
| - bool create_pipe_now,
|
| - base::WaitableEvent* shutdown_event) {
|
| - if (!NPChannelBase::Init(ipc_message_loop, create_pipe_now, shutdown_event))
|
| - return false;
|
| -
|
| - channel_->AddFilter(filter_.get());
|
| - return true;
|
| -}
|
| -
|
|
|