| Index: content/public/test/mock_render_process_host.cc
|
| diff --git a/content/public/test/mock_render_process_host.cc b/content/public/test/mock_render_process_host.cc
|
| index c42bda6f3268ff5819a53b94f44f0d4c4371ac3d..ad39a3496f25a30aa92d90e04dab2ed1cac43ee5 100644
|
| --- a/content/public/test/mock_render_process_host.cc
|
| +++ b/content/public/test/mock_render_process_host.cc
|
| @@ -9,6 +9,7 @@
|
| #include "base/time.h"
|
| #include "content/browser/child_process_security_policy_impl.h"
|
| #include "content/browser/renderer_host/render_process_host_impl.h"
|
| +#include "content/browser/renderer_host/render_view_host_impl.h"
|
| #include "content/browser/renderer_host/render_widget_host_impl.h"
|
| #include "content/common/child_process_host_impl.h"
|
| #include "content/public/browser/notification_service.h"
|
| @@ -53,6 +54,18 @@ int MockRenderProcessHost::GetNextRoutingID() {
|
| return ++prev_routing_id;
|
| }
|
|
|
| +void MockRenderProcessHost::AddRoute(
|
| + int32 routing_id,
|
| + IPC::Listener* listener) {
|
| + listeners_.AddWithID(listener, routing_id);
|
| +}
|
| +
|
| +void MockRenderProcessHost::RemoveRoute(int32 routing_id) {
|
| + DCHECK(listeners_.Lookup(routing_id) != NULL);
|
| + listeners_.Remove(routing_id);
|
| + Cleanup();
|
| +}
|
| +
|
| bool MockRenderProcessHost::WaitForBackingStoreMsg(
|
| int render_widget_id,
|
| const base::TimeDelta& max_delay,
|
| @@ -153,18 +166,8 @@ bool MockRenderProcessHost::IgnoreInputEvents() const {
|
| return false;
|
| }
|
|
|
| -void MockRenderProcessHost::Attach(RenderWidgetHost* host,
|
| - int routing_id) {
|
| - render_widget_hosts_.AddWithID(host, routing_id);
|
| -}
|
| -
|
| -void MockRenderProcessHost::Release(int routing_id) {
|
| - render_widget_hosts_.Remove(routing_id);
|
| - Cleanup();
|
| -}
|
| -
|
| void MockRenderProcessHost::Cleanup() {
|
| - if (render_widget_hosts_.IsEmpty()) {
|
| + if (listeners_.IsEmpty()) {
|
| NotificationService::current()->Notify(
|
| NOTIFICATION_RENDERER_PROCESS_TERMINATED,
|
| Source<RenderProcessHost>(this),
|
| @@ -187,11 +190,6 @@ bool MockRenderProcessHost::SuddenTerminationAllowed() const {
|
| return true;
|
| }
|
|
|
| -RenderWidgetHost* MockRenderProcessHost::GetRenderWidgetHostByID(
|
| - int routing_id) {
|
| - return render_widget_hosts_.Lookup(routing_id);
|
| -}
|
| -
|
| BrowserContext* MockRenderProcessHost::GetBrowserContext() const {
|
| return browser_context_;
|
| }
|
| @@ -206,8 +204,30 @@ IPC::ChannelProxy* MockRenderProcessHost::GetChannel() {
|
| return NULL;
|
| }
|
|
|
| +int MockRenderProcessHost::GetActiveViewCount() {
|
| + int num_active_views = 0;
|
| + RenderWidgetHost::List widgets = RenderWidgetHost::GetRenderWidgetHosts();
|
| + for (size_t i = 0; i < widgets.size(); ++i) {
|
| + // Count only RenderWidgetHosts in this process.
|
| + if (widgets[i]->GetProcess()->GetID() != GetID())
|
| + continue;
|
| +
|
| + // All RenderWidgetHosts are swapped in.
|
| + if (!widgets[i]->IsRenderView()) {
|
| + num_active_views++;
|
| + continue;
|
| + }
|
| +
|
| + // Don't count swapped out views.
|
| + RenderViewHost* rvh = RenderViewHost::From(widgets[i]);
|
| + if (!static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out())
|
| + num_active_views++;
|
| + }
|
| + return num_active_views;
|
| +}
|
| +
|
| bool MockRenderProcessHost::FastShutdownForPageCount(size_t count) {
|
| - if (render_widget_hosts_.size() == count)
|
| + if (static_cast<size_t>(GetActiveViewCount()) == count)
|
| return FastShutdownIfPossible();
|
| return false;
|
| }
|
| @@ -222,15 +242,11 @@ void MockRenderProcessHost::SurfaceUpdated(int32 surface_id) {
|
| void MockRenderProcessHost::ResumeRequestsForView(int route_id) {
|
| }
|
|
|
| -RenderProcessHost::RenderWidgetHostsIterator
|
| - MockRenderProcessHost::GetRenderWidgetHostsIterator() {
|
| - return RenderWidgetHostsIterator(&render_widget_hosts_);
|
| -}
|
|
|
| bool MockRenderProcessHost::OnMessageReceived(const IPC::Message& msg) {
|
| - RenderWidgetHost* rwh = render_widget_hosts_.Lookup(msg.routing_id());
|
| - if (rwh)
|
| - return RenderWidgetHostImpl::From(rwh)->OnMessageReceived(msg);
|
| + IPC::Listener* listener = listeners_.Lookup(msg.routing_id());
|
| + if (listener)
|
| + return listener->OnMessageReceived(msg);
|
| return false;
|
| }
|
|
|
|
|