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 3 // found in the LICENSE file. 4 // 5 // A URLRequestMockHTTPJob class that inserts a time delay in processing. 6 7 #ifndef CHROME_BROWSER_NET_URL_REQUEST_SLOW_HTTP_JOB_H_ 8 #define CHROME_BROWSER_NET_URL_REQUEST_SLOW_HTTP_JOB_H_ 9 #pragma once 10 11 #include "base/timer.h" 12 #include "chrome/browser/net/url_request_mock_http_job.h" 13 14 class URLRequestSlowHTTPJob : public URLRequestMockHTTPJob { 15 public: 16 URLRequestSlowHTTPJob(net::URLRequest* request, const FilePath& file_path); 17 18 static const int kDelayMs; 19 20 static net::URLRequest::ProtocolFactory Factory; 21 22 // Adds the testing URLs to the net::URLRequestFilter. 23 static void AddUrlHandler(const FilePath& base_path); 24 25 // Given the path to a file relative to base_path_, construct a mock URL. 26 static GURL GetMockUrl(const FilePath& path); 27 28 virtual void Start(); 29 30 private: 31 ~URLRequestSlowHTTPJob(); 32 33 void RealStart(); 34 35 base::OneShotTimer<URLRequestSlowHTTPJob> delay_timer_; 36 37 // This is the file path leading to the root of the directory to use as the 38 // root of the http server. 39 static FilePath base_path_; 40 }; 41 42 #endif // CHROME_BROWSER_NET_URL_REQUEST_SLOW_HTTP_JOB_H_ 43