Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: chrome/browser/net/url_request_mock_net_error_job.h

Issue 5384002: net: Remove typedef net::URLRequest URLRequest; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_
11 #pragma once 11 #pragma once
12 12
13 #include "chrome/browser/net/url_request_mock_http_job.h" 13 #include "chrome/browser/net/url_request_mock_http_job.h"
14 14
15 class URLRequestMockNetErrorJob : public URLRequestMockHTTPJob { 15 class URLRequestMockNetErrorJob : public URLRequestMockHTTPJob {
16 public: 16 public:
17 URLRequestMockNetErrorJob(URLRequest* request, 17 URLRequestMockNetErrorJob(net::URLRequest* request,
18 const std::vector<int>& errors, 18 const std::vector<int>& errors,
19 net::X509Certificate* ssl_cert, 19 net::X509Certificate* ssl_cert,
20 const FilePath& file_path); 20 const FilePath& file_path);
21 21
22 virtual void Start(); 22 virtual void Start();
23 virtual void ContinueDespiteLastError(); 23 virtual void ContinueDespiteLastError();
24 24
25 // Add the specified URL to the list of URLs that should be mocked. When this 25 // Add the specified URL to the list of URLs that should be mocked. When this
26 // URL is hit, the specified |errors| will be played. If any of these errors 26 // URL is hit, the specified |errors| will be played. If any of these errors
27 // is a cert error, |ssl_cert| will be used as the ssl cert when notifying of 27 // is a cert error, |ssl_cert| will be used as the ssl cert when notifying of
28 // the error. |ssl_cert| can be NULL if |errors| does not contain any cert 28 // the error. |ssl_cert| can be NULL if |errors| does not contain any cert
29 // errors. |base| is the location on disk where the file mocking the URL 29 // errors. |base| is the location on disk where the file mocking the URL
30 // contents and http-headers should be retrieved from. 30 // contents and http-headers should be retrieved from.
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 41
42 static URLRequest::ProtocolFactory Factory; 42 static net::URLRequest::ProtocolFactory Factory;
43 43
44 void StartAsync(); 44 void StartAsync();
45 45
46 // The errors to simulate. 46 // The errors to simulate.
47 std::vector<int> errors_; 47 std::vector<int> errors_;
48 48
49 // The certificate to use for SSL errors. 49 // The certificate to use for SSL errors.
50 scoped_refptr<net::X509Certificate> ssl_cert_; 50 scoped_refptr<net::X509Certificate> ssl_cert_;
51 51
52 struct MockInfo; 52 struct MockInfo;
53 typedef std::map<GURL, MockInfo> URLMockInfoMap; 53 typedef std::map<GURL, MockInfo> URLMockInfoMap;
54 static URLMockInfoMap url_mock_info_map_; 54 static URLMockInfoMap url_mock_info_map_;
55 55
56 DISALLOW_COPY_AND_ASSIGN(URLRequestMockNetErrorJob); 56 DISALLOW_COPY_AND_ASSIGN(URLRequestMockNetErrorJob);
57 }; 57 };
58 58
59 #endif // CHROME_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_ 59 #endif // CHROME_BROWSER_NET_URL_REQUEST_MOCK_NET_ERROR_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698