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

Issue 1416953007: Add a function to add extra headers from NavigationThrottle (Closed)

Created:
5 years, 1 month ago by clamy
Modified:
3 years, 9 months ago
Reviewers:
nasko, davidben
CC:
chromium-reviews, loading-reviews_chromium.org, darin-cc_chromium.org, nasko+codewatch_chromium.org, jam, creis+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@data-reduction-proxy-resource-throttle
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Add a function to add extra headers from NavigationThrottle This CL introduces a function that allows NavigationThrottles to add extra-headers to the navigation request during WillStartRequest and WillRedirectRequest. The added headers will overwrite any headers with the same name that already exists in the request. BUG=537634

Patch Set 1 #

Patch Set 2 : #

Total comments: 10

Patch Set 3 : Addressed Nasko's comments #

Patch Set 4 : Fixed compilation issue #

Total comments: 1

Patch Set 5 : Rebase #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+185 lines, -36 lines) Patch
M content/browser/frame_host/navigation_handle_impl.h View 1 2 3 4 2 chunks +12 lines, -2 lines 2 comments Download
M content/browser/frame_host/navigation_handle_impl.cc View 1 2 3 4 3 chunks +13 lines, -2 lines 1 comment Download
M content/browser/frame_host/navigation_handle_impl_unittest.cc View 1 2 3 4 5 chunks +81 lines, -1 line 2 comments Download
M content/browser/frame_host/navigation_request.h View 1 2 3 4 3 chunks +7 lines, -3 lines 0 comments Download
M content/browser/frame_host/navigation_request.cc View 1 2 3 4 5 chunks +13 lines, -4 lines 0 comments Download
M content/browser/frame_host/navigation_request_info.h View 1 2 1 chunk +4 lines, -1 line 0 comments Download
M content/browser/loader/navigation_resource_handler.h View 2 chunks +4 lines, -1 line 0 comments Download
M content/browser/loader/navigation_resource_handler.cc View 1 chunk +4 lines, -1 line 0 comments Download
M content/browser/loader/navigation_resource_throttle.h View 1 2 3 4 1 chunk +2 lines, -1 line 1 comment Download
M content/browser/loader/navigation_resource_throttle.cc View 1 2 3 4 4 chunks +22 lines, -9 lines 0 comments Download
M content/browser/loader/navigation_url_loader.h View 2 chunks +5 lines, -1 line 2 comments Download
M content/browser/loader/navigation_url_loader_impl.h View 1 chunk +2 lines, -1 line 0 comments Download
M content/browser/loader/navigation_url_loader_impl.cc View 1 chunk +3 lines, -2 lines 0 comments Download
M content/browser/loader/navigation_url_loader_impl_core.h View 1 chunk +2 lines, -1 line 0 comments Download
M content/browser/loader/navigation_url_loader_impl_core.cc View 1 chunk +3 lines, -2 lines 0 comments Download
M content/browser/loader/navigation_url_loader_unittest.cc View 3 chunks +4 lines, -2 lines 0 comments Download
M content/test/test_navigation_url_loader.h View 1 chunk +2 lines, -1 line 0 comments Download
M content/test/test_navigation_url_loader.cc View 1 chunk +2 lines, -1 line 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 9 (3 generated)
clamy
@nasko: PTAL. This is patch 2 in the serie of preparatory patches for the DataReductionProxyNavigationThrottle. ...
5 years, 1 month ago (2015-11-05 16:26:51 UTC) #3
nasko
I'll leave the loader/ review to davidben@, since I'd like him to take a poke ...
5 years, 1 month ago (2015-11-06 23:51:51 UTC) #4
clamy
@nasko: thanks! @davidben: PTAL https://codereview.chromium.org/1416953007/diff/20001/content/browser/frame_host/navigation_handle_impl.h File content/browser/frame_host/navigation_handle_impl.h (right): https://codereview.chromium.org/1416953007/diff/20001/content/browser/frame_host/navigation_handle_impl.h#newcode115 content/browser/frame_host/navigation_handle_impl.h:115: typedef std::vector<std::pair<std::string, std::string> > ExtraHeadersList; ...
5 years, 1 month ago (2015-11-09 15:47:09 UTC) #6
clamy
@davidben: friendly ping :).
5 years ago (2015-11-25 14:21:54 UTC) #7
nasko
Just a small nit I forgot to send on this one. https://codereview.chromium.org/1416953007/diff/60001/content/browser/frame_host/navigation_handle_impl.h File content/browser/frame_host/navigation_handle_impl.h (right): ...
5 years ago (2015-11-25 14:54:37 UTC) #8
davidben
5 years ago (2015-12-03 23:44:57 UTC) #9
Sorry, I'm really behind on large-ish reviews right now. I started looking
through this, but I wonder if this is quite what we want anyway. Is this only to
be used by the DRP code, or is there another consumer? That's some hack for
SafeBrowsing on Android, which might just be moot with crbug/474608.

And since it hooks in on subresources anyway, the WebContents callback might be
a better fit until we come up with a better story for that kind of check. (I
have some crazy "resumable error" idea.)

Also this API is inherently wonky because once you add a header, it applies to
all redirect legs. So you decide to add a header based on something you see at
a.com, but then a.com redirects to b.com and you keep the header. You wouldn't
have sent that header if, instead, you went to b.com straight.

(The ResourceThrottle one has the same problem. I kind of wish we could make it
so that ResourceThrottles can't set request headers...)

https://codereview.chromium.org/1416953007/diff/80001/content/browser/frame_h...
File content/browser/frame_host/navigation_handle_impl.cc (right):

https://codereview.chromium.org/1416953007/diff/80001/content/browser/frame_h...
content/browser/frame_host/navigation_handle_impl.cc:225:
DCHECK(!complete_callback_.is_null());
Perhaps also DCHECK on state_, in case you add a new throttle check later?

https://codereview.chromium.org/1416953007/diff/80001/content/browser/frame_h...
File content/browser/frame_host/navigation_handle_impl.h (right):

https://codereview.chromium.org/1416953007/diff/80001/content/browser/frame_h...
content/browser/frame_host/navigation_handle_impl.h:137: using ExtraHeadersList
= std::vector<std::pair<std::string, std::string> >;
"> >" can be >> now

https://codereview.chromium.org/1416953007/diff/80001/content/browser/frame_h...
content/browser/frame_host/navigation_handle_impl.h:144: void
AddExtraHeader(const std::string& name, const std::string& value);
This is only to be used by the DRP SafeBrowsing hack, right? Given
https://crbug.com/474608, it might be that that code is short-lived anyway.
Might be worth checking with the status of this and adding a TODO to remove this
API of their plan is to remove the DRP code altogether. ResourceThrottles
changing headers makes me nervous, though that ship seems to have already
sailed.

https://codereview.chromium.org/1416953007/diff/80001/content/browser/frame_h...
File content/browser/frame_host/navigation_handle_impl_unittest.cc (right):

https://codereview.chromium.org/1416953007/diff/80001/content/browser/frame_h...
content/browser/frame_host/navigation_handle_impl_unittest.cc:58:
NavigationThrottle::ThrottleCheckResult WillStartRequest() override {
You'll want to take the static_cast away when AddExtraHeader gets exposed.
(Looks like https://codereview.chromium.org/1424003006/ forgets.)

https://codereview.chromium.org/1416953007/diff/80001/content/browser/frame_h...
content/browser/frame_host/navigation_handle_impl_unittest.cc:66:
->AddExtraHeader(key_, value_);
Ditto.

https://codereview.chromium.org/1416953007/diff/80001/content/browser/loader/...
File content/browser/loader/navigation_resource_throttle.h (right):

https://codereview.chromium.org/1416953007/diff/80001/content/browser/loader/...
content/browser/loader/navigation_resource_throttle.h:36: const
std::vector<std::pair<std::string, std::string> >& extra_headers);
> > can be >> now

https://codereview.chromium.org/1416953007/diff/80001/content/browser/loader/...
File content/browser/loader/navigation_url_loader.h (right):

https://codereview.chromium.org/1416953007/diff/80001/content/browser/loader/...
content/browser/loader/navigation_url_loader.h:50: // request.
Document what extra_headers does.

NB: This API is kind of weird because the headers actually stick from one
redirect to the next.

https://codereview.chromium.org/1416953007/diff/80001/content/browser/loader/...
content/browser/loader/navigation_url_loader.h:52: const
std::vector<std::pair<std::string, std::string> >&
 > > can be >>

Powered by Google App Engine
This is Rietveld 408576698