| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/url_request/sdch_dictionary_fetcher.h" | 5 #include "net/url_request/sdch_dictionary_fetcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 lifecycle_callback_(lifecycle_callback) { | 161 lifecycle_callback_(lifecycle_callback) { |
| 162 DCHECK(!lifecycle_callback_.is_null()); | 162 DCHECK(!lifecycle_callback_.is_null()); |
| 163 } | 163 } |
| 164 ~SDCHTestRequestInterceptor() override {} | 164 ~SDCHTestRequestInterceptor() override {} |
| 165 | 165 |
| 166 URLRequestJob* MaybeInterceptRequest( | 166 URLRequestJob* MaybeInterceptRequest( |
| 167 URLRequest* request, | 167 URLRequest* request, |
| 168 NetworkDelegate* network_delegate) const override { | 168 NetworkDelegate* network_delegate) const override { |
| 169 lifecycle_callback_.Run(1, 0); | 169 lifecycle_callback_.Run(1, 0); |
| 170 | 170 |
| 171 std::string path = request->url().path(); | 171 base::StringPiece path = request->url().path(); |
| 172 if (base::StartsWith(path, kRedirectPath, base::CompareCase::SENSITIVE)) { | 172 if (base::StartsWith(path, kRedirectPath, base::CompareCase::SENSITIVE)) { |
| 173 return new TestURLRequestRedirectJob( | 173 return new TestURLRequestRedirectJob( |
| 174 request, network_delegate, GURL(path.substr(strlen(kRedirectPath))), | 174 request, network_delegate, |
| 175 GURL(path.substr(strlen(kRedirectPath)).as_string()), |
| 175 URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT, "testing", | 176 URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT, "testing", |
| 176 base::Bind(lifecycle_callback_, -1, 0)); | 177 base::Bind(lifecycle_callback_, -1, 0)); |
| 177 } | 178 } |
| 178 | 179 |
| 179 std::unique_ptr<URLRequestSpecifiedResponseJob> job( | 180 std::unique_ptr<URLRequestSpecifiedResponseJob> job( |
| 180 new URLRequestSpecifiedResponseJob( | 181 new URLRequestSpecifiedResponseJob( |
| 181 request, network_delegate, *http_response_info_, | 182 request, network_delegate, *http_response_info_, |
| 182 base::Bind(lifecycle_callback_, -1))); | 183 base::Bind(lifecycle_callback_, -1))); |
| 183 if (base::StartsWith(path, kBodyErrorPath, base::CompareCase::SENSITIVE)) | 184 if (base::StartsWith(path, kBodyErrorPath, base::CompareCase::SENSITIVE)) |
| 184 job->set_final_read_result(net::ERR_FAILED); | 185 job->set_final_read_result(net::ERR_FAILED); |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 // Should only have a dictionary for the successful request. | 571 // Should only have a dictionary for the successful request. |
| 571 ASSERT_EQ(1u, additions.size()); | 572 ASSERT_EQ(1u, additions.size()); |
| 572 EXPECT_EQ( | 573 EXPECT_EQ( |
| 573 URLRequestSpecifiedResponseJob::ExpectedResponseForURL(dictionary_url), | 574 URLRequestSpecifiedResponseJob::ExpectedResponseForURL(dictionary_url), |
| 574 additions[0].dictionary_text); | 575 additions[0].dictionary_text); |
| 575 } | 576 } |
| 576 | 577 |
| 577 } // namespace | 578 } // namespace |
| 578 | 579 |
| 579 } // namespace net | 580 } // namespace net |
| OLD | NEW |