| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #endif | 10 #endif |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 360 } |
| 361 | 361 |
| 362 private: | 362 private: |
| 363 void RunCallback(int response, const CompletionCallback& callback); | 363 void RunCallback(int response, const CompletionCallback& callback); |
| 364 void RunAuthCallback(AuthRequiredResponse response, | 364 void RunAuthCallback(AuthRequiredResponse response, |
| 365 const AuthCallback& callback); | 365 const AuthCallback& callback); |
| 366 | 366 |
| 367 // TestNetworkDelegate implementation. | 367 // TestNetworkDelegate implementation. |
| 368 virtual int OnBeforeURLRequest(URLRequest* request, | 368 virtual int OnBeforeURLRequest(URLRequest* request, |
| 369 const CompletionCallback& callback, | 369 const CompletionCallback& callback, |
| 370 GURL* new_url) OVERRIDE; | 370 GURL* new_url) override; |
| 371 | 371 |
| 372 virtual int OnBeforeSendHeaders(URLRequest* request, | 372 virtual int OnBeforeSendHeaders(URLRequest* request, |
| 373 const CompletionCallback& callback, | 373 const CompletionCallback& callback, |
| 374 HttpRequestHeaders* headers) OVERRIDE; | 374 HttpRequestHeaders* headers) override; |
| 375 | 375 |
| 376 virtual int OnHeadersReceived( | 376 virtual int OnHeadersReceived( |
| 377 URLRequest* request, | 377 URLRequest* request, |
| 378 const CompletionCallback& callback, | 378 const CompletionCallback& callback, |
| 379 const HttpResponseHeaders* original_response_headers, | 379 const HttpResponseHeaders* original_response_headers, |
| 380 scoped_refptr<HttpResponseHeaders>* override_response_headers, | 380 scoped_refptr<HttpResponseHeaders>* override_response_headers, |
| 381 GURL* allowed_unsafe_redirect_url) OVERRIDE; | 381 GURL* allowed_unsafe_redirect_url) override; |
| 382 | 382 |
| 383 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired( | 383 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired( |
| 384 URLRequest* request, | 384 URLRequest* request, |
| 385 const AuthChallengeInfo& auth_info, | 385 const AuthChallengeInfo& auth_info, |
| 386 const AuthCallback& callback, | 386 const AuthCallback& callback, |
| 387 AuthCredentials* credentials) OVERRIDE; | 387 AuthCredentials* credentials) override; |
| 388 | 388 |
| 389 // Resets the callbacks and |stage_blocked_for_callback_|. | 389 // Resets the callbacks and |stage_blocked_for_callback_|. |
| 390 void Reset(); | 390 void Reset(); |
| 391 | 391 |
| 392 // Checks whether we should block in |stage|. If yes, returns an error code | 392 // Checks whether we should block in |stage|. If yes, returns an error code |
| 393 // and optionally sets up callback based on |block_mode_|. If no, returns OK. | 393 // and optionally sets up callback based on |block_mode_|. If no, returns OK. |
| 394 int MaybeBlockStage(Stage stage, const CompletionCallback& callback); | 394 int MaybeBlockStage(Stage stage, const CompletionCallback& callback); |
| 395 | 395 |
| 396 // Configuration parameters, can be adjusted by public methods: | 396 // Configuration parameters, can be adjusted by public methods: |
| 397 const BlockMode block_mode_; | 397 const BlockMode block_mode_; |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 DeleteFile(lnk_path.c_str()); | 1096 DeleteFile(lnk_path.c_str()); |
| 1097 } | 1097 } |
| 1098 #endif // defined(OS_WIN) | 1098 #endif // defined(OS_WIN) |
| 1099 | 1099 |
| 1100 // Custom URLRequestJobs for use with interceptor tests | 1100 // Custom URLRequestJobs for use with interceptor tests |
| 1101 class RestartTestJob : public URLRequestTestJob { | 1101 class RestartTestJob : public URLRequestTestJob { |
| 1102 public: | 1102 public: |
| 1103 RestartTestJob(URLRequest* request, NetworkDelegate* network_delegate) | 1103 RestartTestJob(URLRequest* request, NetworkDelegate* network_delegate) |
| 1104 : URLRequestTestJob(request, network_delegate, true) {} | 1104 : URLRequestTestJob(request, network_delegate, true) {} |
| 1105 protected: | 1105 protected: |
| 1106 virtual void StartAsync() OVERRIDE { | 1106 virtual void StartAsync() override { |
| 1107 this->NotifyRestartRequired(); | 1107 this->NotifyRestartRequired(); |
| 1108 } | 1108 } |
| 1109 private: | 1109 private: |
| 1110 virtual ~RestartTestJob() {} | 1110 virtual ~RestartTestJob() {} |
| 1111 }; | 1111 }; |
| 1112 | 1112 |
| 1113 class CancelTestJob : public URLRequestTestJob { | 1113 class CancelTestJob : public URLRequestTestJob { |
| 1114 public: | 1114 public: |
| 1115 explicit CancelTestJob(URLRequest* request, NetworkDelegate* network_delegate) | 1115 explicit CancelTestJob(URLRequest* request, NetworkDelegate* network_delegate) |
| 1116 : URLRequestTestJob(request, network_delegate, true) {} | 1116 : URLRequestTestJob(request, network_delegate, true) {} |
| 1117 protected: | 1117 protected: |
| 1118 virtual void StartAsync() OVERRIDE { | 1118 virtual void StartAsync() override { |
| 1119 request_->Cancel(); | 1119 request_->Cancel(); |
| 1120 } | 1120 } |
| 1121 private: | 1121 private: |
| 1122 virtual ~CancelTestJob() {} | 1122 virtual ~CancelTestJob() {} |
| 1123 }; | 1123 }; |
| 1124 | 1124 |
| 1125 class CancelThenRestartTestJob : public URLRequestTestJob { | 1125 class CancelThenRestartTestJob : public URLRequestTestJob { |
| 1126 public: | 1126 public: |
| 1127 explicit CancelThenRestartTestJob(URLRequest* request, | 1127 explicit CancelThenRestartTestJob(URLRequest* request, |
| 1128 NetworkDelegate* network_delegate) | 1128 NetworkDelegate* network_delegate) |
| 1129 : URLRequestTestJob(request, network_delegate, true) { | 1129 : URLRequestTestJob(request, network_delegate, true) { |
| 1130 } | 1130 } |
| 1131 protected: | 1131 protected: |
| 1132 virtual void StartAsync() OVERRIDE { | 1132 virtual void StartAsync() override { |
| 1133 request_->Cancel(); | 1133 request_->Cancel(); |
| 1134 this->NotifyRestartRequired(); | 1134 this->NotifyRestartRequired(); |
| 1135 } | 1135 } |
| 1136 private: | 1136 private: |
| 1137 virtual ~CancelThenRestartTestJob() {} | 1137 virtual ~CancelThenRestartTestJob() {} |
| 1138 }; | 1138 }; |
| 1139 | 1139 |
| 1140 // An Interceptor for use with interceptor tests | 1140 // An Interceptor for use with interceptor tests |
| 1141 class TestInterceptor : URLRequest::Interceptor { | 1141 class TestInterceptor : URLRequest::Interceptor { |
| 1142 public: | 1142 public: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1153 did_intercept_final_(false), did_cancel_final_(false) { | 1153 did_intercept_final_(false), did_cancel_final_(false) { |
| 1154 URLRequest::Deprecated::RegisterRequestInterceptor(this); | 1154 URLRequest::Deprecated::RegisterRequestInterceptor(this); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 virtual ~TestInterceptor() { | 1157 virtual ~TestInterceptor() { |
| 1158 URLRequest::Deprecated::UnregisterRequestInterceptor(this); | 1158 URLRequest::Deprecated::UnregisterRequestInterceptor(this); |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 virtual URLRequestJob* MaybeIntercept( | 1161 virtual URLRequestJob* MaybeIntercept( |
| 1162 URLRequest* request, | 1162 URLRequest* request, |
| 1163 NetworkDelegate* network_delegate) OVERRIDE { | 1163 NetworkDelegate* network_delegate) override { |
| 1164 if (restart_main_request_) { | 1164 if (restart_main_request_) { |
| 1165 restart_main_request_ = false; | 1165 restart_main_request_ = false; |
| 1166 did_restart_main_ = true; | 1166 did_restart_main_ = true; |
| 1167 return new RestartTestJob(request, network_delegate); | 1167 return new RestartTestJob(request, network_delegate); |
| 1168 } | 1168 } |
| 1169 if (cancel_main_request_) { | 1169 if (cancel_main_request_) { |
| 1170 cancel_main_request_ = false; | 1170 cancel_main_request_ = false; |
| 1171 did_cancel_main_ = true; | 1171 did_cancel_main_ = true; |
| 1172 return new CancelTestJob(request, network_delegate); | 1172 return new CancelTestJob(request, network_delegate); |
| 1173 } | 1173 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1191 main_headers_, | 1191 main_headers_, |
| 1192 main_data_, | 1192 main_data_, |
| 1193 true); | 1193 true); |
| 1194 job->set_load_timing_info(main_request_load_timing_info_); | 1194 job->set_load_timing_info(main_request_load_timing_info_); |
| 1195 return job; | 1195 return job; |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 virtual URLRequestJob* MaybeInterceptRedirect( | 1198 virtual URLRequestJob* MaybeInterceptRedirect( |
| 1199 URLRequest* request, | 1199 URLRequest* request, |
| 1200 NetworkDelegate* network_delegate, | 1200 NetworkDelegate* network_delegate, |
| 1201 const GURL& location) OVERRIDE { | 1201 const GURL& location) override { |
| 1202 if (cancel_redirect_request_) { | 1202 if (cancel_redirect_request_) { |
| 1203 cancel_redirect_request_ = false; | 1203 cancel_redirect_request_ = false; |
| 1204 did_cancel_redirect_ = true; | 1204 did_cancel_redirect_ = true; |
| 1205 return new CancelTestJob(request, network_delegate); | 1205 return new CancelTestJob(request, network_delegate); |
| 1206 } | 1206 } |
| 1207 if (!intercept_redirect_) | 1207 if (!intercept_redirect_) |
| 1208 return NULL; | 1208 return NULL; |
| 1209 intercept_redirect_ = false; | 1209 intercept_redirect_ = false; |
| 1210 did_intercept_redirect_ = true; | 1210 did_intercept_redirect_ = true; |
| 1211 return new URLRequestTestJob(request, | 1211 return new URLRequestTestJob(request, |
| 1212 network_delegate, | 1212 network_delegate, |
| 1213 redirect_headers_, | 1213 redirect_headers_, |
| 1214 redirect_data_, | 1214 redirect_data_, |
| 1215 true); | 1215 true); |
| 1216 } | 1216 } |
| 1217 | 1217 |
| 1218 virtual URLRequestJob* MaybeInterceptResponse( | 1218 virtual URLRequestJob* MaybeInterceptResponse( |
| 1219 URLRequest* request, NetworkDelegate* network_delegate) OVERRIDE { | 1219 URLRequest* request, NetworkDelegate* network_delegate) override { |
| 1220 if (cancel_final_request_) { | 1220 if (cancel_final_request_) { |
| 1221 cancel_final_request_ = false; | 1221 cancel_final_request_ = false; |
| 1222 did_cancel_final_ = true; | 1222 did_cancel_final_ = true; |
| 1223 return new CancelTestJob(request, network_delegate); | 1223 return new CancelTestJob(request, network_delegate); |
| 1224 } | 1224 } |
| 1225 if (!intercept_final_response_) | 1225 if (!intercept_final_response_) |
| 1226 return NULL; | 1226 return NULL; |
| 1227 intercept_final_response_ = false; | 1227 intercept_final_response_ = false; |
| 1228 did_intercept_final_ = true; | 1228 did_intercept_final_ = true; |
| 1229 return new URLRequestTestJob(request, | 1229 return new URLRequestTestJob(request, |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2395 explicit FixedDateNetworkDelegate(const std::string& fixed_date) | 2395 explicit FixedDateNetworkDelegate(const std::string& fixed_date) |
| 2396 : fixed_date_(fixed_date) {} | 2396 : fixed_date_(fixed_date) {} |
| 2397 virtual ~FixedDateNetworkDelegate() {} | 2397 virtual ~FixedDateNetworkDelegate() {} |
| 2398 | 2398 |
| 2399 // NetworkDelegate implementation | 2399 // NetworkDelegate implementation |
| 2400 virtual int OnHeadersReceived( | 2400 virtual int OnHeadersReceived( |
| 2401 URLRequest* request, | 2401 URLRequest* request, |
| 2402 const CompletionCallback& callback, | 2402 const CompletionCallback& callback, |
| 2403 const HttpResponseHeaders* original_response_headers, | 2403 const HttpResponseHeaders* original_response_headers, |
| 2404 scoped_refptr<HttpResponseHeaders>* override_response_headers, | 2404 scoped_refptr<HttpResponseHeaders>* override_response_headers, |
| 2405 GURL* allowed_unsafe_redirect_url) OVERRIDE; | 2405 GURL* allowed_unsafe_redirect_url) override; |
| 2406 | 2406 |
| 2407 private: | 2407 private: |
| 2408 std::string fixed_date_; | 2408 std::string fixed_date_; |
| 2409 | 2409 |
| 2410 DISALLOW_COPY_AND_ASSIGN(FixedDateNetworkDelegate); | 2410 DISALLOW_COPY_AND_ASSIGN(FixedDateNetworkDelegate); |
| 2411 }; | 2411 }; |
| 2412 | 2412 |
| 2413 int FixedDateNetworkDelegate::OnHeadersReceived( | 2413 int FixedDateNetworkDelegate::OnHeadersReceived( |
| 2414 URLRequest* request, | 2414 URLRequest* request, |
| 2415 const CompletionCallback& callback, | 2415 const CompletionCallback& callback, |
| (...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3987 // before headers are sent, when headers are read, and when auth information | 3987 // before headers are sent, when headers are read, and when auth information |
| 3988 // is requested. Uses AsyncDelegateLogger. | 3988 // is requested. Uses AsyncDelegateLogger. |
| 3989 class AsyncLoggingNetworkDelegate : public TestNetworkDelegate { | 3989 class AsyncLoggingNetworkDelegate : public TestNetworkDelegate { |
| 3990 public: | 3990 public: |
| 3991 AsyncLoggingNetworkDelegate() {} | 3991 AsyncLoggingNetworkDelegate() {} |
| 3992 virtual ~AsyncLoggingNetworkDelegate() {} | 3992 virtual ~AsyncLoggingNetworkDelegate() {} |
| 3993 | 3993 |
| 3994 // NetworkDelegate implementation. | 3994 // NetworkDelegate implementation. |
| 3995 virtual int OnBeforeURLRequest(URLRequest* request, | 3995 virtual int OnBeforeURLRequest(URLRequest* request, |
| 3996 const CompletionCallback& callback, | 3996 const CompletionCallback& callback, |
| 3997 GURL* new_url) OVERRIDE { | 3997 GURL* new_url) override { |
| 3998 TestNetworkDelegate::OnBeforeURLRequest(request, callback, new_url); | 3998 TestNetworkDelegate::OnBeforeURLRequest(request, callback, new_url); |
| 3999 return RunCallbackAsynchronously(request, callback); | 3999 return RunCallbackAsynchronously(request, callback); |
| 4000 } | 4000 } |
| 4001 | 4001 |
| 4002 virtual int OnBeforeSendHeaders(URLRequest* request, | 4002 virtual int OnBeforeSendHeaders(URLRequest* request, |
| 4003 const CompletionCallback& callback, | 4003 const CompletionCallback& callback, |
| 4004 HttpRequestHeaders* headers) OVERRIDE { | 4004 HttpRequestHeaders* headers) override { |
| 4005 TestNetworkDelegate::OnBeforeSendHeaders(request, callback, headers); | 4005 TestNetworkDelegate::OnBeforeSendHeaders(request, callback, headers); |
| 4006 return RunCallbackAsynchronously(request, callback); | 4006 return RunCallbackAsynchronously(request, callback); |
| 4007 } | 4007 } |
| 4008 | 4008 |
| 4009 virtual int OnHeadersReceived( | 4009 virtual int OnHeadersReceived( |
| 4010 URLRequest* request, | 4010 URLRequest* request, |
| 4011 const CompletionCallback& callback, | 4011 const CompletionCallback& callback, |
| 4012 const HttpResponseHeaders* original_response_headers, | 4012 const HttpResponseHeaders* original_response_headers, |
| 4013 scoped_refptr<HttpResponseHeaders>* override_response_headers, | 4013 scoped_refptr<HttpResponseHeaders>* override_response_headers, |
| 4014 GURL* allowed_unsafe_redirect_url) OVERRIDE { | 4014 GURL* allowed_unsafe_redirect_url) override { |
| 4015 TestNetworkDelegate::OnHeadersReceived(request, | 4015 TestNetworkDelegate::OnHeadersReceived(request, |
| 4016 callback, | 4016 callback, |
| 4017 original_response_headers, | 4017 original_response_headers, |
| 4018 override_response_headers, | 4018 override_response_headers, |
| 4019 allowed_unsafe_redirect_url); | 4019 allowed_unsafe_redirect_url); |
| 4020 return RunCallbackAsynchronously(request, callback); | 4020 return RunCallbackAsynchronously(request, callback); |
| 4021 } | 4021 } |
| 4022 | 4022 |
| 4023 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired( | 4023 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired( |
| 4024 URLRequest* request, | 4024 URLRequest* request, |
| 4025 const AuthChallengeInfo& auth_info, | 4025 const AuthChallengeInfo& auth_info, |
| 4026 const AuthCallback& callback, | 4026 const AuthCallback& callback, |
| 4027 AuthCredentials* credentials) OVERRIDE { | 4027 AuthCredentials* credentials) override { |
| 4028 AsyncDelegateLogger::Run( | 4028 AsyncDelegateLogger::Run( |
| 4029 request, | 4029 request, |
| 4030 LOAD_STATE_WAITING_FOR_DELEGATE, | 4030 LOAD_STATE_WAITING_FOR_DELEGATE, |
| 4031 LOAD_STATE_WAITING_FOR_DELEGATE, | 4031 LOAD_STATE_WAITING_FOR_DELEGATE, |
| 4032 LOAD_STATE_WAITING_FOR_DELEGATE, | 4032 LOAD_STATE_WAITING_FOR_DELEGATE, |
| 4033 base::Bind(&AsyncLoggingNetworkDelegate::SetAuthAndResume, | 4033 base::Bind(&AsyncLoggingNetworkDelegate::SetAuthAndResume, |
| 4034 callback, credentials)); | 4034 callback, credentials)); |
| 4035 return AUTH_REQUIRED_RESPONSE_IO_PENDING; | 4035 return AUTH_REQUIRED_RESPONSE_IO_PENDING; |
| 4036 } | 4036 } |
| 4037 | 4037 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4079 else if (cancel_stage == CANCEL_ON_RESPONSE_STARTED) | 4079 else if (cancel_stage == CANCEL_ON_RESPONSE_STARTED) |
| 4080 set_cancel_in_response_started(true); | 4080 set_cancel_in_response_started(true); |
| 4081 else if (cancel_stage == CANCEL_ON_READ_COMPLETED) | 4081 else if (cancel_stage == CANCEL_ON_READ_COMPLETED) |
| 4082 set_cancel_in_received_data(true); | 4082 set_cancel_in_received_data(true); |
| 4083 } | 4083 } |
| 4084 virtual ~AsyncLoggingUrlRequestDelegate() {} | 4084 virtual ~AsyncLoggingUrlRequestDelegate() {} |
| 4085 | 4085 |
| 4086 // URLRequest::Delegate implementation: | 4086 // URLRequest::Delegate implementation: |
| 4087 void virtual OnReceivedRedirect(URLRequest* request, | 4087 void virtual OnReceivedRedirect(URLRequest* request, |
| 4088 const RedirectInfo& redirect_info, | 4088 const RedirectInfo& redirect_info, |
| 4089 bool* defer_redirect) OVERRIDE { | 4089 bool* defer_redirect) override { |
| 4090 *defer_redirect = true; | 4090 *defer_redirect = true; |
| 4091 AsyncDelegateLogger::Run( | 4091 AsyncDelegateLogger::Run( |
| 4092 request, | 4092 request, |
| 4093 LOAD_STATE_WAITING_FOR_DELEGATE, | 4093 LOAD_STATE_WAITING_FOR_DELEGATE, |
| 4094 LOAD_STATE_WAITING_FOR_DELEGATE, | 4094 LOAD_STATE_WAITING_FOR_DELEGATE, |
| 4095 LOAD_STATE_WAITING_FOR_DELEGATE, | 4095 LOAD_STATE_WAITING_FOR_DELEGATE, |
| 4096 base::Bind( | 4096 base::Bind( |
| 4097 &AsyncLoggingUrlRequestDelegate::OnReceivedRedirectLoggingComplete, | 4097 &AsyncLoggingUrlRequestDelegate::OnReceivedRedirectLoggingComplete, |
| 4098 base::Unretained(this), request, redirect_info)); | 4098 base::Unretained(this), request, redirect_info)); |
| 4099 } | 4099 } |
| 4100 | 4100 |
| 4101 virtual void OnResponseStarted(URLRequest* request) OVERRIDE { | 4101 virtual void OnResponseStarted(URLRequest* request) override { |
| 4102 AsyncDelegateLogger::Run( | 4102 AsyncDelegateLogger::Run( |
| 4103 request, | 4103 request, |
| 4104 LOAD_STATE_WAITING_FOR_DELEGATE, | 4104 LOAD_STATE_WAITING_FOR_DELEGATE, |
| 4105 LOAD_STATE_WAITING_FOR_DELEGATE, | 4105 LOAD_STATE_WAITING_FOR_DELEGATE, |
| 4106 LOAD_STATE_WAITING_FOR_DELEGATE, | 4106 LOAD_STATE_WAITING_FOR_DELEGATE, |
| 4107 base::Bind( | 4107 base::Bind( |
| 4108 &AsyncLoggingUrlRequestDelegate::OnResponseStartedLoggingComplete, | 4108 &AsyncLoggingUrlRequestDelegate::OnResponseStartedLoggingComplete, |
| 4109 base::Unretained(this), request)); | 4109 base::Unretained(this), request)); |
| 4110 } | 4110 } |
| 4111 | 4111 |
| 4112 virtual void OnReadCompleted(URLRequest* request, | 4112 virtual void OnReadCompleted(URLRequest* request, |
| 4113 int bytes_read) OVERRIDE { | 4113 int bytes_read) override { |
| 4114 AsyncDelegateLogger::Run( | 4114 AsyncDelegateLogger::Run( |
| 4115 request, | 4115 request, |
| 4116 LOAD_STATE_IDLE, | 4116 LOAD_STATE_IDLE, |
| 4117 LOAD_STATE_IDLE, | 4117 LOAD_STATE_IDLE, |
| 4118 LOAD_STATE_IDLE, | 4118 LOAD_STATE_IDLE, |
| 4119 base::Bind( | 4119 base::Bind( |
| 4120 &AsyncLoggingUrlRequestDelegate::AfterReadCompletedLoggingComplete, | 4120 &AsyncLoggingUrlRequestDelegate::AfterReadCompletedLoggingComplete, |
| 4121 base::Unretained(this), request, bytes_read)); | 4121 base::Unretained(this), request, bytes_read)); |
| 4122 } | 4122 } |
| 4123 | 4123 |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4571 } | 4571 } |
| 4572 | 4572 |
| 4573 namespace { | 4573 namespace { |
| 4574 | 4574 |
| 4575 const char kExtraHeader[] = "Allow-Snafu"; | 4575 const char kExtraHeader[] = "Allow-Snafu"; |
| 4576 const char kExtraValue[] = "fubar"; | 4576 const char kExtraValue[] = "fubar"; |
| 4577 | 4577 |
| 4578 class RedirectWithAdditionalHeadersDelegate : public TestDelegate { | 4578 class RedirectWithAdditionalHeadersDelegate : public TestDelegate { |
| 4579 virtual void OnReceivedRedirect(URLRequest* request, | 4579 virtual void OnReceivedRedirect(URLRequest* request, |
| 4580 const RedirectInfo& redirect_info, | 4580 const RedirectInfo& redirect_info, |
| 4581 bool* defer_redirect) OVERRIDE { | 4581 bool* defer_redirect) override { |
| 4582 TestDelegate::OnReceivedRedirect(request, redirect_info, defer_redirect); | 4582 TestDelegate::OnReceivedRedirect(request, redirect_info, defer_redirect); |
| 4583 request->SetExtraRequestHeaderByName(kExtraHeader, kExtraValue, false); | 4583 request->SetExtraRequestHeaderByName(kExtraHeader, kExtraValue, false); |
| 4584 } | 4584 } |
| 4585 }; | 4585 }; |
| 4586 | 4586 |
| 4587 } // namespace | 4587 } // namespace |
| 4588 | 4588 |
| 4589 TEST_F(URLRequestTestHTTP, RedirectWithAdditionalHeadersTest) { | 4589 TEST_F(URLRequestTestHTTP, RedirectWithAdditionalHeadersTest) { |
| 4590 ASSERT_TRUE(test_server_.Start()); | 4590 ASSERT_TRUE(test_server_.Start()); |
| 4591 | 4591 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4608 EXPECT_EQ(kExtraValue, d.data_received()); | 4608 EXPECT_EQ(kExtraValue, d.data_received()); |
| 4609 } | 4609 } |
| 4610 | 4610 |
| 4611 namespace { | 4611 namespace { |
| 4612 | 4612 |
| 4613 const char kExtraHeaderToRemove[] = "To-Be-Removed"; | 4613 const char kExtraHeaderToRemove[] = "To-Be-Removed"; |
| 4614 | 4614 |
| 4615 class RedirectWithHeaderRemovalDelegate : public TestDelegate { | 4615 class RedirectWithHeaderRemovalDelegate : public TestDelegate { |
| 4616 virtual void OnReceivedRedirect(URLRequest* request, | 4616 virtual void OnReceivedRedirect(URLRequest* request, |
| 4617 const RedirectInfo& redirect_info, | 4617 const RedirectInfo& redirect_info, |
| 4618 bool* defer_redirect) OVERRIDE { | 4618 bool* defer_redirect) override { |
| 4619 TestDelegate::OnReceivedRedirect(request, redirect_info, defer_redirect); | 4619 TestDelegate::OnReceivedRedirect(request, redirect_info, defer_redirect); |
| 4620 request->RemoveRequestHeaderByName(kExtraHeaderToRemove); | 4620 request->RemoveRequestHeaderByName(kExtraHeaderToRemove); |
| 4621 } | 4621 } |
| 4622 }; | 4622 }; |
| 4623 | 4623 |
| 4624 } // namespace | 4624 } // namespace |
| 4625 | 4625 |
| 4626 TEST_F(URLRequestTestHTTP, RedirectWithHeaderRemovalTest) { | 4626 TEST_F(URLRequestTestHTTP, RedirectWithHeaderRemovalTest) { |
| 4627 ASSERT_TRUE(test_server_.Start()); | 4627 ASSERT_TRUE(test_server_.Start()); |
| 4628 | 4628 |
| (...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6804 } | 6804 } |
| 6805 | 6805 |
| 6806 namespace { | 6806 namespace { |
| 6807 | 6807 |
| 6808 class SSLClientAuthTestDelegate : public TestDelegate { | 6808 class SSLClientAuthTestDelegate : public TestDelegate { |
| 6809 public: | 6809 public: |
| 6810 SSLClientAuthTestDelegate() : on_certificate_requested_count_(0) { | 6810 SSLClientAuthTestDelegate() : on_certificate_requested_count_(0) { |
| 6811 } | 6811 } |
| 6812 virtual void OnCertificateRequested( | 6812 virtual void OnCertificateRequested( |
| 6813 URLRequest* request, | 6813 URLRequest* request, |
| 6814 SSLCertRequestInfo* cert_request_info) OVERRIDE { | 6814 SSLCertRequestInfo* cert_request_info) override { |
| 6815 on_certificate_requested_count_++; | 6815 on_certificate_requested_count_++; |
| 6816 base::MessageLoop::current()->Quit(); | 6816 base::MessageLoop::current()->Quit(); |
| 6817 } | 6817 } |
| 6818 int on_certificate_requested_count() { | 6818 int on_certificate_requested_count() { |
| 6819 return on_certificate_requested_count_; | 6819 return on_certificate_requested_count_; |
| 6820 } | 6820 } |
| 6821 private: | 6821 private: |
| 6822 int on_certificate_requested_count_; | 6822 int on_certificate_requested_count_; |
| 6823 }; | 6823 }; |
| 6824 | 6824 |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7324 public: | 7324 public: |
| 7325 TestSSLConfigService(bool ev_enabled, | 7325 TestSSLConfigService(bool ev_enabled, |
| 7326 bool online_rev_checking, | 7326 bool online_rev_checking, |
| 7327 bool rev_checking_required_local_anchors) | 7327 bool rev_checking_required_local_anchors) |
| 7328 : ev_enabled_(ev_enabled), | 7328 : ev_enabled_(ev_enabled), |
| 7329 online_rev_checking_(online_rev_checking), | 7329 online_rev_checking_(online_rev_checking), |
| 7330 rev_checking_required_local_anchors_( | 7330 rev_checking_required_local_anchors_( |
| 7331 rev_checking_required_local_anchors) {} | 7331 rev_checking_required_local_anchors) {} |
| 7332 | 7332 |
| 7333 // SSLConfigService: | 7333 // SSLConfigService: |
| 7334 virtual void GetSSLConfig(SSLConfig* config) OVERRIDE { | 7334 virtual void GetSSLConfig(SSLConfig* config) override { |
| 7335 *config = SSLConfig(); | 7335 *config = SSLConfig(); |
| 7336 config->rev_checking_enabled = online_rev_checking_; | 7336 config->rev_checking_enabled = online_rev_checking_; |
| 7337 config->verify_ev_cert = ev_enabled_; | 7337 config->verify_ev_cert = ev_enabled_; |
| 7338 config->rev_checking_required_local_anchors = | 7338 config->rev_checking_required_local_anchors = |
| 7339 rev_checking_required_local_anchors_; | 7339 rev_checking_required_local_anchors_; |
| 7340 } | 7340 } |
| 7341 | 7341 |
| 7342 protected: | 7342 protected: |
| 7343 virtual ~TestSSLConfigService() {} | 7343 virtual ~TestSSLConfigService() {} |
| 7344 | 7344 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 7370 class HTTPSOCSPTest : public HTTPSRequestTest { | 7370 class HTTPSOCSPTest : public HTTPSRequestTest { |
| 7371 public: | 7371 public: |
| 7372 HTTPSOCSPTest() | 7372 HTTPSOCSPTest() |
| 7373 : context_(true), | 7373 : context_(true), |
| 7374 ev_test_policy_( | 7374 ev_test_policy_( |
| 7375 new ScopedTestEVPolicy(EVRootCAMetadata::GetInstance(), | 7375 new ScopedTestEVPolicy(EVRootCAMetadata::GetInstance(), |
| 7376 kOCSPTestCertFingerprint, | 7376 kOCSPTestCertFingerprint, |
| 7377 kOCSPTestCertPolicy)) { | 7377 kOCSPTestCertPolicy)) { |
| 7378 } | 7378 } |
| 7379 | 7379 |
| 7380 virtual void SetUp() OVERRIDE { | 7380 virtual void SetUp() override { |
| 7381 SetupContext(&context_); | 7381 SetupContext(&context_); |
| 7382 context_.Init(); | 7382 context_.Init(); |
| 7383 | 7383 |
| 7384 scoped_refptr<X509Certificate> root_cert = | 7384 scoped_refptr<X509Certificate> root_cert = |
| 7385 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); | 7385 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); |
| 7386 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get()); | 7386 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get()); |
| 7387 test_root_.reset(new ScopedTestRoot(root_cert.get())); | 7387 test_root_.reset(new ScopedTestRoot(root_cert.get())); |
| 7388 | 7388 |
| 7389 #if defined(USE_NSS) || defined(OS_IOS) | 7389 #if defined(USE_NSS) || defined(OS_IOS) |
| 7390 SetURLRequestContextForNSSHttpIO(&context_); | 7390 SetURLRequestContextForNSSHttpIO(&context_); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7551 EXPECT_EQ(ExpectedCertStatusForFailedOnlineRevocationCheck(), | 7551 EXPECT_EQ(ExpectedCertStatusForFailedOnlineRevocationCheck(), |
| 7552 cert_status & CERT_STATUS_ALL_ERRORS); | 7552 cert_status & CERT_STATUS_ALL_ERRORS); |
| 7553 | 7553 |
| 7554 // Without a positive OCSP response, we shouldn't show the EV status. | 7554 // Without a positive OCSP response, we shouldn't show the EV status. |
| 7555 EXPECT_FALSE(cert_status & CERT_STATUS_IS_EV); | 7555 EXPECT_FALSE(cert_status & CERT_STATUS_IS_EV); |
| 7556 EXPECT_TRUE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); | 7556 EXPECT_TRUE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); |
| 7557 } | 7557 } |
| 7558 | 7558 |
| 7559 class HTTPSHardFailTest : public HTTPSOCSPTest { | 7559 class HTTPSHardFailTest : public HTTPSOCSPTest { |
| 7560 protected: | 7560 protected: |
| 7561 virtual void SetupContext(URLRequestContext* context) OVERRIDE { | 7561 virtual void SetupContext(URLRequestContext* context) override { |
| 7562 context->set_ssl_config_service( | 7562 context->set_ssl_config_service( |
| 7563 new TestSSLConfigService(false /* check for EV */, | 7563 new TestSSLConfigService(false /* check for EV */, |
| 7564 false /* online revocation checking */, | 7564 false /* online revocation checking */, |
| 7565 true /* require rev. checking for local | 7565 true /* require rev. checking for local |
| 7566 anchors */)); | 7566 anchors */)); |
| 7567 } | 7567 } |
| 7568 }; | 7568 }; |
| 7569 | 7569 |
| 7570 | 7570 |
| 7571 TEST_F(HTTPSHardFailTest, FailsOnOCSPInvalid) { | 7571 TEST_F(HTTPSHardFailTest, FailsOnOCSPInvalid) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 7589 | 7589 |
| 7590 EXPECT_EQ(CERT_STATUS_REVOKED, | 7590 EXPECT_EQ(CERT_STATUS_REVOKED, |
| 7591 cert_status & CERT_STATUS_REVOKED); | 7591 cert_status & CERT_STATUS_REVOKED); |
| 7592 | 7592 |
| 7593 // Without a positive OCSP response, we shouldn't show the EV status. | 7593 // Without a positive OCSP response, we shouldn't show the EV status. |
| 7594 EXPECT_TRUE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); | 7594 EXPECT_TRUE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); |
| 7595 } | 7595 } |
| 7596 | 7596 |
| 7597 class HTTPSEVCRLSetTest : public HTTPSOCSPTest { | 7597 class HTTPSEVCRLSetTest : public HTTPSOCSPTest { |
| 7598 protected: | 7598 protected: |
| 7599 virtual void SetupContext(URLRequestContext* context) OVERRIDE { | 7599 virtual void SetupContext(URLRequestContext* context) override { |
| 7600 context->set_ssl_config_service( | 7600 context->set_ssl_config_service( |
| 7601 new TestSSLConfigService(true /* check for EV */, | 7601 new TestSSLConfigService(true /* check for EV */, |
| 7602 false /* online revocation checking */, | 7602 false /* online revocation checking */, |
| 7603 false /* require rev. checking for local | 7603 false /* require rev. checking for local |
| 7604 anchors */)); | 7604 anchors */)); |
| 7605 } | 7605 } |
| 7606 }; | 7606 }; |
| 7607 | 7607 |
| 7608 TEST_F(HTTPSEVCRLSetTest, MissingCRLSetAndInvalidOCSP) { | 7608 TEST_F(HTTPSEVCRLSetTest, MissingCRLSetAndInvalidOCSP) { |
| 7609 if (!SystemSupportsOCSP()) { | 7609 if (!SystemSupportsOCSP()) { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7774 DoConnection(ssl_options, &cert_status); | 7774 DoConnection(ssl_options, &cert_status); |
| 7775 | 7775 |
| 7776 EXPECT_EQ(0u, cert_status & CERT_STATUS_ALL_ERRORS); | 7776 EXPECT_EQ(0u, cert_status & CERT_STATUS_ALL_ERRORS); |
| 7777 | 7777 |
| 7778 EXPECT_FALSE(cert_status & CERT_STATUS_IS_EV); | 7778 EXPECT_FALSE(cert_status & CERT_STATUS_IS_EV); |
| 7779 EXPECT_FALSE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); | 7779 EXPECT_FALSE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); |
| 7780 } | 7780 } |
| 7781 | 7781 |
| 7782 class HTTPSCRLSetTest : public HTTPSOCSPTest { | 7782 class HTTPSCRLSetTest : public HTTPSOCSPTest { |
| 7783 protected: | 7783 protected: |
| 7784 virtual void SetupContext(URLRequestContext* context) OVERRIDE { | 7784 virtual void SetupContext(URLRequestContext* context) override { |
| 7785 context->set_ssl_config_service( | 7785 context->set_ssl_config_service( |
| 7786 new TestSSLConfigService(false /* check for EV */, | 7786 new TestSSLConfigService(false /* check for EV */, |
| 7787 false /* online revocation checking */, | 7787 false /* online revocation checking */, |
| 7788 false /* require rev. checking for local | 7788 false /* require rev. checking for local |
| 7789 anchors */)); | 7789 anchors */)); |
| 7790 } | 7790 } |
| 7791 }; | 7791 }; |
| 7792 | 7792 |
| 7793 TEST_F(HTTPSCRLSetTest, ExpiredCRLSet) { | 7793 TEST_F(HTTPSCRLSetTest, ExpiredCRLSet) { |
| 7794 SpawnedTestServer::SSLOptions ssl_options( | 7794 SpawnedTestServer::SSLOptions ssl_options( |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8177 | 8177 |
| 8178 EXPECT_FALSE(r->is_pending()); | 8178 EXPECT_FALSE(r->is_pending()); |
| 8179 EXPECT_EQ(1, d->response_started_count()); | 8179 EXPECT_EQ(1, d->response_started_count()); |
| 8180 EXPECT_FALSE(d->received_data_before_response()); | 8180 EXPECT_FALSE(d->received_data_before_response()); |
| 8181 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 8181 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 8182 } | 8182 } |
| 8183 } | 8183 } |
| 8184 #endif // !defined(DISABLE_FTP_SUPPORT) | 8184 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 8185 | 8185 |
| 8186 } // namespace net | 8186 } // namespace net |
| OLD | NEW |