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

Unified Diff: chrome/browser/extensions/api/web_request/web_request_api.cc

Issue 10837164: WebRequest: Signal end of request if start signaled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WasSignaled is now a const method. Created 8 years, 4 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 | « chrome/browser/extensions/api/web_request/web_request_api.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/web_request/web_request_api.cc
diff --git a/chrome/browser/extensions/api/web_request/web_request_api.cc b/chrome/browser/extensions/api/web_request/web_request_api.cc
index e8b5d91f71175c1782cd43709a5b467dc9384fe5..add3163d50af425b05dd7f48563cfdf616a1888e 100644
--- a/chrome/browser/extensions/api/web_request/web_request_api.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_api.cc
@@ -812,7 +812,11 @@ void ExtensionWebRequestEventRouter::OnCompleted(
ExtensionInfoMap* extension_info_map,
net::URLRequest* request) {
// We hide events from the system context as well as sensitive requests.
- if (!profile || WebRequestPermissions::HideRequest(request))
+ // However, if the request first became sensitive after redirecting we have
+ // already signaled it and thus we have to signal the end of it. This is
+ // risk-free because the handler cannot modify the request now.
+ if (!profile ||
+ (WebRequestPermissions::HideRequest(request) && !WasSignaled(*request)))
return;
request_time_tracker_->LogRequestEndTime(request->identifier(),
@@ -861,7 +865,11 @@ void ExtensionWebRequestEventRouter::OnErrorOccurred(
net::URLRequest* request,
bool started) {
// We hide events from the system context as well as sensitive requests.
- if (!profile || WebRequestPermissions::HideRequest(request))
+ // However, if the request first became sensitive after redirecting we have
+ // already signaled it and thus we have to signal the end of it. This is
+ // risk-free because the handler cannot modify the request now.
+ if (!profile ||
+ (WebRequestPermissions::HideRequest(request) && !WasSignaled(*request)))
return;
request_time_tracker_->LogRequestEndTime(request->identifier(),
@@ -1096,6 +1104,13 @@ void* ExtensionWebRequestEventRouter::GetCrossProfile(void* profile) const {
return cross_profile->second;
}
+bool ExtensionWebRequestEventRouter::WasSignaled(
+ const net::URLRequest& request) const {
+ SignaledRequestMap::const_iterator flag =
+ signaled_requests_.find(request.identifier());
+ return (flag != signaled_requests_.end()) && (flag->second != 0);
+}
+
void ExtensionWebRequestEventRouter::GetMatchingListenersImpl(
void* profile,
ExtensionInfoMap* extension_info_map,
« no previous file with comments | « chrome/browser/extensions/api/web_request/web_request_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698