diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-18 00:34:30 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-18 00:34:30 +0000 |
commit | f3b1a084a01ab82caf998daefcb989c66ff16135 (patch) | |
tree | 1072e46976c2fb7fa82d72c74bdc579d78f0ce01 /chrome/browser/visitedlink | |
parent | 8f0633691cd10779408642e2ad5eaa9b0c190b0a (diff) | |
download | chromium_src-f3b1a084a01ab82caf998daefcb989c66ff16135.zip chromium_src-f3b1a084a01ab82caf998daefcb989c66ff16135.tar.gz chromium_src-f3b1a084a01ab82caf998daefcb989c66ff16135.tar.bz2 |
Define the public interface for content browser RenderProcessHost. This interface is implemented by the RenderProcessHostImpl class which lives in content\browser\renderer_host\render_process_host_impl.cc/.h. The RenderProcessHostImpl class is a consolidation of the RenderProcessHost and BrowserRenderProcessHost classes.
The RenderProcessHost public interface was created from the now deleted RenderProcessHost class defined in content\browser\renderer_host\render_process_host.h.
Additional methods have been added to the interface to ensure that it works correctly with the MockRenderProcessHost class used by unit tests. I had to implement a number of overrides in the MockRenderProcessHost class to ensure that tests work correctly. This was because of assumptions in the tests that the MockRPH class was a real RPH which it was till now.
Added a TODO for the methods which could potentially be removed from this interface. Will revisit that in a subsequent CL.
BUG=98716
TEST=No change in functionality. Hopefully it all compiles and works.
Review URL: http://codereview.chromium.org/8515027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110615 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/visitedlink')
-rw-r--r-- | chrome/browser/visitedlink/visitedlink_event_listener.cc | 39 | ||||
-rw-r--r-- | chrome/browser/visitedlink/visitedlink_unittest.cc | 18 |
2 files changed, 31 insertions, 26 deletions
diff --git a/chrome/browser/visitedlink/visitedlink_event_listener.cc b/chrome/browser/visitedlink/visitedlink_event_listener.cc index a15dbe4..da41bba 100644 --- a/chrome/browser/visitedlink/visitedlink_event_listener.cc +++ b/chrome/browser/visitedlink/visitedlink_event_listener.cc @@ -7,10 +7,10 @@ #include "base/shared_memory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/render_messages.h" -#include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/render_process_host.h" using base::Time; using base::TimeDelta; @@ -31,7 +31,7 @@ static const unsigned kVisitedLinkBufferThreshold = 50; // As opposed to the VisitedLinkEventListener, which coalesces to // reduce the rate of messages being sent to render processes, this class // ensures that the updates occur only when explicitly requested. This is -// used for BrowserRenderProcessHost to only send Add/Reset link events to the +// used for RenderProcessHostImpl to only send Add/Reset link events to the // renderers when their tabs are visible and the corresponding RenderViews are // created. class VisitedLinkUpdater { @@ -42,7 +42,8 @@ class VisitedLinkUpdater { // Informs the renderer about a new visited link table. void SendVisitedLinkTable(base::SharedMemory* table_memory) { - RenderProcessHost* process = RenderProcessHost::FromID(render_process_id_); + content::RenderProcessHost* process = + content::RenderProcessHost::FromID(render_process_id_); if (!process) return; // Happens in tests base::SharedMemoryHandle handle_for_process; @@ -77,7 +78,8 @@ class VisitedLinkUpdater { // Sends visited link update messages: a list of links whose visited state // changed or reset of visited state for all links. void Update() { - RenderProcessHost* process = RenderProcessHost::FromID(render_process_id_); + content::RenderProcessHost* process = + content::RenderProcessHost::FromID(render_process_id_); if (!process) return; // Happens in tests @@ -124,8 +126,10 @@ void VisitedLinkEventListener::NewTable(base::SharedMemory* table_memory) { // Send to all RenderProcessHosts. for (Updaters::iterator i = updaters_.begin(); i != updaters_.end(); ++i) { // Make sure to not send to incognito renderers. - RenderProcessHost* process = RenderProcessHost::FromID(i->first); - Profile* profile = Profile::FromBrowserContext(process->browser_context()); + content::RenderProcessHost* process = + content::RenderProcessHost::FromID(i->first); + Profile* profile = Profile::FromBrowserContext( + process->GetBrowserContext()); VisitedLinkMaster* master = profile->GetVisitedLinkMaster(); if (master && master->shared_memory() == table_memory) i->second->SendVisitedLinkTable(table_memory); @@ -168,14 +172,14 @@ void VisitedLinkEventListener::Observe( const content::NotificationDetails& details) { switch (type) { case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { - RenderProcessHost* process = - content::Source<RenderProcessHost>(source).ptr(); + content::RenderProcessHost* process = + content::Source<content::RenderProcessHost>(source).ptr(); Profile* profile = - Profile::FromBrowserContext(process->browser_context()); + Profile::FromBrowserContext(process->GetBrowserContext()); if (!profile_->IsSameProfile(profile)) return; - updaters_[process->id()] = - make_linked_ptr(new VisitedLinkUpdater(process->id())); + updaters_[process->GetID()] = + make_linked_ptr(new VisitedLinkUpdater(process->GetID())); // Initialize support for visited links. Send the renderer process its // initial set of visited links. @@ -183,21 +187,22 @@ void VisitedLinkEventListener::Observe( if (!master) return; - updaters_[process->id()]->SendVisitedLinkTable(master->shared_memory()); + updaters_[process->GetID()]->SendVisitedLinkTable( + master->shared_memory()); break; } case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { - RenderProcessHost* process = - content::Source<RenderProcessHost>(source).ptr(); - if (updaters_.count(process->id())) { - updaters_.erase(process->id()); + content::RenderProcessHost* process = + content::Source<content::RenderProcessHost>(source).ptr(); + if (updaters_.count(process->GetID())) { + updaters_.erase(process->GetID()); } break; } case content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED: { RenderWidgetHost* widget = content::Source<RenderWidgetHost>(source).ptr(); - int child_id = widget->process()->id(); + int child_id = widget->process()->GetID(); if (updaters_.count(child_id)) updaters_[child_id]->Update(); break; diff --git a/chrome/browser/visitedlink/visitedlink_unittest.cc b/chrome/browser/visitedlink/visitedlink_unittest.cc index 43e93a1..487c73d 100644 --- a/chrome/browser/visitedlink/visitedlink_unittest.cc +++ b/chrome/browser/visitedlink/visitedlink_unittest.cc @@ -18,7 +18,7 @@ #include "chrome/renderer/visitedlink_slave.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/renderer_host/browser_render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "content/test/test_browser_thread.h" @@ -495,12 +495,12 @@ class VisitCountingProfile : public TestingProfile { scoped_ptr<VisitedLinkMaster> visited_link_master_; }; -// Stub out as little as possible, borrowing from BrowserRenderProcessHost. -class VisitRelayingRenderProcessHost : public BrowserRenderProcessHost { +// Stub out as little as possible, borrowing from RenderProcessHost. +class VisitRelayingRenderProcessHost : public RenderProcessHostImpl { public: explicit VisitRelayingRenderProcessHost( content::BrowserContext* browser_context) - : BrowserRenderProcessHost(browser_context) { + : RenderProcessHostImpl(browser_context) { content::NotificationService::current()->Notify( content::NOTIFICATION_RENDERER_PROCESS_CREATED, content::Source<RenderProcessHost>(this), @@ -509,7 +509,7 @@ class VisitRelayingRenderProcessHost : public BrowserRenderProcessHost { virtual ~VisitRelayingRenderProcessHost() { content::NotificationService::current()->Notify( content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, - content::Source<RenderProcessHost>(this), + content::Source<content::RenderProcessHost>(this), content::NotificationService::NoDetails()); } @@ -532,7 +532,7 @@ class VisitRelayingRenderProcessHost : public BrowserRenderProcessHost { virtual bool Send(IPC::Message* msg) { VisitCountingProfile* counting_profile = static_cast<VisitCountingProfile*>( - Profile::FromBrowserContext(browser_context())); + Profile::FromBrowserContext(GetBrowserContext())); if (msg->type() == ChromeViewMsg_VisitedLink_Add::ID) { void* iter = NULL; @@ -556,11 +556,11 @@ class VisitRelayingRenderProcessHost : public BrowserRenderProcessHost { }; class VisitedLinkRenderProcessHostFactory - : public RenderProcessHostFactory { + : public content::RenderProcessHostFactory { public: VisitedLinkRenderProcessHostFactory() - : RenderProcessHostFactory() {} - virtual RenderProcessHost* CreateRenderProcessHost( + : content::RenderProcessHostFactory() {} + virtual content::RenderProcessHost* CreateRenderProcessHost( content::BrowserContext* browser_context) const OVERRIDE { return new VisitRelayingRenderProcessHost(browser_context); } |