OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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/time.h" | 7 #include "base/time.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "net/url_request/url_request_filter.h" | 9 #include "net/url_request/url_request_filter.h" |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); | 32 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); |
33 filter->AddHostnameHandler("http", kMockHostname, | 33 filter->AddHostnameHandler("http", kMockHostname, |
34 URLRequestSlowHTTPJob::Factory); | 34 URLRequestSlowHTTPJob::Factory); |
35 } | 35 } |
36 | 36 |
37 /* static */ | 37 /* static */ |
38 GURL URLRequestSlowHTTPJob::GetMockUrl(const FilePath& path) { | 38 GURL URLRequestSlowHTTPJob::GetMockUrl(const FilePath& path) { |
39 std::string url = "http://"; | 39 std::string url = "http://"; |
40 url.append(kMockHostname); | 40 url.append(kMockHostname); |
41 url.append("/"); | 41 url.append("/"); |
42 url.append(WideToUTF8(path.ToWStringHack())); | 42 url.append(UTF16ToUTF8(path.LossyDisplayName())); |
43 return GURL(url); | 43 return GURL(url); |
44 } | 44 } |
45 | 45 |
46 URLRequestSlowHTTPJob::URLRequestSlowHTTPJob(net::URLRequest* request, | 46 URLRequestSlowHTTPJob::URLRequestSlowHTTPJob(net::URLRequest* request, |
47 const FilePath& file_path) | 47 const FilePath& file_path) |
48 : URLRequestMockHTTPJob(request, file_path) { } | 48 : URLRequestMockHTTPJob(request, file_path) { } |
49 | 49 |
50 void URLRequestSlowHTTPJob::Start() { | 50 void URLRequestSlowHTTPJob::Start() { |
51 delay_timer_.Start(TimeDelta::FromMilliseconds(kDelayMs), this, | 51 delay_timer_.Start(TimeDelta::FromMilliseconds(kDelayMs), this, |
52 &URLRequestSlowHTTPJob::RealStart); | 52 &URLRequestSlowHTTPJob::RealStart); |
53 } | 53 } |
54 | 54 |
55 URLRequestSlowHTTPJob::~URLRequestSlowHTTPJob() { | 55 URLRequestSlowHTTPJob::~URLRequestSlowHTTPJob() { |
56 } | 56 } |
57 | 57 |
58 void URLRequestSlowHTTPJob::RealStart() { | 58 void URLRequestSlowHTTPJob::RealStart() { |
59 URLRequestMockHTTPJob::Start(); | 59 URLRequestMockHTTPJob::Start(); |
60 } | 60 } |
OLD | NEW |