diff options
author | steveblock@chromium.org <steveblock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-20 00:40:50 +0000 |
---|---|---|
committer | steveblock@chromium.org <steveblock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-20 00:40:50 +0000 |
commit | 099587b7a8bf441af62251275197973203e2f11a (patch) | |
tree | a8e0711b152925dbc2102b692d6ceec19e881fa3 | |
parent | 79311e89bc4fbd952d5ce872011f8360bfa5e6e6 (diff) | |
download | chromium_src-099587b7a8bf441af62251275197973203e2f11a.zip chromium_src-099587b7a8bf441af62251275197973203e2f11a.tar.gz chromium_src-099587b7a8bf441af62251275197973203e2f11a.tar.bz2 |
Move NPObjectBase and PluginChannelBase from content/plugin to content/common
Also rename PluginChannelBase to NPChannelBase, fix variable naming to be agnostic of plugins, and fix a comment in NPChannelBase.
This change is refactoring only and introduces no change in behaviour.
BUG=96703
Review URL: http://codereview.chromium.org/7891003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101874 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/common/np_channel_base.cc (renamed from content/plugin/plugin_channel_base.cc) | 117 | ||||
-rw-r--r-- | content/common/np_channel_base.h (renamed from content/plugin/plugin_channel_base.h) | 73 | ||||
-rw-r--r-- | content/common/npobject_base.h (renamed from content/plugin/npobject_base.h) | 11 | ||||
-rw-r--r-- | content/content_common.gypi | 3 | ||||
-rw-r--r-- | content/content_plugin.gypi | 3 | ||||
-rw-r--r-- | content/plugin/npobject_proxy.cc | 14 | ||||
-rw-r--r-- | content/plugin/npobject_proxy.h | 14 | ||||
-rw-r--r-- | content/plugin/npobject_stub.cc | 5 | ||||
-rw-r--r-- | content/plugin/npobject_stub.h | 8 | ||||
-rw-r--r-- | content/plugin/npobject_util.cc | 9 | ||||
-rw-r--r-- | content/plugin/npobject_util.h | 8 | ||||
-rw-r--r-- | content/plugin/plugin_channel.cc | 12 | ||||
-rw-r--r-- | content/plugin/plugin_channel.h | 8 | ||||
-rw-r--r-- | content/plugin/plugin_thread.cc | 2 | ||||
-rw-r--r-- | content/renderer/plugin_channel_host.cc | 14 | ||||
-rw-r--r-- | content/renderer/plugin_channel_host.h | 10 | ||||
-rw-r--r-- | content/renderer/render_thread.cc | 4 | ||||
-rw-r--r-- | tools/valgrind/memcheck/suppressions.txt | 2 |
18 files changed, 160 insertions, 157 deletions
diff --git a/content/plugin/plugin_channel_base.cc b/content/common/np_channel_base.cc index 7db967a..6ba5083 100644 --- a/content/plugin/plugin_channel_base.cc +++ b/content/common/np_channel_base.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/plugin/plugin_channel_base.h" +#include "content/common/np_channel_base.h" #include <stack> @@ -17,24 +17,23 @@ #include "ipc/ipc_channel_posix.h" #endif -typedef base::hash_map<std::string, scoped_refptr<PluginChannelBase> > - PluginChannelMap; +typedef base::hash_map<std::string, scoped_refptr<NPChannelBase> > ChannelMap; -static PluginChannelMap g_plugin_channels_; +static ChannelMap g_channels_; -static base::LazyInstance<std::stack<scoped_refptr<PluginChannelBase> > > - lazy_plugin_channel_stack_(base::LINKER_INITIALIZED); +static base::LazyInstance<std::stack<scoped_refptr<NPChannelBase> > > + lazy_channel_stack_(base::LINKER_INITIALIZED); static int next_pipe_id = 0; -PluginChannelBase* PluginChannelBase::GetChannel( +NPChannelBase* NPChannelBase::GetChannel( const IPC::ChannelHandle& channel_handle, IPC::Channel::Mode mode, - PluginChannelFactory factory, base::MessageLoopProxy* ipc_message_loop, + ChannelFactory factory, base::MessageLoopProxy* ipc_message_loop, bool create_pipe_now) { - scoped_refptr<PluginChannelBase> channel; + scoped_refptr<NPChannelBase> channel; std::string channel_key = channel_handle.name; - PluginChannelMap::const_iterator iter = g_plugin_channels_.find(channel_key); - if (iter == g_plugin_channels_.end()) { + ChannelMap::const_iterator iter = g_channels_.find(channel_key); + if (iter == g_channels_.end()) { channel = factory(); } else { channel = iter->second; @@ -50,7 +49,7 @@ PluginChannelBase* PluginChannelBase::GetChannel( } channel->mode_ = mode; if (channel->Init(ipc_message_loop, create_pipe_now)) { - g_plugin_channels_[channel_key] = channel; + g_channels_[channel_key] = channel; } else { channel = NULL; } @@ -59,18 +58,18 @@ PluginChannelBase* PluginChannelBase::GetChannel( return channel; } -void PluginChannelBase::Broadcast(IPC::Message* message) { - for (PluginChannelMap::iterator iter = g_plugin_channels_.begin(); - iter != g_plugin_channels_.end(); +void NPChannelBase::Broadcast(IPC::Message* message) { + for (ChannelMap::iterator iter = g_channels_.begin(); + iter != g_channels_.end(); ++iter) { iter->second->Send(new IPC::Message(*message)); } delete message; } -PluginChannelBase::PluginChannelBase() +NPChannelBase::NPChannelBase() : mode_(IPC::Channel::MODE_NONE), - plugin_count_(0), + non_npobject_count_(0), peer_pid_(0), in_remove_route_(false), channel_valid_(false), @@ -78,19 +77,19 @@ PluginChannelBase::PluginChannelBase() send_unblocking_only_during_unblock_dispatch_(false) { } -PluginChannelBase::~PluginChannelBase() { +NPChannelBase::~NPChannelBase() { } -PluginChannelBase* PluginChannelBase::GetCurrentChannel() { - return lazy_plugin_channel_stack_.Pointer()->top(); +NPChannelBase* NPChannelBase::GetCurrentChannel() { + return lazy_channel_stack_.Pointer()->top(); } -void PluginChannelBase::CleanupChannels() { +void NPChannelBase::CleanupChannels() { // Make a copy of the references as we can't iterate the map since items will // be removed from it as we clean them up. - std::vector<scoped_refptr<PluginChannelBase> > channels; - for (PluginChannelMap::const_iterator iter = g_plugin_channels_.begin(); - iter != g_plugin_channels_.end(); + std::vector<scoped_refptr<NPChannelBase> > channels; + for (ChannelMap::const_iterator iter = g_channels_.begin(); + iter != g_channels_.end(); ++iter) { channels.push_back(iter->second); } @@ -100,10 +99,10 @@ void PluginChannelBase::CleanupChannels() { // This will clean up channels added to the map for which subsequent // AddRoute wasn't called - g_plugin_channels_.clear(); + g_channels_.clear(); } -NPObjectBase* PluginChannelBase::GetNPObjectListenerForRoute(int route_id) { +NPObjectBase* NPChannelBase::GetNPObjectListenerForRoute(int route_id) { ListenerMap::iterator iter = npobject_listeners_.find(route_id); if (iter == npobject_listeners_.end()) { DLOG(WARNING) << "Invalid route id passed in:" << route_id; @@ -112,8 +111,8 @@ NPObjectBase* PluginChannelBase::GetNPObjectListenerForRoute(int route_id) { return iter->second; } -bool PluginChannelBase::Init(base::MessageLoopProxy* ipc_message_loop, - bool create_pipe_now) { +bool NPChannelBase::Init(base::MessageLoopProxy* ipc_message_loop, + bool create_pipe_now) { channel_.reset(new IPC::SyncChannel( channel_handle_, mode_, this, ipc_message_loop, create_pipe_now, ChildProcess::current()->GetShutDownEvent())); @@ -121,7 +120,7 @@ bool PluginChannelBase::Init(base::MessageLoopProxy* ipc_message_loop, return true; } -bool PluginChannelBase::Send(IPC::Message* message) { +bool NPChannelBase::Send(IPC::Message* message) { if (!channel_.get()) { delete message; return false; @@ -136,15 +135,15 @@ bool PluginChannelBase::Send(IPC::Message* message) { return channel_->Send(message); } -int PluginChannelBase::Count() { - return static_cast<int>(g_plugin_channels_.size()); +int NPChannelBase::Count() { + return static_cast<int>(g_channels_.size()); } -bool PluginChannelBase::OnMessageReceived(const IPC::Message& message) { +bool NPChannelBase::OnMessageReceived(const IPC::Message& message) { // This call might cause us to be deleted, so keep an extra reference to // ourself so that we can send the reply and decrement back in_dispatch_. - lazy_plugin_channel_stack_.Pointer()->push( - scoped_refptr<PluginChannelBase>(this)); + lazy_channel_stack_.Pointer()->push( + scoped_refptr<NPChannelBase>(this)); bool handled; if (message.should_unblock()) @@ -164,27 +163,27 @@ bool PluginChannelBase::OnMessageReceived(const IPC::Message& message) { if (message.should_unblock()) in_unblock_dispatch_--; - lazy_plugin_channel_stack_.Pointer()->pop(); + lazy_channel_stack_.Pointer()->pop(); return handled; } -void PluginChannelBase::OnChannelConnected(int32 peer_pid) { +void NPChannelBase::OnChannelConnected(int32 peer_pid) { peer_pid_ = peer_pid; } -void PluginChannelBase::AddRoute(int route_id, - IPC::Channel::Listener* listener, - NPObjectBase* npobject) { +void NPChannelBase::AddRoute(int route_id, + IPC::Channel::Listener* listener, + NPObjectBase* npobject) { if (npobject) { npobject_listeners_[route_id] = npobject; } else { - plugin_count_++; + non_npobject_count_++; } router_.AddRoute(route_id, listener); } -void PluginChannelBase::RemoveRoute(int route_id) { +void NPChannelBase::RemoveRoute(int route_id) { router_.RemoveRoute(route_id); ListenerMap::iterator iter = npobject_listeners_.find(route_id); @@ -203,10 +202,10 @@ void PluginChannelBase::RemoveRoute(int route_id) { return; } - plugin_count_--; - DCHECK(plugin_count_ >= 0); + non_npobject_count_--; + DCHECK(non_npobject_count_ >= 0); - if (!plugin_count_) { + if (!non_npobject_count_) { AutoReset<bool> auto_reset_in_remove_route(&in_remove_route_, true); for (ListenerMap::iterator npobj_iter = npobject_listeners_.begin(); npobj_iter != npobject_listeners_.end(); ++npobj_iter) { @@ -218,10 +217,10 @@ void PluginChannelBase::RemoveRoute(int route_id) { } } - for (PluginChannelMap::iterator iter = g_plugin_channels_.begin(); - iter != g_plugin_channels_.end(); ++iter) { + for (ChannelMap::iterator iter = g_channels_.begin(); + iter != g_channels_.end(); ++iter) { if (iter->second == this) { - g_plugin_channels_.erase(iter); + g_channels_.erase(iter); return; } } @@ -230,43 +229,43 @@ void PluginChannelBase::RemoveRoute(int route_id) { } } -bool PluginChannelBase::OnControlMessageReceived(const IPC::Message& msg) { +bool NPChannelBase::OnControlMessageReceived(const IPC::Message& msg) { NOTREACHED() << "should override in subclass if you care about control messages"; return false; } -void PluginChannelBase::OnChannelError() { +void NPChannelBase::OnChannelError() { channel_valid_ = false; } -NPObject* PluginChannelBase::GetExistingNPObjectProxy(int route_id) { +NPObject* NPChannelBase::GetExistingNPObjectProxy(int route_id) { ProxyMap::iterator iter = proxy_map_.find(route_id); return iter != proxy_map_.end() ? iter->second : NULL; } -int PluginChannelBase::GetExistingRouteForNPObjectStub(NPObject* npobject) { +int NPChannelBase::GetExistingRouteForNPObjectStub(NPObject* npobject) { StubMap::iterator iter = stub_map_.find(npobject); return iter != stub_map_.end() ? iter->second : MSG_ROUTING_NONE; } -void PluginChannelBase::AddMappingForNPObjectProxy(int route_id, - NPObject* object) { +void NPChannelBase::AddMappingForNPObjectProxy(int route_id, + NPObject* object) { proxy_map_[route_id] = object; } -void PluginChannelBase::AddMappingForNPObjectStub(int route_id, - NPObject* object) { +void NPChannelBase::AddMappingForNPObjectStub(int route_id, + NPObject* object) { DCHECK(object != NULL); stub_map_[object] = route_id; } -void PluginChannelBase::RemoveMappingForNPObjectStub(int route_id, - NPObject* object) { +void NPChannelBase::RemoveMappingForNPObjectStub(int route_id, + NPObject* object) { DCHECK(object != NULL); stub_map_.erase(object); } -void PluginChannelBase::RemoveMappingForNPObjectProxy(int route_id) { +void NPChannelBase::RemoveMappingForNPObjectProxy(int route_id) { proxy_map_.erase(route_id); } diff --git a/content/plugin/plugin_channel_base.h b/content/common/np_channel_base.h index f7f5693..9726f6d 100644 --- a/content/plugin/plugin_channel_base.h +++ b/content/common/np_channel_base.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_PLUGIN_PLUGIN_CHANNEL_BASE_H_ -#define CONTENT_PLUGIN_PLUGIN_CHANNEL_BASE_H_ +#ifndef CONTENT_COMMON_NP_CHANNEL_BASE_H_ +#define CONTENT_COMMON_NP_CHANNEL_BASE_H_ #pragma once #include <string> @@ -12,8 +12,8 @@ #include "base/hash_tables.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "content/common/npobject_base.h" #include "content/common/message_router.h" -#include "content/plugin/npobject_base.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_sync_channel.h" #include "ui/gfx/native_widget_types.h" @@ -44,18 +44,19 @@ inline size_t hash_value(NPObject* const& ptr) { } // namespace stdext #endif // COMPILER -// Encapsulates an IPC channel between a renderer and a plugin process. -class PluginChannelBase : public IPC::Channel::Listener, - public IPC::Message::Sender, - public base::RefCountedThreadSafe<PluginChannelBase> { +// Encapsulates an IPC channel between a renderer and another process. Used to +// proxy access to NP objects. +class NPChannelBase : public IPC::Channel::Listener, + public IPC::Message::Sender, + public base::RefCountedThreadSafe<NPChannelBase> { public: // WebPlugin[Delegate] call these on construction and destruction to setup - // the routing and manage lifetime of this object. This is also called by - // NPObjectProxy and NPObjectStub. However the latter don't control the - // lifetime of this object (by passing true for npobject) because we don't - // want a leak of an NPObject in a plugin to keep the channel around longer - // than necessary. + // the routing and manage lifetime of this object (they pass NULL for + // npobject). These are also called by NPObjectProxy and NPObjectStub (which + // pass themselves for npobject). However the latter don't control the + // lifetime of this object because we don't want a leak of an NPObject to + // keep the channel around longer than necessary. void AddRoute(int route_id, IPC::Channel::Listener* listener, NPObjectBase* npobject); void RemoveRoute(int route_id); @@ -77,7 +78,7 @@ class PluginChannelBase : public IPC::Channel::Listener, int peer_pid() { return peer_pid_; } IPC::ChannelHandle channel_handle() const { return channel_handle_; } - // Returns the number of open plugin channels in this process. + // Returns the number of open NPObject channels in this process. static int Count(); // Returns a new route id. @@ -89,9 +90,9 @@ class PluginChannelBase : public IPC::Channel::Listener, return channel_valid_; } - // Returns the most recent PluginChannelBase to have received a message + // Returns the most recent NPChannelBase to have received a message // in this process. - static PluginChannelBase* GetCurrentChannel(); + static NPChannelBase* GetCurrentChannel(); static void CleanupChannels(); @@ -100,27 +101,27 @@ class PluginChannelBase : public IPC::Channel::Listener, NPObjectBase* GetNPObjectListenerForRoute(int route_id); protected: - typedef PluginChannelBase* (*PluginChannelFactory)(); + typedef NPChannelBase* (*ChannelFactory)(); - friend class base::RefCountedThreadSafe<PluginChannelBase>; + friend class base::RefCountedThreadSafe<NPChannelBase>; - virtual ~PluginChannelBase(); + virtual ~NPChannelBase(); - // Returns a PluginChannelBase derived object for the given channel name. + // Returns a NPChannelBase derived object for the given channel name. // If an existing channel exists returns that object, otherwise creates a // new one. Even though on creation the object is refcounted, each caller // must still ref count the returned value. When there are no more routes // on the channel and its ref count is 0, the object deletes itself. - static PluginChannelBase* GetChannel( + static NPChannelBase* GetChannel( const IPC::ChannelHandle& channel_handle, IPC::Channel::Mode mode, - PluginChannelFactory factory, base::MessageLoopProxy* ipc_message_loop, + ChannelFactory factory, base::MessageLoopProxy* ipc_message_loop, bool create_pipe_now); // Sends a message to all instances. static void Broadcast(IPC::Message* message); // Called on the worker thread - PluginChannelBase(); + NPChannelBase(); virtual void CleanUp() { } @@ -144,7 +145,10 @@ class PluginChannelBase : public IPC::Channel::Listener, private: IPC::Channel::Mode mode_; IPC::ChannelHandle channel_handle_; - int plugin_count_; + // This tracks the number of routes registered without an NPObject. It's used + // to manage the lifetime of this object. See comment for AddRoute() and + // RemoveRoute(). + int non_npobject_count_; int peer_pid_; // true when in the middle of a RemoveRoute call @@ -174,19 +178,18 @@ class PluginChannelBase : public IPC::Channel::Listener, int in_unblock_dispatch_; // If true, sync messages will only be marked as unblocking if the channel is - // in the middle of dispatching an unblocking message. - // The plugin process wants to avoid setting the unblock flag on its sync - // messages unless necessary, since it can potentially introduce reentrancy - // into WebKit in ways that it doesn't expect (i.e. causing layout during - // paint). However to avoid deadlock, we must ensure that any message that's - // sent as a result of a sync call from the renderer must unblock the - // renderer. We additionally have to do this for async messages from the - // renderer that have the unblock flag set, since they could be followed by a - // sync message that won't get dispatched until the call to the renderer is - // complete. + // in the middle of dispatching an unblocking message. The non-renderer + // process wants to avoid setting the unblock flag on its sync messages + // unless necessary, since it can potentially introduce reentrancy into + // WebKit in ways that it doesn't expect (i.e. causing layout during paint). + // However to avoid deadlock, we must ensure that any message that's sent as + // a result of a sync call from the renderer must unblock the renderer. We + // additionally have to do this for async messages from the renderer that + // have the unblock flag set, since they could be followed by a sync message + // that won't get dispatched until the call to the renderer is complete. bool send_unblocking_only_during_unblock_dispatch_; - DISALLOW_COPY_AND_ASSIGN(PluginChannelBase); + DISALLOW_COPY_AND_ASSIGN(NPChannelBase); }; -#endif // CONTENT_PLUGIN_PLUGIN_CHANNEL_BASE_H_ +#endif // CONTENT_COMMON_NP_CHANNEL_BASE_H_ diff --git a/content/plugin/npobject_base.h b/content/common/npobject_base.h index fc6117a..e8dd6a9 100644 --- a/content/plugin/npobject_base.h +++ b/content/common/npobject_base.h @@ -1,11 +1,12 @@ -// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Base interface implemented by NPObjectProxy and NPObjectStub +// Base interface used by NPChannelBase and implemented by NPObjectProxy and +// NPObjectStub. -#ifndef CONTENT_PLUGIN_NPOBJECT_BASE_H_ -#define CONTENT_PLUGIN_NPOBJECT_BASE_H_ +#ifndef CONTENT_COMMON_NPOBJECT_BASE_H_ +#define CONTENT_COMMON_NPOBJECT_BASE_H_ #pragma once #include "ipc/ipc_channel.h" @@ -24,4 +25,4 @@ class NPObjectBase { virtual IPC::Channel::Listener* GetChannelListener() = 0; }; -#endif // CONTENT_PLUGIN_NPOBJECT_BASE_H_ +#endif // CONTENT_COMMON_NPOBJECT_BASE_H_ diff --git a/content/content_common.gypi b/content/content_common.gypi index 4aa18f7..7dcffce 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -167,6 +167,9 @@ 'common/notification_service.h', 'common/notification_source.cc', 'common/notification_source.h', + 'common/np_channel_base.cc', + 'common/np_channel_base.h', + 'common/npobject_base.h', 'common/p2p_messages.h', 'common/p2p_sockets.h', 'common/page_transition_types.cc', diff --git a/content/content_plugin.gypi b/content/content_plugin.gypi index 9ab27e1..969d3c0 100644 --- a/content/content_plugin.gypi +++ b/content/content_plugin.gypi @@ -16,7 +16,6 @@ # All .cc, .h, .m, and .mm files under plugins except for tests and # mocks. 'plugin/content_plugin_client.h', - 'plugin/npobject_base.h', 'plugin/npobject_proxy.cc', 'plugin/npobject_proxy.h', 'plugin/npobject_stub.cc', @@ -25,8 +24,6 @@ 'plugin/npobject_util.h', 'plugin/plugin_channel.cc', 'plugin/plugin_channel.h', - 'plugin/plugin_channel_base.cc', - 'plugin/plugin_channel_base.h', 'plugin/plugin_interpose_util_mac.mm', 'plugin/plugin_interpose_util_mac.h', 'plugin/plugin_main.cc', diff --git a/content/plugin/npobject_proxy.cc b/content/plugin/npobject_proxy.cc index 8772b2a..cb0ed89 100644 --- a/content/plugin/npobject_proxy.cc +++ b/content/plugin/npobject_proxy.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -55,7 +55,7 @@ IPC::Channel::Listener* NPObjectProxy::GetChannelListener() { } NPObjectProxy::NPObjectProxy( - PluginChannelBase* channel, + NPChannelBase* channel, int route_id, gfx::NativeViewId containing_window, const GURL& page_url) @@ -79,7 +79,7 @@ NPObjectProxy::~NPObjectProxy() { } } -NPObject* NPObjectProxy::Create(PluginChannelBase* channel, +NPObject* NPObjectProxy::Create(NPChannelBase* channel, int route_id, gfx::NativeViewId containing_window, const GURL& page_url) { @@ -187,7 +187,7 @@ bool NPObjectProxy::NPInvokePrivate(NPP npp, // Note: This instance can get destroyed in the context of // Send so addref the channel in this scope. - scoped_refptr<PluginChannelBase> channel_copy = proxy->channel_; + scoped_refptr<NPChannelBase> channel_copy = proxy->channel_; std::vector<NPVariant_Param> args_param; for (unsigned int i = 0; i < arg_count; ++i) { NPVariant_Param param; @@ -277,7 +277,7 @@ bool NPObjectProxy::NPGetProperty(NPObject *obj, CreateNPIdentifierParam(name, &name_param); NPVariant_Param param; - scoped_refptr<PluginChannelBase> channel(proxy->channel_); + scoped_refptr<NPChannelBase> channel(proxy->channel_); GURL page_url = proxy->page_url_; proxy->Send(new NPObjectMsg_GetProperty( @@ -415,7 +415,7 @@ bool NPObjectProxy::NPNConstruct(NPObject *obj, // Note: This instance can get destroyed in the context of // Send so addref the channel in this scope. - scoped_refptr<PluginChannelBase> channel_copy = proxy->channel_; + scoped_refptr<NPChannelBase> channel_copy = proxy->channel_; std::vector<NPVariant_Param> args_param; for (unsigned int i = 0; i < arg_count; ++i) { NPVariant_Param param; @@ -490,7 +490,7 @@ bool NPObjectProxy::NPNEvaluate(NPP npp, channel->GetModalDialogEvent(proxy->containing_window_)); } } - scoped_refptr<PluginChannelBase> channel(proxy->channel_); + scoped_refptr<NPChannelBase> channel(proxy->channel_); GURL page_url = proxy->page_url_; proxy->Send(msg); diff --git a/content/plugin/npobject_proxy.h b/content/plugin/npobject_proxy.h index dccd531..fea41ff 100644 --- a/content/plugin/npobject_proxy.h +++ b/content/plugin/npobject_proxy.h @@ -10,13 +10,13 @@ #pragma once #include "base/memory/ref_counted.h" -#include "content/plugin/npobject_base.h" +#include "content/common/npobject_base.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_channel.h" #include "third_party/npapi/bindings/npruntime.h" #include "ui/gfx/native_widget_types.h" -class PluginChannelBase; +class NPChannelBase; struct NPObject; // When running a plugin in a different process from the renderer, we need to @@ -24,7 +24,7 @@ struct NPObject; // as a plugin can get an NPObject for the window, and a page can get an // NPObject for the plugin. In the process that interacts with the NPobject we // give it an NPObjectProxy instead. All calls to it are sent across an IPC -// channel (specifically, a PluginChannelBase). The NPObjectStub on the other +// channel (specifically, a NPChannelBase). The NPObjectStub on the other // side translates the IPC messages into calls to the actual NPObject, and // returns the marshalled result. class NPObjectProxy : public IPC::Channel::Listener, @@ -33,7 +33,7 @@ class NPObjectProxy : public IPC::Channel::Listener, public: virtual ~NPObjectProxy(); - static NPObject* Create(PluginChannelBase* channel, + static NPObject* Create(NPChannelBase* channel, int route_id, gfx::NativeViewId containing_window, const GURL& page_url); @@ -41,7 +41,7 @@ class NPObjectProxy : public IPC::Channel::Listener, // IPC::Message::Sender implementation: virtual bool Send(IPC::Message* msg); int route_id() { return route_id_; } - PluginChannelBase* channel() { return channel_; } + NPChannelBase* channel() { return channel_; } // The next 9 functions are called on NPObjects from the plugin and browser. static bool NPHasMethod(NPObject *obj, @@ -96,7 +96,7 @@ class NPObjectProxy : public IPC::Channel::Listener, virtual IPC::Channel::Listener* GetChannelListener(); private: - NPObjectProxy(PluginChannelBase* channel, + NPObjectProxy(NPChannelBase* channel, int route_id, gfx::NativeViewId containing_window, const GURL& page_url); @@ -112,7 +112,7 @@ class NPObjectProxy : public IPC::Channel::Listener, static void NPPInvalidate(NPObject *obj); static NPClass npclass_proxy_; - scoped_refptr<PluginChannelBase> channel_; + scoped_refptr<NPChannelBase> channel_; int route_id_; gfx::NativeViewId containing_window_; diff --git a/content/plugin/npobject_stub.cc b/content/plugin/npobject_stub.cc index b3e1441..5b50a7b 100644 --- a/content/plugin/npobject_stub.cc +++ b/content/plugin/npobject_stub.cc @@ -7,18 +7,19 @@ #include "content/common/content_client.h" #include "content/common/plugin_messages.h" #include "content/plugin/npobject_util.h" -#include "content/plugin/plugin_channel_base.h" #include "content/plugin/plugin_thread.h" #include "third_party/npapi/bindings/npapi.h" #include "third_party/npapi/bindings/npruntime.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" #include "webkit/plugins/npapi/plugin_constants_win.h" +class NPChannelBase; + using WebKit::WebBindings; NPObjectStub::NPObjectStub( NPObject* npobject, - PluginChannelBase* channel, + NPChannelBase* channel, int route_id, gfx::NativeViewId containing_window, const GURL& page_url) diff --git a/content/plugin/npobject_stub.h b/content/plugin/npobject_stub.h index d48fa09..7dbc32f 100644 --- a/content/plugin/npobject_stub.h +++ b/content/plugin/npobject_stub.h @@ -13,12 +13,12 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "content/plugin/npobject_base.h" +#include "content/common/npobject_base.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_channel.h" #include "ui/gfx/native_widget_types.h" -class PluginChannelBase; +class NPChannelBase; struct NPIdentifier_Param; struct NPObject; struct NPVariant_Param; @@ -32,7 +32,7 @@ class NPObjectStub : public IPC::Channel::Listener, public NPObjectBase { public: NPObjectStub(NPObject* npobject, - PluginChannelBase* channel, + NPChannelBase* channel, int route_id, gfx::NativeViewId containing_window, const GURL& page_url); @@ -84,7 +84,7 @@ class NPObjectStub : public IPC::Channel::Listener, private: NPObject* npobject_; - scoped_refptr<PluginChannelBase> channel_; + scoped_refptr<NPChannelBase> channel_; int route_id_; gfx::NativeViewId containing_window_; diff --git a/content/plugin/npobject_util.cc b/content/plugin/npobject_util.cc index f9aba8a0c..8890280 100644 --- a/content/plugin/npobject_util.cc +++ b/content/plugin/npobject_util.cc @@ -5,9 +5,9 @@ #include "content/plugin/npobject_util.h" #include "base/string_util.h" +#include "content/common/np_channel_base.h" #include "content/common/plugin_messages.h" #include "content/plugin/npobject_proxy.h" -#include "content/plugin/plugin_channel_base.h" #include "third_party/npapi/bindings/nphostapi.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" #include "webkit/plugins/npapi/plugin_host.h" @@ -87,8 +87,7 @@ static bool NPN_EvaluatePatch(NPP npp, static void NPN_SetExceptionPatch(NPObject *obj, const NPUTF8 *message) { std::string message_str(message); if (IsPluginProcess()) { - PluginChannelBase* renderer_channel = - PluginChannelBase::GetCurrentChannel(); + NPChannelBase* renderer_channel = NPChannelBase::GetCurrentChannel(); if (renderer_channel) renderer_channel->Send(new PluginHostMsg_SetException(message_str)); } else { @@ -145,7 +144,7 @@ NPIdentifier CreateNPIdentifier(const NPIdentifier_Param& param) { } void CreateNPVariantParam(const NPVariant& variant, - PluginChannelBase* channel, + NPChannelBase* channel, NPVariant_Param* param, bool release, gfx::NativeViewId containing_window, @@ -219,7 +218,7 @@ void CreateNPVariantParam(const NPVariant& variant, } bool CreateNPVariant(const NPVariant_Param& param, - PluginChannelBase* channel, + NPChannelBase* channel, NPVariant* result, gfx::NativeViewId containing_window, const GURL& page_url) { diff --git a/content/plugin/npobject_util.h b/content/plugin/npobject_util.h index cca210d..7e5cb07 100644 --- a/content/plugin/npobject_util.h +++ b/content/plugin/npobject_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -18,7 +18,7 @@ class GURL; class NPObjectProxy; -class PluginChannelBase; +class NPChannelBase; struct _NPVariant; struct NPIdentifier_Param; @@ -47,7 +47,7 @@ NPIdentifier CreateNPIdentifier(const NPIdentifier_Param& param); // If release is true, the NPVariant object is released (except if // it contains an NPObject, since the stub will manage its lifetime). void CreateNPVariantParam(const NPVariant& variant, - PluginChannelBase* channel, + NPChannelBase* channel, NPVariant_Param* param, bool release, gfx::NativeViewId containing_window, @@ -56,7 +56,7 @@ void CreateNPVariantParam(const NPVariant& variant, // Creates an NPVariant from the marshalled object. // Returns true on success. bool CreateNPVariant(const NPVariant_Param& param, - PluginChannelBase* channel, + NPChannelBase* channel, NPVariant* result, gfx::NativeViewId containing_window, const GURL& page_url); diff --git a/content/plugin/plugin_channel.cc b/content/plugin/plugin_channel.cc index cd2e99f..6d428cf 100644 --- a/content/plugin/plugin_channel.cc +++ b/content/plugin/plugin_channel.cc @@ -143,7 +143,7 @@ PluginChannel* PluginChannel::GetPluginChannel( "%d.r%d", base::GetCurrentProcId(), renderer_id); PluginChannel* channel = - static_cast<PluginChannel*>(PluginChannelBase::GetChannel( + static_cast<PluginChannel*>(NPChannelBase::GetChannel( channel_key, IPC::Channel::MODE_SERVER, ClassFactory, @@ -187,7 +187,7 @@ bool PluginChannel::Send(IPC::Message* msg) { VLOG(1) << "sending message @" << msg << " on channel @" << this << " with type " << msg->type(); } - bool result = PluginChannelBase::Send(msg); + bool result = NPChannelBase::Send(msg); in_send_--; return result; } @@ -197,7 +197,7 @@ bool PluginChannel::OnMessageReceived(const IPC::Message& msg) { VLOG(1) << "received message @" << &msg << " on channel @" << this << " with type " << msg.type(); } - return PluginChannelBase::OnMessageReceived(msg); + return NPChannelBase::OnMessageReceived(msg); } bool PluginChannel::OnControlMessageReceived(const IPC::Message& msg) { @@ -297,13 +297,13 @@ void PluginChannel::OnChannelConnected(int32 peer_pid) { NOTREACHED(); } renderer_handle_ = handle; - PluginChannelBase::OnChannelConnected(peer_pid); + NPChannelBase::OnChannelConnected(peer_pid); } void PluginChannel::OnChannelError() { base::CloseProcessHandle(renderer_handle_); renderer_handle_ = 0; - PluginChannelBase::OnChannelError(); + NPChannelBase::OnChannelError(); CleanUp(); } @@ -325,7 +325,7 @@ void PluginChannel::CleanUp() { bool PluginChannel::Init(base::MessageLoopProxy* ipc_message_loop, bool create_pipe_now) { - if (!PluginChannelBase::Init(ipc_message_loop, create_pipe_now)) + if (!NPChannelBase::Init(ipc_message_loop, create_pipe_now)) return false; channel_->AddFilter(filter_.get()); diff --git a/content/plugin/plugin_channel.h b/content/plugin/plugin_channel.h index 6a5bb74..87afb8c 100644 --- a/content/plugin/plugin_channel.h +++ b/content/plugin/plugin_channel.h @@ -11,7 +11,7 @@ #include "base/memory/scoped_handle.h" #include "base/process.h" #include "build/build_config.h" -#include "content/plugin/plugin_channel_base.h" +#include "content/common/np_channel_base.h" #include "content/plugin/webplugin_delegate_stub.h" namespace base { @@ -20,7 +20,7 @@ class WaitableEvent; // Encapsulates an IPC channel between the plugin process and one renderer // process. On the renderer side there's a corresponding PluginChannelHost. -class PluginChannel : public PluginChannelBase { +class PluginChannel : public NPChannelBase { public: // Get a new PluginChannel object for the current process to talk to the // given renderer process. The renderer ID is an opaque unique ID generated @@ -63,7 +63,7 @@ class PluginChannel : public PluginChannelBase { virtual void CleanUp(); - // Overrides PluginChannelBase::Init. + // Overrides NPChannelBase::Init. virtual bool Init(base::MessageLoopProxy* ipc_message_loop, bool create_pipe_now); @@ -75,7 +75,7 @@ class PluginChannel : public PluginChannelBase { virtual bool OnControlMessageReceived(const IPC::Message& msg); - static PluginChannelBase* ClassFactory() { return new PluginChannel(); } + static NPChannelBase* ClassFactory() { return new PluginChannel(); } void OnCreateInstance(const std::string& mime_type, int* instance_id); void OnDestroyInstance(int instance_id, IPC::Message* reply_msg); diff --git a/content/plugin/plugin_thread.cc b/content/plugin/plugin_thread.cc index 75252c6..af66f09 100644 --- a/content/plugin/plugin_thread.cc +++ b/content/plugin/plugin_thread.cc @@ -126,7 +126,7 @@ PluginThread::~PluginThread() { base::UnloadNativeLibrary(preloaded_plugin_module_); preloaded_plugin_module_ = NULL; } - PluginChannelBase::CleanupChannels(); + NPChannelBase::CleanupChannels(); webkit::npapi::PluginLib::UnloadAllPlugins(); if (webkit_glue::ShouldForcefullyTerminatePluginProcess()) diff --git a/content/renderer/plugin_channel_host.cc b/content/renderer/plugin_channel_host.cc index 7fedc84..b41db85 100644 --- a/content/renderer/plugin_channel_host.cc +++ b/content/renderer/plugin_channel_host.cc @@ -1,11 +1,11 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/renderer/plugin_channel_host.h" +#include "content/common/npobject_base.h" #include "content/common/plugin_messages.h" -#include "content/plugin/npobject_base.h" #if defined(OS_POSIX) #include "ipc/ipc_channel_posix.h" @@ -71,7 +71,7 @@ PluginChannelHost* PluginChannelHost::GetPluginChannelHost( const IPC::ChannelHandle& channel_handle, base::MessageLoopProxy* ipc_message_loop) { PluginChannelHost* result = - static_cast<PluginChannelHost*>(PluginChannelBase::GetChannel( + static_cast<PluginChannelHost*>(NPChannelBase::GetChannel( channel_handle, IPC::Channel::MODE_CLIENT, ClassFactory, @@ -88,7 +88,7 @@ PluginChannelHost::~PluginChannelHost() { bool PluginChannelHost::Init(base::MessageLoopProxy* ipc_message_loop, bool create_pipe_now) { - bool ret = PluginChannelBase::Init(ipc_message_loop, create_pipe_now); + bool ret = NPChannelBase::Init(ipc_message_loop, create_pipe_now); is_listening_filter_ = new IsListeningFilter; channel_->AddFilter(is_listening_filter_); return ret; @@ -104,7 +104,7 @@ int PluginChannelHost::GenerateRouteID() { void PluginChannelHost::AddRoute(int route_id, IPC::Channel::Listener* listener, NPObjectBase* npobject) { - PluginChannelBase::AddRoute(route_id, listener, npobject); + NPChannelBase::AddRoute(route_id, listener, npobject); if (!npobject) proxies_[route_id] = listener; @@ -112,7 +112,7 @@ void PluginChannelHost::AddRoute(int route_id, void PluginChannelHost::RemoveRoute(int route_id) { proxies_.erase(route_id); - PluginChannelBase::RemoveRoute(route_id); + NPChannelBase::RemoveRoute(route_id); } bool PluginChannelHost::OnControlMessageReceived(const IPC::Message& message) { @@ -135,7 +135,7 @@ void PluginChannelHost::OnPluginShuttingDown(const IPC::Message& message) { } void PluginChannelHost::OnChannelError() { - PluginChannelBase::OnChannelError(); + NPChannelBase::OnChannelError(); for (ProxyMap::iterator iter = proxies_.begin(); iter != proxies_.end(); iter++) { diff --git a/content/renderer/plugin_channel_host.h b/content/renderer/plugin_channel_host.h index 524df47..a12fca6 100644 --- a/content/renderer/plugin_channel_host.h +++ b/content/renderer/plugin_channel_host.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,7 +7,7 @@ #pragma once #include "base/hash_tables.h" -#include "content/plugin/plugin_channel_base.h" +#include "content/common/np_channel_base.h" #include "ipc/ipc_channel_handle.h" class IsListeningFilter; @@ -15,7 +15,7 @@ class NPObjectBase; // Encapsulates an IPC channel between the renderer and one plugin process. // On the plugin side there's a corresponding PluginChannel. -class PluginChannelHost : public PluginChannelBase { +class PluginChannelHost : public NPChannelBase { public: static PluginChannelHost* GetPluginChannelHost( const IPC::ChannelHandle& channel_handle, @@ -38,7 +38,7 @@ class PluginChannelHost : public PluginChannelBase { static bool IsListening(); static void Broadcast(IPC::Message* message) { - PluginChannelBase::Broadcast(message); + NPChannelBase::Broadcast(message); } bool expecting_shutdown() { return expecting_shutdown_; } @@ -48,7 +48,7 @@ class PluginChannelHost : public PluginChannelBase { PluginChannelHost(); virtual ~PluginChannelHost(); - static PluginChannelBase* ClassFactory() { return new PluginChannelHost(); } + static NPChannelBase* ClassFactory() { return new PluginChannelHost(); } virtual bool OnControlMessageReceived(const IPC::Message& message); void OnSetException(const std::string& message); diff --git a/content/renderer/render_thread.cc b/content/renderer/render_thread.cc index 3be07a4..3e11f98 100644 --- a/content/renderer/render_thread.cc +++ b/content/renderer/render_thread.cc @@ -74,7 +74,7 @@ #include "content/plugin/plugin_channel.h" #else #include "base/memory/scoped_handle.h" -#include "content/plugin/plugin_channel_base.h" +#include "content/common/np_channel_base.h" #endif #if defined(OS_WIN) @@ -245,7 +245,7 @@ RenderThread::~RenderThread() { // TODO(port) #if defined(OS_WIN) // Clean up plugin channels before this thread goes away. - PluginChannelBase::CleanupChannels(); + NPChannelBase::CleanupChannels(); // Don't call COM if the renderer is in the sandbox. if (RenderProcessImpl::InProcessPlugins()) CoUninitialize(); diff --git a/tools/valgrind/memcheck/suppressions.txt b/tools/valgrind/memcheck/suppressions.txt index b73721b..9e981af 100644 --- a/tools/valgrind/memcheck/suppressions.txt +++ b/tools/valgrind/memcheck/suppressions.txt @@ -3005,7 +3005,7 @@ fun:_ZN13NPObjectProxy10NPAllocateEP4_NPPP7NPClass fun:_NPN_CreateObject fun:_ZN6WebKit11WebBindings12createObjectEP4_NPPP7NPClass - fun:_ZN13NPObjectProxy6CreateEP17PluginChannelBaseiiRK4GURL + fun:_ZN13NPObjectProxy6CreateEP17NPChannelBaseiiRK4GURL } { Bug_69934_b |