diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-27 23:11:34 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-27 23:11:34 +0000 |
commit | 5aa2013cf0fd9c0bb03eb2a1de01774bf2848c38 (patch) | |
tree | 2415e8c89e7da63f7834d9ddfaa7adfbcabe54ee /net/base | |
parent | edd91a9b18019e2ea6159cf43b6e0fb0fdc13fbc (diff) | |
download | chromium_src-5aa2013cf0fd9c0bb03eb2a1de01774bf2848c38.zip chromium_src-5aa2013cf0fd9c0bb03eb2a1de01774bf2848c38.tar.gz chromium_src-5aa2013cf0fd9c0bb03eb2a1de01774bf2848c38.tar.bz2 |
Flesh out the onBeforeSendHeaders event a bit more. We now send the
requestHeaders and allow the extension to modify them.
I also changed the network delegate callbacks, so that they accept arguments beyond just a status code, and they do not outlive the object they are bound to.
BUG=60101
TEST=automated
Review URL: http://codereview.chromium.org/6899001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83246 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/network_delegate.cc | 8 | ||||
-rw-r--r-- | net/base/network_delegate.h | 19 |
2 files changed, 19 insertions, 8 deletions
diff --git a/net/base/network_delegate.cc b/net/base/network_delegate.cc index 3062c7b..d018455 100644 --- a/net/base/network_delegate.cc +++ b/net/base/network_delegate.cc @@ -53,8 +53,14 @@ void NetworkDelegate::NotifyCompleted(URLRequest* request) { } void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) { + DCHECK(CalledOnValidThread()); DCHECK(request); - return OnURLRequestDestroyed(request); + OnURLRequestDestroyed(request); +} + +void NetworkDelegate::NotifyHttpTransactionDestroyed(uint64 request_id) { + DCHECK(CalledOnValidThread()); + OnHttpTransactionDestroyed(request_id); } URLRequestJob* NetworkDelegate::MaybeCreateURLRequestJob(URLRequest* request) { diff --git a/net/base/network_delegate.h b/net/base/network_delegate.h index 86949a8..3cc7b45 100644 --- a/net/base/network_delegate.h +++ b/net/base/network_delegate.h @@ -48,6 +48,7 @@ class NetworkDelegate : public base::NonThreadSafe { void NotifyResponseStarted(URLRequest* request); void NotifyCompleted(URLRequest* request); void NotifyURLRequestDestroyed(URLRequest* request); + void NotifyHttpTransactionDestroyed(uint64 request_id); // Returns a URLRequestJob that will be used to handle the request if // non-null. @@ -63,18 +64,18 @@ class NetworkDelegate : public base::NonThreadSafe { // member function, which will perform basic sanity checking. // Called before a request is sent. Allows the delegate to rewrite the URL - // being fetched by modifying |new_url|. The callback can be called at any - // time, but will have no effect if the request has already been cancelled or - // deleted. Returns a net status code, generally either OK to continue with - // the request or ERR_IO_PENDING if the result is not ready yet. + // being fetched by modifying |new_url|. |callback| and |new_url| are valid + // only until OnURLRequestDestroyed is called for this request. Returns a net + // status code, generally either OK to continue with the request or + // ERR_IO_PENDING if the result is not ready yet. virtual int OnBeforeURLRequest(URLRequest* request, CompletionCallback* callback, GURL* new_url) = 0; // Called right before the HTTP headers are sent. Allows the delegate to - // read/write |headers| before they get sent out. The callback can be called - // at any time, but will have no effect if the transaction handling this - // request has been cancelled. Returns a net status code. + // read/write |headers| before they get sent out. |callback| and |headers| are + // valid only until OnHttpTransactionDestroyed is called for this request. + // Returns a net status code. virtual int OnBeforeSendHeaders(uint64 request_id, CompletionCallback* callback, HttpRequestHeaders* headers) = 0; @@ -99,6 +100,10 @@ class NetworkDelegate : public base::NonThreadSafe { // a virtual method call. virtual void OnURLRequestDestroyed(URLRequest* request) = 0; + // Called when the HttpTransaction for the request with the given ID is + // destroyed. + virtual void OnHttpTransactionDestroyed(uint64 request_id) = 0; + // Called before a request is sent and before a URLRequestJob is created to // handle the request. virtual URLRequestJob* OnMaybeCreateURLRequestJob(URLRequest* request) = 0; |