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

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: delegate callbcak 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
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 0cd52a35093d3a9717b59330f23cc6eaf13e7be2..ce8e98d36aafda75fd29640032a6305be3ab7fb7 100644
--- a/chrome/browser/extensions/extension_webrequest_api.h
+++ b/chrome/browser/extensions/extension_webrequest_api.h
@@ -21,6 +21,7 @@ class ExtensionEventRouterForwarder;
class GURL;
namespace net {
+class HttpRequestHeaders;
class URLRequest;
}
@@ -41,6 +42,14 @@ class ExtensionWebRequestEventRouter {
net::URLRequest* request,
net::CompletionCallback* callback);
+ // Same as above, but for HTTP(s) requests. This version includes the request
+ // headers about to be sent.
+ bool OnBeforeSendHeaders(ProfileId profile_id,
+ ExtensionEventRouterForwarder* event_router,
+ uint64 request_id,
+ net::HttpRequestHeaders* headers,
+ net::CompletionCallback* callback);
+
// Called when an event listener handles a blocking event and responds.
// TODO(mpcomplete): modify request
void OnEventHandled(
@@ -73,23 +82,42 @@ class ExtensionWebRequestEventRouter {
friend struct DefaultSingletonTraits<ExtensionWebRequestEventRouter>;
struct EventListener;
struct BlockedRequest;
+ class TrackedRequest;
+ friend class TrackedRequest;
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, TrackedRequest*> 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(
ProfileId profile_id, const std::string& event_name, const GURL& url);
+ // 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_;
@@ -98,6 +126,10 @@ class ExtensionWebRequestEventRouter {
// to respond.
BlockedRequestMap blocked_requests_;
+ // A map of HTTP(s) network requests. We don't dispatch onBeforeRequest for
+ // these requests until headers are available.
+ HttpRequestMap http_requests_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter);
};

Powered by Google App Engine
This is Rietveld 408576698