Chromium Code Reviews| Index: net/url_request/sdch_dictionary_fetcher.cc |
| diff --git a/net/url_request/sdch_dictionary_fetcher.cc b/net/url_request/sdch_dictionary_fetcher.cc |
| index 1141aab8024485d62faa3d78da951e2d48f6206f..0fbae6f6b4a88b4aad35caaf9924a69a209e2c37 100644 |
| --- a/net/url_request/sdch_dictionary_fetcher.cc |
| +++ b/net/url_request/sdch_dictionary_fetcher.cc |
| @@ -18,6 +18,7 @@ |
| #include "net/base/sdch_net_log_params.h" |
| #include "net/http/http_response_headers.h" |
| #include "net/log/net_log.h" |
| +#include "net/url_request/redirect_info.h" |
| #include "net/url_request/url_request_context.h" |
| #include "net/url_request/url_request_status.h" |
| #include "net/url_request/url_request_throttler_manager.h" |
| @@ -143,10 +144,22 @@ void SdchDictionaryFetcher::Cancel() { |
| fetch_queue_->Clear(); |
| } |
| +void SdchDictionaryFetcher::OnReceivedRedirect( |
| + URLRequest* request, |
| + const RedirectInfo& redirect_info, |
| + bool* defer_redirect) { |
| + DCHECK_EQ(next_state_, STATE_SEND_REQUEST_PENDING); |
| + |
| + redirect_url_ = redirect_info.new_url; |
| + next_state_ = STATE_RECEIVED_REDIRECT; |
| + |
| + DoLoop(OK); |
| +} |
| + |
| void SdchDictionaryFetcher::OnResponseStarted(URLRequest* request) { |
| DCHECK(CalledOnValidThread()); |
| DCHECK_EQ(request, current_request_.get()); |
| - DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE); |
| + DCHECK_EQ(next_state_, STATE_SEND_REQUEST_PENDING); |
| DCHECK(!in_loop_); |
| // Confirm that the response isn't a stale read from the cache (as |
| @@ -228,8 +241,11 @@ int SdchDictionaryFetcher::DoLoop(int rv) { |
| case STATE_SEND_REQUEST: |
| rv = DoSendRequest(rv); |
| break; |
| - case STATE_SEND_REQUEST_COMPLETE: |
| - rv = DoSendRequestComplete(rv); |
| + case STATE_RECEIVED_REDIRECT: |
| + rv = DoReceivedRedirect(rv); |
| + break; |
| + case STATE_SEND_REQUEST_PENDING: |
| + rv = DoSendRequestPending(rv); |
| break; |
| case STATE_READ_BODY: |
| rv = DoReadBody(rv); |
| @@ -259,7 +275,7 @@ int SdchDictionaryFetcher::DoSendRequest(int rv) { |
| return OK; |
| } |
| - next_state_ = STATE_SEND_REQUEST_COMPLETE; |
| + next_state_ = STATE_SEND_REQUEST_PENDING; |
| FetchInfo info; |
| bool success = fetch_queue_->Pop(&info); |
| @@ -279,7 +295,20 @@ int SdchDictionaryFetcher::DoSendRequest(int rv) { |
| return ERR_IO_PENDING; |
| } |
| -int SdchDictionaryFetcher::DoSendRequestComplete(int rv) { |
| +int SdchDictionaryFetcher::DoReceivedRedirect(int rv) { |
| + // Don't allow redirect to go cross-origin or cross-port. This test also |
| + // forbids going cross-scheme, which is probably not necessary, but will |
| + // be necessary when/if SDCH is restricted to HTTPS. |
|
Ryan Sleevi
2016/04/13 00:30:44
The way this comment is worded, I think you're con
Mike West
2016/04/13 15:49:31
How are we not already restricting SDCH to HTTPS?
|
| + if (redirect_url_.GetOrigin() != current_request_->url().GetOrigin()) { |
|
eroman
2016/04/13 00:12:38
+rsleevi for security perspective, although mkwst
Ryan Sleevi
2016/04/13 00:30:44
Right, Mike is definitely the better reviewer here
Mike West
2016/04/13 10:54:07
1. I agree with Ryan that a spec which explained h
Mike West
2016/04/13 15:49:31
On the narrow question of this code: I'd suggest s
|
| + current_request_->Cancel(); |
|
eroman
2016/04/13 00:12:38
I think this is redundant -- calling ResetRequest(
Randy Smith (Not in Mondays)
2016/04/13 18:18:46
Yeah, I think you're right. Good point.
|
| + ResetRequest(); |
| + next_state_ = STATE_SEND_REQUEST; |
|
eroman
2016/04/13 00:12:38
Shouldn't there be a return statement here, and er
Randy Smith (Not in Mondays)
2016/04/13 18:18:46
Ooops. Yes, there should. That suggests my tests
|
| + } |
| + next_state_ = STATE_SEND_REQUEST_PENDING; |
| + return ERR_IO_PENDING; |
| +} |
| + |
| +int SdchDictionaryFetcher::DoSendRequestPending(int rv) { |
| DCHECK(CalledOnValidThread()); |
| // If there's been an error, abort the current request. |