summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-30 22:31:51 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-30 22:31:51 +0000
commit4875ba17099e50f482ec826fc38e7922096b7be2 (patch)
tree7bb5ec4498187f7c9673ada84c54aca1c0cdd6e5 /net/base
parentb04f6c6aea3ffd3a03368b67abacc1f36d2f8ce8 (diff)
downloadchromium_src-4875ba17099e50f482ec826fc38e7922096b7be2.zip
chromium_src-4875ba17099e50f482ec826fc38e7922096b7be2.tar.gz
chromium_src-4875ba17099e50f482ec826fc38e7922096b7be2.tar.bz2
Add request_id to HttpRequestInfo and pass it to the NetworkDelegate for events.
This lets us look up the request associated with an http transaction and send event details for the webRequest.onBeforeRequest extension event. I also hooked up the onBeforeRequest event for HTTP network and cache transactions so that they are separate from other requests. This lets us have the request header information. BUG=60101 TEST=no Review URL: http://codereview.chromium.org/6698009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79905 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r--net/base/network_delegate.cc16
-rw-r--r--net/base/network_delegate.h35
2 files changed, 38 insertions, 13 deletions
diff --git a/net/base/network_delegate.cc b/net/base/network_delegate.cc
index 17da7a8..2ed1ea5 100644
--- a/net/base/network_delegate.cc
+++ b/net/base/network_delegate.cc
@@ -8,18 +8,21 @@
namespace net {
-bool NetworkDelegate::NotifyBeforeURLRequest(URLRequest* request,
- CompletionCallback* callback) {
+int NetworkDelegate::NotifyBeforeURLRequest(URLRequest* request,
+ CompletionCallback* callback) {
DCHECK(CalledOnValidThread());
DCHECK(request);
DCHECK(callback);
return OnBeforeURLRequest(request, callback);
}
-void NetworkDelegate::NotifySendHttpRequest(HttpRequestHeaders* headers) {
+int NetworkDelegate::NotifyBeforeSendHeaders(uint64 request_id,
+ HttpRequestHeaders* headers,
+ CompletionCallback* callback) {
DCHECK(CalledOnValidThread());
DCHECK(headers);
- OnSendHttpRequest(headers);
+ DCHECK(callback);
+ return OnBeforeSendHeaders(request_id, headers, callback);
}
void NetworkDelegate::NotifyResponseStarted(URLRequest* request) {
@@ -34,6 +37,11 @@ void NetworkDelegate::NotifyReadCompleted(URLRequest* request, int bytes_read) {
OnReadCompleted(request, bytes_read);
}
+void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) {
+ DCHECK(request);
+ return OnURLRequestDestroyed(request);
+}
+
URLRequestJob* NetworkDelegate::MaybeCreateURLRequestJob(URLRequest* request) {
DCHECK(CalledOnValidThread());
DCHECK(request);
diff --git a/net/base/network_delegate.h b/net/base/network_delegate.h
index 284728b4..effc699 100644
--- a/net/base/network_delegate.h
+++ b/net/base/network_delegate.h
@@ -31,12 +31,16 @@ class NetworkDelegate : public base::NonThreadSafe {
// Notification interface called by the network stack. Note that these
// functions mostly forward to the private virtuals. They also add some sanity
- // checking on parameters.
- bool NotifyBeforeURLRequest(URLRequest* request,
+ // checking on parameters. See the corresponding virtuals for explanations of
+ // the methods and their arguments.
+ int NotifyBeforeURLRequest(URLRequest* request,
+ CompletionCallback* callback);
+ int NotifyBeforeSendHeaders(uint64 request_id,
+ HttpRequestHeaders* headers,
CompletionCallback* callback);
- void NotifySendHttpRequest(HttpRequestHeaders* headers);
void NotifyResponseStarted(URLRequest* request);
void NotifyReadCompleted(URLRequest* request, int bytes_read);
+ void NotifyURLRequestDestroyed(URLRequest* request);
// Returns a URLRequestJob that will be used to handle the request if
// non-null.
@@ -51,13 +55,20 @@ class NetworkDelegate : public base::NonThreadSafe {
// member functions will be called by the respective public notification
// member function, which will perform basic sanity checking.
- // Called before a request is sent.
- virtual bool OnBeforeURLRequest(URLRequest* request,
- CompletionCallback* callback) = 0;
+ // Called before a request is sent. 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.
+ virtual int OnBeforeURLRequest(URLRequest* request,
+ CompletionCallback* callback) = 0;
- // Called right before the HTTP headers are sent. Allows the delegate to
- // read/write |headers| before they get sent out.
- virtual void OnSendHttpRequest(HttpRequestHeaders* headers) = 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.
+ virtual int OnBeforeSendHeaders(uint64 request_id,
+ HttpRequestHeaders* headers,
+ CompletionCallback* callback) = 0;
// This corresponds to URLRequestDelegate::OnResponseStarted.
virtual void OnResponseStarted(URLRequest* request) = 0;
@@ -65,9 +76,15 @@ class NetworkDelegate : public base::NonThreadSafe {
// This corresponds to URLRequestDelegate::OnReadCompleted.
virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0;
+ // Called when an URLRequest is being destroyed. Note that the request is
+ // being deleted, so it's not safe to call any methods that may result in
+ // a virtual method call.
+ virtual void OnURLRequestDestroyed(URLRequest* request) = 0;
+
// Called before a request is sent and before a URLRequestJob is created to
// handle the request.
virtual URLRequestJob* OnMaybeCreateURLRequestJob(URLRequest* request) = 0;
+
};
} // namespace net