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

Unified Diff: content/plugin/plugin_channel.cc

Issue 10069054: RefCounted types should not have public destructors, content/ remaining bits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to Trunk Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/plugin/plugin_channel.h ('k') | content/plugin/plugin_thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
-}
-
« no previous file with comments | « content/plugin/plugin_channel.h ('k') | content/plugin/plugin_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698