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

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

Issue 7024056: Handle extension webrequest API on the IO thread. This speeds up blocking event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 6 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 891370274a6170ec4331f18bbffd9c625216e702..161643a5e0a1eff8bfa5c816c96ad2e3fc8009d6 100644
--- a/chrome/browser/extensions/extension_webrequest_api.h
+++ b/chrome/browser/extensions/extension_webrequest_api.h
@@ -21,7 +21,7 @@
#include "webkit/glue/resource_type.h"
class DictionaryValue;
-class ExtensionEventRouterForwarder;
+class ExtensionInfoMap;
class GURL;
class ListValue;
class StringValue;
@@ -109,7 +109,7 @@ class ExtensionWebRequestEventRouter {
// 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,
+ ExtensionInfoMap* extension_info_map,
net::URLRequest* request,
net::CompletionCallback* callback,
GURL* new_url);
@@ -119,7 +119,7 @@ class ExtensionWebRequestEventRouter {
// Returns net::ERR_IO_PENDING if an extension is intercepting the request, OK
// otherwise.
int OnBeforeSendHeaders(ProfileId profile_id,
- ExtensionEventRouterForwarder* event_router,
+ ExtensionInfoMap* extension_info_map,
uint64 request_id,
net::CompletionCallback* callback,
net::HttpRequestHeaders* headers);
@@ -127,7 +127,7 @@ class ExtensionWebRequestEventRouter {
// Dispatches the onRequestSent event. This is fired for HTTP(s) requests
// only.
void OnRequestSent(ProfileId profile_id,
- ExtensionEventRouterForwarder* event_router,
+ ExtensionInfoMap* extension_info_map,
uint64 request_id,
const net::HostPortPair& socket_address,
const net::HttpRequestHeaders& headers);
@@ -135,24 +135,24 @@ class ExtensionWebRequestEventRouter {
// Dispatches the onBeforeRedirect event. This is fired for HTTP(s) requests
// only.
void OnBeforeRedirect(ProfileId profile_id,
- ExtensionEventRouterForwarder* event_router,
+ ExtensionInfoMap* extension_info_map,
net::URLRequest* request,
const GURL& new_location);
// Dispatches the onResponseStarted event indicating that the first bytes of
// the response have arrived.
void OnResponseStarted(ProfileId profile_id,
- ExtensionEventRouterForwarder* event_router,
+ ExtensionInfoMap* extension_info_map,
net::URLRequest* request);
// Dispatches the onComplete event.
void OnCompleted(ProfileId profile_id,
- ExtensionEventRouterForwarder* event_router,
+ ExtensionInfoMap* extension_info_map,
net::URLRequest* request);
// Dispatches an onErrorOccurred event.
void OnErrorOccurred(ProfileId profile_id,
- ExtensionEventRouterForwarder* event_router,
+ ExtensionInfoMap* extension_info_map,
net::URLRequest* request);
// Notifications when objects are going away.
@@ -178,7 +178,8 @@ class ExtensionWebRequestEventRouter {
const std::string& event_name,
const std::string& sub_event_name,
const RequestFilter& filter,
- int extra_info_spec);
+ int extra_info_spec,
+ base::WeakPtr<IPC::Message::Sender> ipc_sender);
// Removes the listener for the given sub-event.
void RemoveEventListener(
@@ -186,6 +187,12 @@ class ExtensionWebRequestEventRouter {
const std::string& extension_id,
const std::string& sub_event_name);
+ // Called when an incognito profile is created or destroyed.
+ void OnOTRProfileCreated(ProfileId original_profile_id,
+ ProfileId otr_profile_id);
+ void OnOTRProfileDestroyed(ProfileId original_profile_id,
+ ProfileId otr_profile_id);
+
private:
friend struct DefaultSingletonTraits<ExtensionWebRequestEventRouter>;
struct EventListener;
@@ -196,13 +203,13 @@ class ExtensionWebRequestEventRouter {
typedef std::map<uint64, net::URLRequest*> HttpRequestMap;
// Map of request_id -> bit vector of EventTypes already signaled
typedef std::map<uint64, int> SignaledRequestMap;
+ typedef std::map<ProfileId, ProfileId> CrossProfileMap;
ExtensionWebRequestEventRouter();
~ExtensionWebRequestEventRouter();
bool DispatchEvent(
ProfileId profile_id,
- ExtensionEventRouterForwarder* event_router,
net::URLRequest* request,
const std::vector<const EventListener*>& listeners,
const ListValue& args);
@@ -212,6 +219,7 @@ class ExtensionWebRequestEventRouter {
// set of extra_info_spec flags that every matching listener asked for.
std::vector<const EventListener*> GetMatchingListeners(
ProfileId profile_id,
+ ExtensionInfoMap* extension_info_map,
const std::string& event_name,
const GURL& url,
int tab_id,
@@ -222,10 +230,27 @@ class ExtensionWebRequestEventRouter {
// Same as above, but retrieves the filter parameters from the request.
std::vector<const EventListener*> GetMatchingListeners(
ProfileId profile_id,
+ ExtensionInfoMap* extension_info_map,
const std::string& event_name,
net::URLRequest* request,
int* extra_info_spec);
+ // Helper for the above functions. This is called twice: once for the profile
+ // of the event, the next time for the "cross" profile (i.e. the incognito
+ // profile if the event is originally for the normal profile, or vice versa).
+ void GetMatchingListenersImpl(
+ ProfileId profile_id,
+ ExtensionInfoMap* extension_info_map,
+ bool crosses_incognito,
+ const std::string& event_name,
+ const GURL& url,
+ int tab_id,
+ int window_id,
+ ResourceType::Type resource_type,
+ int* extra_info_spec,
+ std::vector<const ExtensionWebRequestEventRouter::EventListener*>*
+ matching_listeners);
+
// Decrements the count of event handlers blocking the given request. When the
// count reaches 0, we stop blocking the request and proceed it using the
// method requested by the extension with the highest precedence. Precedence
@@ -233,8 +258,6 @@ class ExtensionWebRequestEventRouter {
// method assumes ownership.
void DecrementBlockCount(uint64 request_id, EventResponse* response);
- void OnRequestDeleted(net::URLRequest* request);
-
// Sets the flag that |event_type| has been signaled for |request_id|.
// Returns the value of the flag before setting it.
bool GetAndSetSignaled(uint64 request_id, EventTypes event_type);
@@ -258,16 +281,20 @@ class ExtensionWebRequestEventRouter {
// signaled and should not be sent again.
SignaledRequestMap signaled_requests_;
+ // A map of original profile -> corresponding incognito profile (and vice
+ // versa).
+ CrossProfileMap cross_profile_map_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter);
};
-class WebRequestAddEventListener : public SyncExtensionFunction {
+class WebRequestAddEventListener : public SyncIOThreadExtensionFunction {
public:
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME("experimental.webRequest.addEventListener");
};
-class WebRequestEventHandled : public SyncExtensionFunction {
+class WebRequestEventHandled : public SyncIOThreadExtensionFunction {
public:
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME("experimental.webRequest.eventHandled");
« no previous file with comments | « chrome/browser/extensions/extension_info_map_unittest.cc ('k') | chrome/browser/extensions/extension_webrequest_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698