| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // A URLRequestJob class that simulates network errors (including https | 5 // A URLRequestJob class that simulates network errors (including https |
| 6 // related). | 6 // related). |
| 7 // It is based on URLRequestMockHttpJob. | 7 // It is based on URLRequestMockHttpJob. |
| 8 | 8 |
| 9 #ifndef CHROME_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ | 9 #ifndef CHROME_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ |
| 10 #define CHROME_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ | 10 #define CHROME_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 static void AddMockedURL(const GURL& url, | 31 static void AddMockedURL(const GURL& url, |
| 32 const std::wstring& base, | 32 const std::wstring& base, |
| 33 const std::vector<int>& errors, | 33 const std::vector<int>& errors, |
| 34 net::X509Certificate* ssl_cert); | 34 net::X509Certificate* ssl_cert); |
| 35 | 35 |
| 36 // Removes the specified |url| from the list of mocked urls. | 36 // Removes the specified |url| from the list of mocked urls. |
| 37 static void RemoveMockedURL(const GURL& url); | 37 static void RemoveMockedURL(const GURL& url); |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 ~URLRequestMockNetErrorJob(); | 40 ~URLRequestMockNetErrorJob(); |
| 41 struct MockInfo { | |
| 42 MockInfo() : ssl_cert(NULL) { } | |
| 43 MockInfo(std::wstring base, | |
| 44 std::vector<int> errors, | |
| 45 net::X509Certificate* ssl_cert) | |
| 46 : base(base), | |
| 47 errors(errors), | |
| 48 ssl_cert(ssl_cert) { } | |
| 49 | |
| 50 std::wstring base; | |
| 51 std::vector<int> errors; | |
| 52 scoped_refptr<net::X509Certificate> ssl_cert; | |
| 53 }; | |
| 54 | 41 |
| 55 static URLRequest::ProtocolFactory Factory; | 42 static URLRequest::ProtocolFactory Factory; |
| 56 | 43 |
| 57 void StartAsync(); | 44 void StartAsync(); |
| 58 | 45 |
| 59 // The errors to simulate. | 46 // The errors to simulate. |
| 60 std::vector<int> errors_; | 47 std::vector<int> errors_; |
| 61 | 48 |
| 62 // The certificate to use for SSL errors. | 49 // The certificate to use for SSL errors. |
| 63 scoped_refptr<net::X509Certificate> ssl_cert_; | 50 scoped_refptr<net::X509Certificate> ssl_cert_; |
| 64 | 51 |
| 52 struct MockInfo; |
| 65 typedef std::map<GURL, MockInfo> URLMockInfoMap; | 53 typedef std::map<GURL, MockInfo> URLMockInfoMap; |
| 66 static URLMockInfoMap url_mock_info_map_; | 54 static URLMockInfoMap url_mock_info_map_; |
| 67 | 55 |
| 68 DISALLOW_COPY_AND_ASSIGN(URLRequestMockNetErrorJob); | 56 DISALLOW_COPY_AND_ASSIGN(URLRequestMockNetErrorJob); |
| 69 }; | 57 }; |
| 70 | 58 |
| 71 #endif // CHROME_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ | 59 #endif // CHROME_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ |
| OLD | NEW |