| Index: content/browser/loader/render_view_host_tracker.cc
|
| diff --git a/content/browser/loader/render_view_host_tracker.cc b/content/browser/loader/render_view_host_tracker.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c68b1f9c27c8e0a794efc1cacaf625369de0378b
|
| --- /dev/null
|
| +++ b/content/browser/loader/render_view_host_tracker.cc
|
| @@ -0,0 +1,58 @@
|
| +// Copyright (c) 2013 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/browser/loader/render_view_host_tracker.h"
|
| +
|
| +#include "base/bind_helpers.h"
|
| +#include "content/browser/loader/resource_dispatcher_host_impl.h"
|
| +#include "content/browser/loader/resource_scheduler.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| +#include "content/public/browser/notification_service.h"
|
| +#include "content/public/browser/notification_types.h"
|
| +#include "content/public/browser/render_process_host.h"
|
| +#include "content/public/browser/render_view_host.h"
|
| +
|
| +namespace content {
|
| +
|
| +RenderViewHostTracker::RenderViewHostTracker() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + registrar_.Add(this, NOTIFICATION_RENDER_VIEW_HOST_CREATED,
|
| + NotificationService::AllSources());
|
| + registrar_.Add(this, NOTIFICATION_RENDER_VIEW_HOST_DELETED,
|
| + NotificationService::AllSources());
|
| +}
|
| +
|
| +RenderViewHostTracker::~RenderViewHostTracker() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +}
|
| +
|
| +void RenderViewHostTracker::Observe(
|
| + int type,
|
| + const NotificationSource& source,
|
| + const NotificationDetails& details) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + RenderViewHost* rvh = content::Source<RenderViewHost>(source).ptr();
|
| + int child_id = rvh->GetProcess()->GetID();
|
| + int route_id = rvh->GetRoutingID();
|
| +
|
| + switch (type) {
|
| + case NOTIFICATION_RENDER_VIEW_HOST_CREATED:
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostCreated,
|
| + base::Unretained(ResourceDispatcherHostImpl::Get()),
|
| + child_id, route_id));
|
| + break;
|
| +
|
| + case NOTIFICATION_RENDER_VIEW_HOST_DELETED:
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted,
|
| + base::Unretained(ResourceDispatcherHostImpl::Get()),
|
| + child_id, route_id));
|
| + break;
|
| + }
|
| +}
|
| +
|
| +} // namespace content
|
|
|