Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4503)

Unified Diff: chrome/browser/extensions/extension_webrequest_api.h

Issue 6698009: Add request_id to HttpRequestInfo and pass it to the NetworkDelegate for events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 500 error Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_webrequest_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_webrequest_api.h
diff --git a/chrome/browser/extensions/extension_webrequest_api.h b/chrome/browser/extensions/extension_webrequest_api.h
index 32a9317f7687ca1f4071ccc097fbb295cb221f91..174ac32949cdd0878392d76feb1883293fabf584 100644
--- a/chrome/browser/extensions/extension_webrequest_api.h
+++ b/chrome/browser/extensions/extension_webrequest_api.h
@@ -22,6 +22,7 @@ class ExtensionEventRouterForwarder;
class GURL;
namespace net {
+class HttpRequestHeaders;
class URLRequest;
}
@@ -36,11 +37,24 @@ class ExtensionWebRequestEventRouter {
static ExtensionWebRequestEventRouter* GetInstance();
// Dispatches the OnBeforeRequest event to any extensions whose filters match
- // the given request. Returns true if an extension wants to pause the request.
- bool OnBeforeRequest(ProfileId profile_id,
- ExtensionEventRouterForwarder* event_router,
- net::URLRequest* request,
- net::CompletionCallback* callback);
+ // the given request. Returns net::ERR_IO_PENDING if an extension is
+ // intercepting the request, OK otherwise.
+ int OnBeforeRequest(ProfileId profile_id,
+ ExtensionEventRouterForwarder* event_router,
+ net::URLRequest* request,
+ net::CompletionCallback* callback);
+
+ // Dispatches the onBeforeSendHeaders event. This is fired for HTTP(s)
+ // requests only, and allows modification of the outgoing request headers.
+ // Returns net::ERR_IO_PENDING if an extension is intercepting the request, OK
+ // otherwise.
+ int OnBeforeSendHeaders(ProfileId profile_id,
+ ExtensionEventRouterForwarder* event_router,
+ uint64 request_id,
+ net::HttpRequestHeaders* headers,
+ net::CompletionCallback* callback);
+
+ void OnURLRequestDestroyed(ProfileId profile_id, net::URLRequest* request);
// Called when an event listener handles a blocking event and responds.
// TODO(mpcomplete): modify request
@@ -77,10 +91,19 @@ class ExtensionWebRequestEventRouter {
typedef std::map<std::string, std::set<EventListener> > ListenerMapForProfile;
typedef std::map<ProfileId, ListenerMapForProfile> ListenerMap;
typedef std::map<uint64, BlockedRequest> BlockedRequestMap;
+ typedef std::map<uint64, net::URLRequest*> HttpRequestMap;
ExtensionWebRequestEventRouter();
~ExtensionWebRequestEventRouter();
+ bool DispatchEvent(
+ ProfileId profile_id,
+ ExtensionEventRouterForwarder* event_router,
+ net::URLRequest* request,
+ net::CompletionCallback* callback,
+ const std::vector<const EventListener*>& listeners,
+ const ListValue& args);
+
// Returns a list of event listeners that care about the given event, based
// on their filter parameters.
std::vector<const EventListener*> GetMatchingListeners(
@@ -91,11 +114,18 @@ class ExtensionWebRequestEventRouter {
int window_id,
ResourceType::Type resource_type);
+ // Same as above, but retrieves the filter parameters from the request.
+ std::vector<const EventListener*> GetMatchingListeners(
+ ProfileId profile_id,
+ const std::string& event_name,
+ net::URLRequest* request);
// Decrements the count of event handlers blocking the given request. When the
// count reaches 0 (or immediately if the request is being cancelled), we
// stop blocking the request and either resume or cancel it.
void DecrementBlockCount(uint64 request_id, bool cancel);
+ void OnRequestDeleted(net::URLRequest* request);
+
// A map for each profile that maps an event name to a set of extensions that
// are listening to that event.
ListenerMap listeners_;
@@ -104,6 +134,10 @@ class ExtensionWebRequestEventRouter {
// to respond.
BlockedRequestMap blocked_requests_;
+ // A map of HTTP(s) network requests. We use this to look up the URLRequest
+ // from the request ID given to us for HTTP-specific events.
+ HttpRequestMap http_requests_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter);
};
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_webrequest_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698