| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_download_job.h" | 5 #include "chrome/browser/net/url_request_slow_download_job.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 std::vector<URLRequestSlowDownloadJob*> | 26 std::vector<URLRequestSlowDownloadJob*> |
| 27 URLRequestSlowDownloadJob::kPendingRequests; | 27 URLRequestSlowDownloadJob::kPendingRequests; |
| 28 | 28 |
| 29 void URLRequestSlowDownloadJob::Start() { | 29 void URLRequestSlowDownloadJob::Start() { |
| 30 MessageLoop::current()->PostTask( | 30 MessageLoop::current()->PostTask( |
| 31 FROM_HERE, | 31 FROM_HERE, |
| 32 method_factory_.NewRunnableMethod( | 32 method_factory_.NewRunnableMethod( |
| 33 &URLRequestSlowDownloadJob::StartAsync)); | 33 &URLRequestSlowDownloadJob::StartAsync)); |
| 34 } | 34 } |
| 35 | 35 |
| 36 /* static */ | 36 // static |
| 37 void URLRequestSlowDownloadJob::AddUrlHandler() { | 37 void URLRequestSlowDownloadJob::AddUrlHandler() { |
| 38 URLRequestFilter* filter = URLRequestFilter::GetInstance(); | 38 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); |
| 39 filter->AddUrlHandler(GURL(kUnknownSizeUrl), | 39 filter->AddUrlHandler(GURL(kUnknownSizeUrl), |
| 40 &URLRequestSlowDownloadJob::Factory); | 40 &URLRequestSlowDownloadJob::Factory); |
| 41 filter->AddUrlHandler(GURL(kKnownSizeUrl), | 41 filter->AddUrlHandler(GURL(kKnownSizeUrl), |
| 42 &URLRequestSlowDownloadJob::Factory); | 42 &URLRequestSlowDownloadJob::Factory); |
| 43 filter->AddUrlHandler(GURL(kFinishDownloadUrl), | 43 filter->AddUrlHandler(GURL(kFinishDownloadUrl), |
| 44 &URLRequestSlowDownloadJob::Factory); | 44 &URLRequestSlowDownloadJob::Factory); |
| 45 } | 45 } |
| 46 | 46 |
| 47 /*static */ | 47 /*static */ |
| 48 net::URLRequestJob* URLRequestSlowDownloadJob::Factory( | 48 net::URLRequestJob* URLRequestSlowDownloadJob::Factory( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // ParseRawHeaders expects \0 to end each header line. | 169 // ParseRawHeaders expects \0 to end each header line. |
| 170 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 170 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
| 171 info->headers = new net::HttpResponseHeaders(raw_headers); | 171 info->headers = new net::HttpResponseHeaders(raw_headers); |
| 172 } | 172 } |
| 173 | 173 |
| 174 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { | 174 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { |
| 175 net::HttpResponseInfo info; | 175 net::HttpResponseInfo info; |
| 176 GetResponseInfoConst(&info); | 176 GetResponseInfoConst(&info); |
| 177 return info.headers && info.headers->GetMimeType(mime_type); | 177 return info.headers && info.headers->GetMimeType(mime_type); |
| 178 } | 178 } |
| OLD | NEW |