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

Unified Diff: content/browser/loader/navigation_resource_throttle.cc

Issue 1416953007: Add a function to add extra headers from NavigationThrottle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data-reduction-proxy-resource-throttle
Patch Set: Rebase Created 5 years 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: content/browser/loader/navigation_resource_throttle.cc
diff --git a/content/browser/loader/navigation_resource_throttle.cc b/content/browser/loader/navigation_resource_throttle.cc
index 44fd0c131ff413fd0d90d0d4c07adae7dedc338b..c00d397faa242edece1dd9bcaee9d085531b57a9 100644
--- a/content/browser/loader/navigation_resource_throttle.cc
+++ b/content/browser/loader/navigation_resource_throttle.cc
@@ -20,15 +20,19 @@
namespace content {
namespace {
-typedef base::Callback<void(NavigationThrottle::ThrottleCheckResult)>
+typedef base::Callback<void(
+ NavigationThrottle::ThrottleCheckResult,
+ const std::vector<std::pair<std::string, std::string>>&)>
UIChecksPerformedCallback;
-void SendCheckResultToIOThread(UIChecksPerformedCallback callback,
- NavigationThrottle::ThrottleCheckResult result) {
+void SendCheckResultToIOThread(
+ UIChecksPerformedCallback callback,
+ NavigationThrottle::ThrottleCheckResult result,
+ const NavigationHandleImpl::ExtraHeadersList& extra_headers) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
CHECK(result != NavigationThrottle::DEFER);
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- base::Bind(callback, result));
+ base::Bind(callback, result, extra_headers));
}
void CheckWillStartRequestOnUIThread(UIChecksPerformedCallback callback,
@@ -43,14 +47,16 @@ void CheckWillStartRequestOnUIThread(UIChecksPerformedCallback callback,
RenderFrameHostImpl* render_frame_host =
RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id);
if (!render_frame_host) {
- SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
+ SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED,
+ NavigationHandleImpl::ExtraHeadersList());
return;
}
NavigationHandleImpl* navigation_handle =
render_frame_host->navigation_handle();
if (!navigation_handle) {
- SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
+ SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED,
+ NavigationHandleImpl::ExtraHeadersList());
return;
}
@@ -72,14 +78,16 @@ void CheckWillRedirectRequestOnUIThread(
RenderFrameHostImpl* render_frame_host =
RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id);
if (!render_frame_host) {
- SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
+ SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED,
+ NavigationHandleImpl::ExtraHeadersList());
return;
}
NavigationHandleImpl* navigation_handle =
render_frame_host->navigation_handle();
if (!navigation_handle) {
- SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
+ SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED,
+ NavigationHandleImpl::ExtraHeadersList());
return;
}
@@ -215,13 +223,18 @@ const char* NavigationResourceThrottle::GetNameForLogging() const {
}
void NavigationResourceThrottle::OnUIChecksPerformed(
- NavigationThrottle::ThrottleCheckResult result) {
+ NavigationThrottle::ThrottleCheckResult result,
+ const std::vector<std::pair<std::string, std::string>>& extra_headers) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (result == NavigationThrottle::CANCEL_AND_IGNORE) {
controller()->CancelAndIgnore();
} else if (result == NavigationThrottle::CANCEL) {
controller()->Cancel();
} else {
+ DCHECK(result == NavigationThrottle::PROCEED);
+ for (auto header : extra_headers) {
+ request_->SetExtraRequestHeaderByName(header.first, header.second, true);
+ }
controller()->Resume();
}
}

Powered by Google App Engine
This is Rietveld 408576698