Commit c6e8346b authored by thakis@chromium.org's avatar thakis@chromium.org

Attribute orphaned or anonymous network usage to the Browser resources.

BUG=47955,69883
TEST=When a tab is closed with a download in-progress and Task Manager displayed, the network activity is reflected in the Browser resource's Network total.

Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=72095

Review URL: http://codereview.chromium.org/6383002
Patch from James Weatherall <wez@chromium.org>.

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72105 0039d316-1c4b-4281-b951-d872f2087c98
parent b0fc6317
...@@ -845,10 +845,17 @@ void TaskManagerModel::BytesRead(BytesReadParam param) { ...@@ -845,10 +845,17 @@ void TaskManagerModel::BytesRead(BytesReadParam param) {
if (resource) if (resource)
break; break;
} }
if (resource == NULL) { if (resource == NULL) {
// We may not have that resource anymore (example: close a tab while a // We can't match a resource to the notification. That might mean the
// a network resource is being retrieved), in which case we just ignore the // tab that started a download was closed, or the request may have had
// notification. // no originating resource associated with it in the first place.
// We attribute orphaned/unaccounted activity to the Browser process.
int browser_pid = base::GetCurrentProcId();
CHECK(param.origin_child_id != browser_pid);
param.origin_child_id = browser_pid;
param.render_process_host_child_id = param.routing_id = -1;
BytesRead(param);
return; return;
} }
...@@ -887,18 +894,15 @@ void TaskManagerModel::OnJobRedirect(net::URLRequestJob* job, ...@@ -887,18 +894,15 @@ void TaskManagerModel::OnJobRedirect(net::URLRequestJob* job,
void TaskManagerModel::OnBytesRead(net::URLRequestJob* job, const char* buf, void TaskManagerModel::OnBytesRead(net::URLRequestJob* job, const char* buf,
int byte_count) { int byte_count) {
// Only net::URLRequestJob instances created by the ResourceDispatcherHost
// 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 render_process_host_child_id = -1, routing_id = -1;
if (!ResourceDispatcherHost::RenderViewForRequest(job->request(), ResourceDispatcherHost::RenderViewForRequest(job->request(),
&render_process_host_child_id, &render_process_host_child_id,
&routing_id)) { &routing_id);
// Only net::URLRequestJob instances created by the ResourceDispatcherHost
// have a render view associated. Jobs from components such as the
// SearchProvider for autocomplete, have no associated view, so we can't
// correctly attribute the bandwidth they consume.
// TODO(wez): All jobs' resources should ideally be accountable, even if
// only by contributing to the Browser process' stats.
return;
}
// This happens in the IO thread, post it to the UI thread. // This happens in the IO thread, post it to the UI thread.
int origin_child_id = int origin_child_id =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment