diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-03 00:17:47 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-03 00:17:47 +0000 |
commit | 3b490c88625d5468075fa68e711c5a36103c0fcb (patch) | |
tree | 59df2ee9748bc675f6e5339aea19a2429a658f11 /chrome/browser/task_manager | |
parent | 2f9b4ff9c8d3de972bcc3eb8e36ec427a9d18f9b (diff) | |
download | chromium_src-3b490c88625d5468075fa68e711c5a36103c0fcb.zip chromium_src-3b490c88625d5468075fa68e711c5a36103c0fcb.tar.gz chromium_src-3b490c88625d5468075fa68e711c5a36103c0fcb.tar.bz2 |
Replace the GetAssociatedRenderView call with GetAssociatedRenderFrame in task manager code.
BUG=304341
R=nasko@chromium.org
Review URL: https://codereview.chromium.org/123503004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242844 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/task_manager')
21 files changed, 94 insertions, 82 deletions
diff --git a/chrome/browser/task_manager/background_resource_provider.cc b/chrome/browser/task_manager/background_resource_provider.cc index 0aeb3e83..4e72f90 100644 --- a/chrome/browser/task_manager/background_resource_provider.cc +++ b/chrome/browser/task_manager/background_resource_provider.cc @@ -19,6 +19,7 @@ #include "chrome/browser/task_manager/resource_provider.h" #include "chrome/browser/task_manager/task_manager.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" @@ -133,19 +134,21 @@ BackgroundContentsResourceProvider::~BackgroundContentsResourceProvider() { Resource* BackgroundContentsResourceProvider::GetResource( int origin_pid, - int render_process_host_id, - int routing_id) { + int child_id, + int route_id) { // If an origin PID was specified, the request is from a plugin, not the // render view host process if (origin_pid) return NULL; + content::RenderFrameHost* rfh = + content::RenderFrameHost::FromID(child_id, route_id); + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost(rfh); + for (Resources::iterator i = resources_.begin(); i != resources_.end(); i++) { - WebContents* tab = i->first->web_contents(); - if (tab->GetRenderProcessHost()->GetID() == render_process_host_id - && tab->GetRenderViewHost()->GetRoutingID() == routing_id) { + if (web_contents == i->first->web_contents()) return i->second; - } } // Can happen if the page went away while a network request was being diff --git a/chrome/browser/task_manager/background_resource_provider.h b/chrome/browser/task_manager/background_resource_provider.h index a6d1ee6..c4b0ec3 100644 --- a/chrome/browser/task_manager/background_resource_provider.h +++ b/chrome/browser/task_manager/background_resource_provider.h @@ -27,8 +27,8 @@ class BackgroundContentsResourceProvider explicit BackgroundContentsResourceProvider(TaskManager* task_manager); virtual Resource* GetResource(int origin_pid, - int render_process_host_id, - int routing_id) OVERRIDE; + int child_id, + int route_id) OVERRIDE; virtual void StartUpdating() OVERRIDE; virtual void StopUpdating() OVERRIDE; diff --git a/chrome/browser/task_manager/browser_process_resource_provider.cc b/chrome/browser/task_manager/browser_process_resource_provider.cc index 01ed0a2..3cc7bce 100644 --- a/chrome/browser/task_manager/browser_process_resource_provider.cc +++ b/chrome/browser/task_manager/browser_process_resource_provider.cc @@ -143,9 +143,9 @@ BrowserProcessResourceProvider::~BrowserProcessResourceProvider() { Resource* BrowserProcessResourceProvider::GetResource( int origin_pid, - int render_process_host_id, - int routing_id) { - if (origin_pid || render_process_host_id != -1) { + int child_id, + int route_id) { + if (origin_pid || child_id != -1) { return NULL; } diff --git a/chrome/browser/task_manager/browser_process_resource_provider.h b/chrome/browser/task_manager/browser_process_resource_provider.h index b625e2b..a76c4e1 100644 --- a/chrome/browser/task_manager/browser_process_resource_provider.h +++ b/chrome/browser/task_manager/browser_process_resource_provider.h @@ -64,8 +64,8 @@ class BrowserProcessResourceProvider : public ResourceProvider { explicit BrowserProcessResourceProvider(TaskManager* task_manager); virtual Resource* GetResource(int origin_pid, - int render_process_host_id, - int routing_id) OVERRIDE; + int child_id, + int route_id) OVERRIDE; virtual void StartUpdating() OVERRIDE; virtual void StopUpdating() OVERRIDE; diff --git a/chrome/browser/task_manager/child_process_resource_provider.cc b/chrome/browser/task_manager/child_process_resource_provider.cc index 1639bb4..eb0510c 100644 --- a/chrome/browser/task_manager/child_process_resource_provider.cc +++ b/chrome/browser/task_manager/child_process_resource_provider.cc @@ -219,8 +219,8 @@ ChildProcessResourceProvider::~ChildProcessResourceProvider() { Resource* ChildProcessResourceProvider::GetResource( int origin_pid, - int render_process_host_id, - int routing_id) { + int child_id, + int route_id) { PidResourceMap::iterator iter = pid_to_resources_.find(origin_pid); if (iter != pid_to_resources_.end()) return iter->second; diff --git a/chrome/browser/task_manager/child_process_resource_provider.h b/chrome/browser/task_manager/child_process_resource_provider.h index cd20162..6998d6d 100644 --- a/chrome/browser/task_manager/child_process_resource_provider.h +++ b/chrome/browser/task_manager/child_process_resource_provider.h @@ -30,8 +30,8 @@ class ChildProcessResourceProvider explicit ChildProcessResourceProvider(TaskManager* task_manager); virtual Resource* GetResource(int origin_pid, - int render_process_host_id, - int routing_id) OVERRIDE; + int child_id, + int route_id) OVERRIDE; virtual void StartUpdating() OVERRIDE; virtual void StopUpdating() OVERRIDE; diff --git a/chrome/browser/task_manager/extension_process_resource_provider.cc b/chrome/browser/task_manager/extension_process_resource_provider.cc index 7ace7f6..1db73a1 100644 --- a/chrome/browser/task_manager/extension_process_resource_provider.cc +++ b/chrome/browser/task_manager/extension_process_resource_provider.cc @@ -18,6 +18,7 @@ #include "chrome/browser/task_manager/task_manager_util.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/site_instance.h" @@ -177,18 +178,23 @@ ExtensionProcessResourceProvider::~ExtensionProcessResourceProvider() { Resource* ExtensionProcessResourceProvider::GetResource( int origin_pid, - int render_process_host_id, - int routing_id) { + int child_id, + int route_id) { // If an origin PID was specified, the request is from a plugin, not the // render view host process if (origin_pid) return NULL; + content::RenderFrameHost* rfh = + content::RenderFrameHost::FromID(child_id, route_id); + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost(rfh); + for (ExtensionRenderViewHostMap::iterator i = resources_.begin(); i != resources_.end(); i++) { - if (i->first->GetSiteInstance()->GetProcess()->GetID() == - render_process_host_id && - i->first->GetRoutingID() == routing_id) + content::WebContents* view_contents = + content::WebContents::FromRenderViewHost(i->first); + if (web_contents == view_contents) return i->second; } diff --git a/chrome/browser/task_manager/extension_process_resource_provider.h b/chrome/browser/task_manager/extension_process_resource_provider.h index a70c6c7..9c6e634 100644 --- a/chrome/browser/task_manager/extension_process_resource_provider.h +++ b/chrome/browser/task_manager/extension_process_resource_provider.h @@ -29,8 +29,8 @@ class ExtensionProcessResourceProvider explicit ExtensionProcessResourceProvider(TaskManager* task_manager); virtual Resource* GetResource(int origin_pid, - int render_process_host_id, - int routing_id) OVERRIDE; + int child_id, + int route_id) OVERRIDE; virtual void StartUpdating() OVERRIDE; virtual void StopUpdating() OVERRIDE; diff --git a/chrome/browser/task_manager/guest_resource_provider.cc b/chrome/browser/task_manager/guest_resource_provider.cc index b27678b..2e341e4 100644 --- a/chrome/browser/task_manager/guest_resource_provider.cc +++ b/chrome/browser/task_manager/guest_resource_provider.cc @@ -13,6 +13,7 @@ #include "chrome/browser/task_manager/task_manager.h" #include "chrome/browser/task_manager/task_manager_util.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_iterator.h" @@ -108,21 +109,23 @@ GuestResourceProvider::~GuestResourceProvider() { Resource* GuestResourceProvider::GetResource( int origin_pid, - int render_process_host_id, - int routing_id) { + int child_id, + int route_id) { // If an origin PID was specified then the request originated in a plugin // working on the WebContents's behalf, so ignore it. if (origin_pid) return NULL; + content::RenderFrameHost* rfh = + content::RenderFrameHost::FromID(child_id, route_id); + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost(rfh); + for (GuestResourceMap::iterator i = resources_.begin(); i != resources_.end(); ++i) { - WebContents* contents = WebContents::FromRenderViewHost(i->first); - if (contents && - contents->GetRenderProcessHost()->GetID() == render_process_host_id && - contents->GetRenderViewHost()->GetRoutingID() == routing_id) { + WebContents* guest_contents = WebContents::FromRenderViewHost(i->first); + if (web_contents == guest_contents) return i->second; - } } return NULL; diff --git a/chrome/browser/task_manager/guest_resource_provider.h b/chrome/browser/task_manager/guest_resource_provider.h index f4970d4..17d390a 100644 --- a/chrome/browser/task_manager/guest_resource_provider.h +++ b/chrome/browser/task_manager/guest_resource_provider.h @@ -29,8 +29,8 @@ class GuestResourceProvider : public ResourceProvider, // ResourceProvider methods: virtual Resource* GetResource(int origin_pid, - int render_process_host_id, - int routing_id) OVERRIDE; + int child_id, + int route_id) OVERRIDE; virtual void StartUpdating() OVERRIDE; virtual void StopUpdating() OVERRIDE; diff --git a/chrome/browser/task_manager/notification_resource_provider.cc b/chrome/browser/task_manager/notification_resource_provider.cc index 2723631..0b317c5 100644 --- a/chrome/browser/task_manager/notification_resource_provider.cc +++ b/chrome/browser/task_manager/notification_resource_provider.cc @@ -133,8 +133,8 @@ NotificationResourceProvider::~NotificationResourceProvider() { Resource* NotificationResourceProvider::GetResource( int origin_pid, - int render_process_host_id, - int routing_id) { + int child_id, + int route_id) { // TODO(johnnyg): provide resources by pid if necessary. return NULL; } diff --git a/chrome/browser/task_manager/notification_resource_provider.h b/chrome/browser/task_manager/notification_resource_provider.h index 4508123..eb3a730 100644 --- a/chrome/browser/task_manager/notification_resource_provider.h +++ b/chrome/browser/task_manager/notification_resource_provider.h @@ -27,8 +27,8 @@ class NotificationResourceProvider : public ResourceProvider, // ResourceProvider interface virtual Resource* GetResource(int origin_pid, - int render_process_host_id, - int routing_id) OVERRIDE; + int child_id, + int route_id) OVERRIDE; virtual void StartUpdating() OVERRIDE; virtual void StopUpdating() OVERRIDE; diff --git a/chrome/browser/task_manager/panel_resource_provider.cc b/chrome/browser/task_manager/panel_resource_provider.cc index d714e18..18ea3b5 100644 --- a/chrome/browser/task_manager/panel_resource_provider.cc +++ b/chrome/browser/task_manager/panel_resource_provider.cc @@ -15,6 +15,7 @@ #include "chrome/browser/ui/panels/panel.h" #include "chrome/browser/ui/panels/panel_manager.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" @@ -120,21 +121,22 @@ PanelResourceProvider::~PanelResourceProvider() { Resource* PanelResourceProvider::GetResource( int origin_pid, - int render_process_host_id, - int routing_id) { + int child_id, + int route_id) { // If an origin PID was specified, the request is from a plugin, not the // render view host process if (origin_pid) return NULL; + content::RenderFrameHost* rfh = + content::RenderFrameHost::FromID(child_id, route_id); + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost(rfh); + for (PanelResourceMap::iterator i = resources_.begin(); i != resources_.end(); ++i) { - WebContents* contents = i->first->GetWebContents(); - if (contents && - contents->GetRenderProcessHost()->GetID() == render_process_host_id && - contents->GetRenderViewHost()->GetRoutingID() == routing_id) { + if (web_contents == i->first->GetWebContents()) return i->second; - } } // Can happen if the panel went away while a network request was being diff --git a/chrome/browser/task_manager/panel_resource_provider.h b/chrome/browser/task_manager/panel_resource_provider.h index 66dcbea..2c7a669 100644 --- a/chrome/browser/task_manager/panel_resource_provider.h +++ b/chrome/browser/task_manager/panel_resource_provider.h @@ -28,8 +28,8 @@ class PanelResourceProvider : public ResourceProvider, // ResourceProvider methods: virtual Resource* GetResource(int origin_pid, - int render_process_host_id, - int routing_id) OVERRIDE; + int child_id, + int route_id) OVERRIDE; virtual void StartUpdating() OVERRIDE; virtual void StopUpdating() OVERRIDE; diff --git a/chrome/browser/task_manager/resource_provider.h b/chrome/browser/task_manager/resource_provider.h index 5008db7..322092f 100644 --- a/chrome/browser/task_manager/resource_provider.h +++ b/chrome/browser/task_manager/resource_provider.h @@ -157,9 +157,9 @@ class ResourceProvider : public base::RefCountedThreadSafe<ResourceProvider> { public: // Should return the resource associated to the specified ids, or NULL if // the resource does not belong to this provider. - virtual Resource* GetResource(int process_id, - int render_process_host_id, - int routing_id) = 0; + virtual Resource* GetResource(int origin_pid, + int child_id, + int route_id) = 0; virtual void StartUpdating() = 0; virtual void StopUpdating() = 0; diff --git a/chrome/browser/task_manager/tab_contents_resource_provider.cc b/chrome/browser/task_manager/tab_contents_resource_provider.cc index 45ac0ffa..9b79cc1 100644 --- a/chrome/browser/task_manager/tab_contents_resource_provider.cc +++ b/chrome/browser/task_manager/tab_contents_resource_provider.cc @@ -26,6 +26,7 @@ #include "chrome/browser/ui/browser_iterator.h" #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" #include "extensions/common/constants.h" @@ -183,12 +184,12 @@ TabContentsResourceProvider::~TabContentsResourceProvider() { Resource* TabContentsResourceProvider::GetResource( int origin_pid, - int render_process_host_id, - int routing_id) { - WebContents* web_contents = - tab_util::GetWebContentsByID(render_process_host_id, routing_id); - if (!web_contents) // Not one of our resource. - return NULL; + int child_id, + int route_id) { + content::RenderFrameHost* rfh = + content::RenderFrameHost::FromID(child_id, route_id); + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost(rfh); // If an origin PID was specified then the request originated in a plugin // working on the WebContents's behalf, so ignore it. diff --git a/chrome/browser/task_manager/tab_contents_resource_provider.h b/chrome/browser/task_manager/tab_contents_resource_provider.h index 3795e25..da2bb82 100644 --- a/chrome/browser/task_manager/tab_contents_resource_provider.h +++ b/chrome/browser/task_manager/tab_contents_resource_provider.h @@ -32,8 +32,8 @@ class TabContentsResourceProvider : public ResourceProvider, explicit TabContentsResourceProvider(TaskManager* task_manager); virtual Resource* GetResource(int origin_pid, - int render_process_host_id, - int routing_id) OVERRIDE; + int child_id, + int route_id) OVERRIDE; virtual void StartUpdating() OVERRIDE; virtual void StopUpdating() OVERRIDE; diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc index 8ceb778..efb88c9 100644 --- a/chrome/browser/task_manager/task_manager.cc +++ b/chrome/browser/task_manager/task_manager.cc @@ -1246,16 +1246,14 @@ void TaskManagerModel::NotifyBytesRead(const net::URLRequest& request, DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); // Only net::URLRequestJob instances created by the ResourceDispatcherHost - // have an associated ResourceRequestInfo. + // have an associated ResourceRequestInfo and a render frame associated. + // All other jobs will have -1 returned for the render process child and + // routing ids - the jobs may still match a resource based on their origin id, + // otherwise BytesRead() will attribute the activity to the Browser resource. const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); - - // have a render view associated. All other jobs will have -1 returned for - // the render process child and routing ids - the jobs may still match a - // resource based on their origin id, otherwise BytesRead() will attribute - // the activity to the Browser resource. - int render_process_host_child_id = -1, routing_id = -1; + int child_id = -1, route_id = -1; if (info) - info->GetAssociatedRenderView(&render_process_host_child_id, &routing_id); + info->GetAssociatedRenderFrame(&child_id, &route_id); // Get the origin PID of the request's originator. This will only be set for // plugins - for renderer or browser initiated requests it will be zero. @@ -1271,8 +1269,7 @@ void TaskManagerModel::NotifyBytesRead(const net::URLRequest& request, } bytes_read_buffer_.push_back( - BytesReadParam(origin_pid, render_process_host_child_id, - routing_id, byte_count)); + BytesReadParam(origin_pid, child_id, route_id, byte_count)); } // This is called on the UI thread. @@ -1343,8 +1340,8 @@ void TaskManagerModel::BytesRead(BytesReadParam param) { for (ResourceProviderList::iterator iter = providers_.begin(); iter != providers_.end(); ++iter) { resource = (*iter)->GetResource(param.origin_pid, - param.render_process_host_child_id, - param.routing_id); + param.child_id, + param.route_id); if (resource) break; } @@ -1354,9 +1351,9 @@ void TaskManagerModel::BytesRead(BytesReadParam param) { // tab that started a download was closed, or the request may have had // no originating resource associated with it in the first place. // We attribute orphaned/unaccounted activity to the Browser process. - CHECK(param.origin_pid || (param.render_process_host_child_id != -1)); + CHECK(param.origin_pid || (param.child_id != -1)); param.origin_pid = 0; - param.render_process_host_child_id = param.routing_id = -1; + param.child_id = param.route_id = -1; BytesRead(param); return; } diff --git a/chrome/browser/task_manager/task_manager.h b/chrome/browser/task_manager/task_manager.h index f885c81..c5a1017 100644 --- a/chrome/browser/task_manager/task_manager.h +++ b/chrome/browser/task_manager/task_manager.h @@ -429,22 +429,22 @@ class TaskManagerModel : public base::RefCountedThreadSafe<TaskManagerModel> { // This struct is used to exchange information between the io and ui threads. struct BytesReadParam { BytesReadParam(int origin_pid, - int render_process_host_child_id, - int routing_id, + int child_id, + int route_id, int byte_count) : origin_pid(origin_pid), - render_process_host_child_id(render_process_host_child_id), - routing_id(routing_id), + child_id(child_id), + route_id(route_id), byte_count(byte_count) {} // The process ID that triggered the request. For plugin requests this // will differ from the renderer process ID. int origin_pid; - // The child ID of the RenderProcessHost this request was routed through. - int render_process_host_child_id; + // The child ID of the process this request was routed through. + int child_id; - int routing_id; + int route_id; int byte_count; }; diff --git a/chrome/browser/task_manager/worker_resource_provider.cc b/chrome/browser/task_manager/worker_resource_provider.cc index 7aee456..f9e702e 100644 --- a/chrome/browser/task_manager/worker_resource_provider.cc +++ b/chrome/browser/task_manager/worker_resource_provider.cc @@ -185,8 +185,8 @@ WorkerResourceProvider::~WorkerResourceProvider() { Resource* WorkerResourceProvider::GetResource( int origin_pid, - int render_process_host_id, - int routing_id) { + int child_id, + int route_id) { return NULL; } diff --git a/chrome/browser/task_manager/worker_resource_provider.h b/chrome/browser/task_manager/worker_resource_provider.h index e7f4388..25df691 100644 --- a/chrome/browser/task_manager/worker_resource_provider.h +++ b/chrome/browser/task_manager/worker_resource_provider.h @@ -36,8 +36,8 @@ class WorkerResourceProvider : public ResourceProvider, // ResourceProvider implementation. virtual Resource* GetResource(int origin_pid, - int render_process_host_id, - int routing_id) OVERRIDE; + int child_id, + int route_id) OVERRIDE; virtual void StartUpdating() OVERRIDE; virtual void StopUpdating() OVERRIDE; |