OLD | NEW |
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 // A URLRequestMockHTTPJob class that inserts a time delay in processing. | 5 // A URLRequestMockHTTPJob class that inserts a time delay in processing. |
6 | 6 |
7 #ifndef CONTENT_TEST_NET_URL_REQUEST_SLOW_HTTP_JOB_H_ | 7 #ifndef CONTENT_TEST_NET_URL_REQUEST_SLOW_HTTP_JOB_H_ |
8 #define CONTENT_TEST_NET_URL_REQUEST_SLOW_HTTP_JOB_H_ | 8 #define CONTENT_TEST_NET_URL_REQUEST_SLOW_HTTP_JOB_H_ |
9 | 9 |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "content/test/net/url_request_mock_http_job.h" | 11 #include "content/test/net/url_request_mock_http_job.h" |
12 | 12 |
| 13 namespace content { |
| 14 |
13 class URLRequestSlowHTTPJob : public URLRequestMockHTTPJob { | 15 class URLRequestSlowHTTPJob : public URLRequestMockHTTPJob { |
14 public: | 16 public: |
15 URLRequestSlowHTTPJob(net::URLRequest* request, | 17 URLRequestSlowHTTPJob(net::URLRequest* request, |
16 net::NetworkDelegate* network_delegate, | 18 net::NetworkDelegate* network_delegate, |
17 const FilePath& file_path); | 19 const FilePath& file_path); |
18 | 20 |
19 static const int kDelayMs; | 21 static const int kDelayMs; |
20 | 22 |
21 static net::URLRequest::ProtocolFactory Factory; | 23 static net::URLRequest::ProtocolFactory Factory; |
22 | 24 |
23 // Adds the testing URLs to the net::URLRequestFilter. | 25 // Adds the testing URLs to the net::URLRequestFilter. |
24 static void AddUrlHandler(const FilePath& base_path); | 26 static void AddUrlHandler(const FilePath& base_path); |
25 | 27 |
26 // Given the path to a file relative to the path passed to AddUrlHandler(), | 28 // Given the path to a file relative to the path passed to AddUrlHandler(), |
27 // construct a mock URL. | 29 // construct a mock URL. |
28 static GURL GetMockUrl(const FilePath& path); | 30 static GURL GetMockUrl(const FilePath& path); |
29 | 31 |
30 virtual void Start() OVERRIDE; | 32 virtual void Start() OVERRIDE; |
31 | 33 |
32 private: | 34 private: |
33 virtual ~URLRequestSlowHTTPJob(); | 35 virtual ~URLRequestSlowHTTPJob(); |
34 | 36 |
35 void RealStart(); | 37 void RealStart(); |
36 | 38 |
37 base::OneShotTimer<URLRequestSlowHTTPJob> delay_timer_; | 39 base::OneShotTimer<URLRequestSlowHTTPJob> delay_timer_; |
38 }; | 40 }; |
39 | 41 |
| 42 } // namespace content |
| 43 |
40 #endif // CONTENT_TEST_NET_URL_REQUEST_SLOW_HTTP_JOB_H_ | 44 #endif // CONTENT_TEST_NET_URL_REQUEST_SLOW_HTTP_JOB_H_ |
OLD | NEW |