diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-05 05:11:28 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-05 05:11:28 +0000 |
commit | cdf682e4f0a828f76faf0d21c4eb263e51efee62 (patch) | |
tree | 05ca300563d5b6aaaa26c49bcca6ea5e117f2f9e /chrome/browser/net | |
parent | 83530b7c2914d367d2eeb299a7c452794d1761de (diff) | |
download | chromium_src-cdf682e4f0a828f76faf0d21c4eb263e51efee62.zip chromium_src-cdf682e4f0a828f76faf0d21c4eb263e51efee62.tar.gz chromium_src-cdf682e4f0a828f76faf0d21c4eb263e51efee62.tar.bz2 |
Fix Task Manager to correctly display network usage of plug-in processes.
BUG=chromium-os:2954
TEST=Run Chrome and open Task Manager, then play a video in YouTube and check whether the Network usage is correctly reported against the plug-in.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=73884
Review URL: http://codereview.chromium.org/6328010
Patch from James Weatherall <wez@chromium.org>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73915 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/url_request_tracking.cc | 30 | ||||
-rw-r--r-- | chrome/browser/net/url_request_tracking.h | 23 |
2 files changed, 26 insertions, 27 deletions
diff --git a/chrome/browser/net/url_request_tracking.cc b/chrome/browser/net/url_request_tracking.cc index a931856..020aad1 100644 --- a/chrome/browser/net/url_request_tracking.cc +++ b/chrome/browser/net/url_request_tracking.cc @@ -11,37 +11,37 @@ namespace { // The value is not important, this address is used as the unique key for the // PID. -const void* kOriginProcessUniqueIDKey = 0; +const void* kOriginPidKey = 0; -class UniqueIDData : public net::URLRequest::UserData { +class OriginPidData : public net::URLRequest::UserData { public: - explicit UniqueIDData(int id) : id_(id) {} - virtual ~UniqueIDData() {} + explicit OriginPidData(int pid) : pid_(pid) {} + virtual ~OriginPidData() {} - int id() const { return id_; } - void set_id(int id) { id_ = id; } + int pid() const { return pid_; } + void set_pid(int pid) { pid_ = pid; } private: - int id_; + int pid_; - DISALLOW_COPY_AND_ASSIGN(UniqueIDData); + DISALLOW_COPY_AND_ASSIGN(OriginPidData); }; } // namespace namespace chrome_browser_net { -void SetOriginProcessUniqueIDForRequest(int id, net::URLRequest* request) { +void SetOriginPIDForRequest(int pid, net::URLRequest* request) { // The request will take ownership. - request->SetUserData(&kOriginProcessUniqueIDKey, new UniqueIDData(id)); + request->SetUserData(&kOriginPidKey, new OriginPidData(pid)); } -int GetOriginProcessUniqueIDForRequest(const net::URLRequest* request) { - const UniqueIDData* data = static_cast<const UniqueIDData*>( - request->GetUserData(&kOriginProcessUniqueIDKey)); +int GetOriginPIDForRequest(const net::URLRequest* request) { + const OriginPidData* data = static_cast<const OriginPidData*>( + request->GetUserData(&kOriginPidKey)); if (!data) - return -1; - return data->id(); + return 0; + return data->pid(); } } // namespace chrome_browser_net diff --git a/chrome/browser/net/url_request_tracking.h b/chrome/browser/net/url_request_tracking.h index 0e7a7156..497dfb2 100644 --- a/chrome/browser/net/url_request_tracking.h +++ b/chrome/browser/net/url_request_tracking.h @@ -18,20 +18,19 @@ namespace chrome_browser_net { // place allows us to do more general things, such as assigning traffic for the // network view in the task manager. // -// If you make a request on behalf of a child process, please call this -// function. The default value will be -1 which will be interprepreted as -// originating from the browser itself. +// If you make a request on behalf of a child process other than a renderer, +// please call this function to store its PID (NOT its browser-assigned unique +// child ID). For requests originating in a renderer or the browser itself, +// set a PID of zero (the default). // -// The ID is the child process' unique ID (not a PID) of the process originating -// the request. This is normally the renderer corresponding to the load. If a -// plugin process does a request through a renderer process this will be the -// plugin (the originator of the request). -void SetOriginProcessUniqueIDForRequest(int id, net::URLRequest* request); +// TODO(wez): Get rid of the zero-PID hack & enforce that one is always set. +void SetOriginPIDForRequest(int pid, net::URLRequest* request); -// Returns the child process' unique ID that has been previously set by -// SetOriginProcessUniqueIDForRequest. If no ID has been set, the return -// value is -1. We use this to identify requests made by the browser process. -int GetOriginProcessUniqueIDForRequest(const net::URLRequest* request); +// Returns the process ID of the request's originator, previously stored with +// SetOriginProcessIDForRequest, or zero if no PID has been set. A PID of zero +// should be interpreted as meaning the request originated from a renderer +// process, or within the browser itself. +int GetOriginPIDForRequest(const net::URLRequest* request); } // namespace chrome_browser_net |