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

Side by Side Diff: content/test/net/url_request_failed_job.h

Issue 24503004: Show IDN in error screens (DNS failure etc.) (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 2 months 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
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | content/test/net/url_request_failed_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CONTENT_TEST_NET_URL_REQUEST_FAILED_JOB_H_ 5 #ifndef CONTENT_TEST_NET_URL_REQUEST_FAILED_JOB_H_
6 #define CONTENT_TEST_NET_URL_REQUEST_FAILED_JOB_H_ 6 #define CONTENT_TEST_NET_URL_REQUEST_FAILED_JOB_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "net/url_request/url_request_job.h" 12 #include "net/url_request/url_request_job.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 // This class simulates a URLRequestJob failing with a given error code while 17 // This class simulates a URLRequestJob failing with a given error code while
18 // trying to connect. 18 // trying to connect.
19 class URLRequestFailedJob : public net::URLRequestJob { 19 class URLRequestFailedJob : public net::URLRequestJob {
20 public: 20 public:
21 URLRequestFailedJob(net::URLRequest* request, 21 URLRequestFailedJob(net::URLRequest* request,
22 net::NetworkDelegate* network_delegate, 22 net::NetworkDelegate* network_delegate,
23 int net_error); 23 int net_error);
24 24
25 virtual void Start() OVERRIDE; 25 virtual void Start() OVERRIDE;
26 26
27 // Adds the testing URLs to the net::URLRequestFilter. 27 // Adds the testing URLs to the net::URLRequestFilter.
28 static void AddUrlHandler(); 28 static void AddUrlHandler();
29 static void AddUrlHandlerForHostname(const std::string& hostname);
29 30
30 // Given a net error code, constructs a mock URL that will return that error 31 // Given a net error code, constructs a mock URL that will return that error
31 // asynchronously when started. |net_error| must be a valid net error code 32 // asynchronously when started. |net_error| must be a valid net error code
32 // other than net::OK and net::ERR_IO_PENDING. 33 // other than net::OK and net::ERR_IO_PENDING.
33 static GURL GetMockHttpUrl(int net_error); 34 static GURL GetMockHttpUrl(int net_error);
34 static GURL GetMockHttpsUrl(int net_error); 35 static GURL GetMockHttpsUrl(int net_error);
35 36
37 // URLRequestFailedJob must be added as a handler for |hostname| for
38 // the returned URL to return |net_error|.
39 static GURL GetMockHttpUrlForHostname(int net_error,
40 const std::string& hostname);
41 static GURL GetMockHttpsUrlForHostname(int net_error,
42 const std::string& hostname);
43
36 private: 44 private:
37 static net::URLRequestJob* Factory(net::URLRequest* request, 45 static net::URLRequestJob* Factory(net::URLRequest* request,
38 net::NetworkDelegate* network_delegate, 46 net::NetworkDelegate* network_delegate,
39 const std::string& scheme); 47 const std::string& scheme);
40 48
41 virtual ~URLRequestFailedJob(); 49 virtual ~URLRequestFailedJob();
42 50
43 // Simulate a failure. 51 // Simulate a failure.
44 void StartAsync(); 52 void StartAsync();
45 53
46 const int net_error_; 54 const int net_error_;
47 55
48 base::WeakPtrFactory<URLRequestFailedJob> weak_factory_; 56 base::WeakPtrFactory<URLRequestFailedJob> weak_factory_;
49 57
50 DISALLOW_COPY_AND_ASSIGN(URLRequestFailedJob); 58 DISALLOW_COPY_AND_ASSIGN(URLRequestFailedJob);
51 }; 59 };
52 60
53 } // namespace content 61 } // namespace content
54 62
55 #endif // CONTENT_TEST_NET_URL_REQUEST_FAILED_JOB_H_ 63 #endif // CONTENT_TEST_NET_URL_REQUEST_FAILED_JOB_H_
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | content/test/net/url_request_failed_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698