| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ios/web/net/request_tracker_impl.h" | 5 #include "ios/web/net/request_tracker_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 16 #include "ios/web/public/cert_policy.h" | 17 #include "ios/web/public/cert_policy.h" |
| 17 #include "ios/web/public/certificate_policy_cache.h" | 18 #include "ios/web/public/certificate_policy_cache.h" |
| 18 #include "ios/web/public/ssl_status.h" | 19 #include "ios/web/public/ssl_status.h" |
| 19 #include "ios/web/public/test/test_browser_state.h" | 20 #include "ios/web/public/test/test_browser_state.h" |
| 20 #include "ios/web/public/test/test_web_thread.h" | 21 #include "ios/web/public/test/test_web_thread.h" |
| 21 #include "net/cert/x509_certificate.h" | 22 #include "net/cert/x509_certificate.h" |
| 22 #include "net/http/http_response_headers.h" | 23 #include "net/http/http_response_headers.h" |
| 23 #include "net/test/cert_test_util.h" | 24 #include "net/test/cert_test_util.h" |
| 24 #include "net/test/test_data_directory.h" | 25 #include "net/test/test_data_directory.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 199 } |
| 199 | 200 |
| 200 NSString* WaitUntilLoop(bool (^condition)(void)) { | 201 NSString* WaitUntilLoop(bool (^condition)(void)) { |
| 201 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 202 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 202 base::Time maxDate = base::Time::Now() + base::TimeDelta::FromSeconds(10); | 203 base::Time maxDate = base::Time::Now() + base::TimeDelta::FromSeconds(10); |
| 203 while (!condition()) { | 204 while (!condition()) { |
| 204 if ([receiver_ error]) | 205 if ([receiver_ error]) |
| 205 return [receiver_ error]; | 206 return [receiver_ error]; |
| 206 if (base::Time::Now() > maxDate) | 207 if (base::Time::Now() > maxDate) |
| 207 return @"Time is up, too slow to go"; | 208 return @"Time is up, too slow to go"; |
| 208 loop_.RunUntilIdle(); | 209 base::RunLoop().RunUntilIdle(); |
| 209 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); | 210 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); |
| 210 } | 211 } |
| 211 return nil; | 212 return nil; |
| 212 } | 213 } |
| 213 | 214 |
| 214 NSString* CheckActive() { | 215 NSString* CheckActive() { |
| 215 NSString* message = WaitUntilLoop(^{ | 216 NSString* message = WaitUntilLoop(^{ |
| 216 return (receiver_.get()->value_ > 0.0f); | 217 return (receiver_.get()->value_ > 0.0f); |
| 217 }); | 218 }); |
| 218 | 219 |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 base::Bind(&TwoStartsSSLCallback, | 504 base::Bind(&TwoStartsSSLCallback, |
| 504 &request_0_called)); | 505 &request_0_called)); |
| 505 tracker_->OnSSLCertificateError(GetSecureRequest(1), ssl_info, true, | 506 tracker_->OnSSLCertificateError(GetSecureRequest(1), ssl_info, true, |
| 506 base::Bind(&TwoStartsSSLCallback, | 507 base::Bind(&TwoStartsSSLCallback, |
| 507 &request_1_called)); | 508 &request_1_called)); |
| 508 EXPECT_TRUE(request_0_called); | 509 EXPECT_TRUE(request_0_called); |
| 509 EXPECT_TRUE(request_1_called); | 510 EXPECT_TRUE(request_1_called); |
| 510 } | 511 } |
| 511 | 512 |
| 512 } // namespace | 513 } // namespace |
| OLD | NEW |