Fix build break
[chromium-blink-merge.git] / content / test / net / url_request_failed_job.h
blobfd8b435d5e71dadfd015161a1f157cbb7cd374b8
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_TEST_NET_URL_REQUEST_FAILED_JOB_H_
6 #define CONTENT_TEST_NET_URL_REQUEST_FAILED_JOB_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h"
12 #include "googleurl/src/gurl.h"
13 #include "net/url_request/url_request_job.h"
15 namespace content {
17 // This class simulates a URLRequestJob failing with a given error code while
18 // trying to connect.
19 class URLRequestFailedJob : public net::URLRequestJob {
20 public:
21 URLRequestFailedJob(net::URLRequest* request,
22 net::NetworkDelegate* network_delegate,
23 int net_error);
25 virtual void Start() OVERRIDE;
27 // Adds the testing URLs to the net::URLRequestFilter.
28 static void AddUrlHandler();
30 // 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 // other than net::OK and net::ERR_IO_PENDING.
33 static GURL GetMockHttpUrl(int net_error);
34 static GURL GetMockHttpsUrl(int net_error);
36 private:
37 static net::URLRequestJob* Factory(net::URLRequest* request,
38 net::NetworkDelegate* network_delegate,
39 const std::string& scheme);
41 virtual ~URLRequestFailedJob();
43 // Simulate a failure.
44 void StartAsync();
46 const int net_error_;
48 base::WeakPtrFactory<URLRequestFailedJob> weak_factory_;
50 DISALLOW_COPY_AND_ASSIGN(URLRequestFailedJob);
53 } // namespace content
55 #endif // CONTENT_TEST_NET_URL_REQUEST_FAILED_JOB_H_