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

Side by Side Diff: content/browser/loader/render_view_host_tracker.cc

Issue 12600018: ResourceScheduler should use renderer notifications instead of MRUCache to track renderers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename to RenderViewHostTracker Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/loader/render_view_host_tracker.h"
6
7 #include "base/bind_helpers.h"
8 #include "content/browser/loader/resource_dispatcher_host_impl.h"
9 #include "content/browser/loader/resource_scheduler.h"
10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/notification_service.h"
12 #include "content/public/browser/notification_types.h"
13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/render_view_host.h"
15
16 namespace content {
17
18 RenderViewHostTracker::RenderViewHostTracker() {
19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
20 registrar_.Add(this, NOTIFICATION_RENDER_VIEW_HOST_CREATED,
21 NotificationService::AllSources());
22 registrar_.Add(this, NOTIFICATION_RENDER_VIEW_HOST_DELETED,
23 NotificationService::AllSources());
24 }
25
26 RenderViewHostTracker::~RenderViewHostTracker() {
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
28 }
29
30 void RenderViewHostTracker::Observe(
31 int type,
32 const NotificationSource& source,
33 const NotificationDetails& details) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
35 RenderViewHost* rvh = content::Source<RenderViewHost>(source).ptr();
36 int child_id = rvh->GetProcess()->GetID();
37 int route_id = rvh->GetRoutingID();
38
39 switch (type) {
40 case NOTIFICATION_RENDER_VIEW_HOST_CREATED:
41 BrowserThread::PostTask(
42 BrowserThread::IO, FROM_HERE,
43 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostCreated,
44 base::Unretained(ResourceDispatcherHostImpl::Get()),
45 child_id, route_id));
46 break;
47
48 case NOTIFICATION_RENDER_VIEW_HOST_DELETED:
49 BrowserThread::PostTask(
50 BrowserThread::IO, FROM_HERE,
51 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted,
52 base::Unretained(ResourceDispatcherHostImpl::Get()),
53 child_id, route_id));
54 break;
55 }
56 }
57
58 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698