| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/net/url_request_slow_http_job.h" | 5 #include "chrome/browser/net/url_request_slow_http_job.h" |
| 6 | 6 |
| 7 #include "base/platform_thread.h" | 7 #include "base/platform_thread.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "net/url_request/url_request_filter.h" | 10 #include "net/url_request/url_request_filter.h" |
| 11 | 11 |
| 12 static const char kMockHostname[] = "mock.slow.http"; | 12 static const char kMockHostname[] = "mock.slow.http"; |
| 13 | 13 |
| 14 FilePath URLRequestSlowHTTPJob::base_path_; | 14 FilePath URLRequestSlowHTTPJob::base_path_; |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 const int URLRequestSlowHTTPJob::kDelayMs = 1000; | 17 const int URLRequestSlowHTTPJob::kDelayMs = 1000; |
| 18 | 18 |
| 19 using base::TimeDelta; | 19 using base::TimeDelta; |
| 20 | 20 |
| 21 /* static */ | 21 /* static */ |
| 22 URLRequestJob* URLRequestSlowHTTPJob::Factory(net::URLRequest* request, | 22 net::URLRequestJob* URLRequestSlowHTTPJob::Factory(net::URLRequest* request, |
| 23 const std::string& scheme) { | 23 const std::string& scheme) { |
| 24 return new URLRequestSlowHTTPJob(request, | 24 return new URLRequestSlowHTTPJob(request, |
| 25 GetOnDiskPath(base_path_, request, scheme)); | 25 GetOnDiskPath(base_path_, request, scheme)); |
| 26 } | 26 } |
| 27 | 27 |
| 28 /* static */ | 28 /* static */ |
| 29 void URLRequestSlowHTTPJob::AddUrlHandler(const FilePath& base_path) { | 29 void URLRequestSlowHTTPJob::AddUrlHandler(const FilePath& base_path) { |
| 30 base_path_ = base_path; | 30 base_path_ = base_path; |
| 31 | 31 |
| 32 // Add kMockHostname to URLRequestFilter. | 32 // Add kMockHostname to URLRequestFilter. |
| 33 URLRequestFilter* filter = URLRequestFilter::GetInstance(); | 33 URLRequestFilter* filter = URLRequestFilter::GetInstance(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 52 delay_timer_.Start(TimeDelta::FromMilliseconds(kDelayMs), this, | 52 delay_timer_.Start(TimeDelta::FromMilliseconds(kDelayMs), this, |
| 53 &URLRequestSlowHTTPJob::RealStart); | 53 &URLRequestSlowHTTPJob::RealStart); |
| 54 } | 54 } |
| 55 | 55 |
| 56 URLRequestSlowHTTPJob::~URLRequestSlowHTTPJob() { | 56 URLRequestSlowHTTPJob::~URLRequestSlowHTTPJob() { |
| 57 } | 57 } |
| 58 | 58 |
| 59 void URLRequestSlowHTTPJob::RealStart() { | 59 void URLRequestSlowHTTPJob::RealStart() { |
| 60 URLRequestMockHTTPJob::Start(); | 60 URLRequestMockHTTPJob::Start(); |
| 61 } | 61 } |
| OLD | NEW |