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