OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 net::URLRequestJob class that simulates network errors (including https | 5 // A net::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 // contents and http-headers should be retrieved from. | 31 // contents and http-headers should be retrieved from. |
32 static void AddMockedURL(const GURL& url, | 32 static void AddMockedURL(const GURL& url, |
33 const std::wstring& base, | 33 const std::wstring& base, |
34 const std::vector<int>& errors, | 34 const std::vector<int>& errors, |
35 net::X509Certificate* ssl_cert); | 35 net::X509Certificate* ssl_cert); |
36 | 36 |
37 // Removes the specified |url| from the list of mocked urls. | 37 // Removes the specified |url| from the list of mocked urls. |
38 static void RemoveMockedURL(const GURL& url); | 38 static void RemoveMockedURL(const GURL& url); |
39 | 39 |
40 private: | 40 private: |
41 ~URLRequestMockNetErrorJob(); | 41 virtual ~URLRequestMockNetErrorJob(); |
42 | 42 |
43 static net::URLRequest::ProtocolFactory Factory; | 43 static net::URLRequest::ProtocolFactory Factory; |
44 | 44 |
45 void StartAsync(); | 45 void StartAsync(); |
46 | 46 |
47 // The errors to simulate. | 47 // The errors to simulate. |
48 std::vector<int> errors_; | 48 std::vector<int> errors_; |
49 | 49 |
50 // The certificate to use for SSL errors. | 50 // The certificate to use for SSL errors. |
51 scoped_refptr<net::X509Certificate> ssl_cert_; | 51 scoped_refptr<net::X509Certificate> ssl_cert_; |
52 | 52 |
53 struct MockInfo; | 53 struct MockInfo; |
54 typedef std::map<GURL, MockInfo> URLMockInfoMap; | 54 typedef std::map<GURL, MockInfo> URLMockInfoMap; |
55 static URLMockInfoMap url_mock_info_map_; | 55 static URLMockInfoMap url_mock_info_map_; |
56 | 56 |
57 ScopedRunnableMethodFactory<URLRequestMockNetErrorJob> method_factory_; | 57 ScopedRunnableMethodFactory<URLRequestMockNetErrorJob> method_factory_; |
58 | 58 |
59 DISALLOW_COPY_AND_ASSIGN(URLRequestMockNetErrorJob); | 59 DISALLOW_COPY_AND_ASSIGN(URLRequestMockNetErrorJob); |
60 }; | 60 }; |
61 | 61 |
62 #endif // CHROME_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ | 62 #endif // CHROME_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ |
OLD | NEW |