| 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 #include "content/browser/net/url_request_slow_download_job.h" | 5 #include "content/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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 const char URLRequestSlowDownloadJob::kFinishDownloadUrl[] = | 25 const char URLRequestSlowDownloadJob::kFinishDownloadUrl[] = |
| 26 "http://url.handled.by.slow.download/download-finish"; | 26 "http://url.handled.by.slow.download/download-finish"; |
| 27 | 27 |
| 28 const int URLRequestSlowDownloadJob::kFirstDownloadSize = 1024 * 35; | 28 const int URLRequestSlowDownloadJob::kFirstDownloadSize = 1024 * 35; |
| 29 const int URLRequestSlowDownloadJob::kSecondDownloadSize = 1024 * 10; | 29 const int URLRequestSlowDownloadJob::kSecondDownloadSize = 1024 * 10; |
| 30 | 30 |
| 31 // static | 31 // static |
| 32 base::LazyInstance< | 32 base::LazyInstance< |
| 33 URLRequestSlowDownloadJob::SlowJobsSet, | 33 URLRequestSlowDownloadJob::SlowJobsSet, |
| 34 base::LeakyLazyInstanceTraits<URLRequestSlowDownloadJob::SlowJobsSet> > | 34 base::LeakyLazyInstanceTraits<URLRequestSlowDownloadJob::SlowJobsSet> > |
| 35 URLRequestSlowDownloadJob::pending_requests_(base::LINKER_INITIALIZED); | 35 URLRequestSlowDownloadJob::pending_requests_ = |
| 36 LAZY_INSTANCE_INITIALIZER; |
| 36 | 37 |
| 37 void URLRequestSlowDownloadJob::Start() { | 38 void URLRequestSlowDownloadJob::Start() { |
| 38 MessageLoop::current()->PostTask( | 39 MessageLoop::current()->PostTask( |
| 39 FROM_HERE, | 40 FROM_HERE, |
| 40 method_factory_.NewRunnableMethod( | 41 method_factory_.NewRunnableMethod( |
| 41 &URLRequestSlowDownloadJob::StartAsync)); | 42 &URLRequestSlowDownloadJob::StartAsync)); |
| 42 } | 43 } |
| 43 | 44 |
| 44 // static | 45 // static |
| 45 void URLRequestSlowDownloadJob::AddUrlHandler() { | 46 void URLRequestSlowDownloadJob::AddUrlHandler() { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // ParseRawHeaders expects \0 to end each header line. | 191 // ParseRawHeaders expects \0 to end each header line. |
| 191 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 192 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
| 192 info->headers = new net::HttpResponseHeaders(raw_headers); | 193 info->headers = new net::HttpResponseHeaders(raw_headers); |
| 193 } | 194 } |
| 194 | 195 |
| 195 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { | 196 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { |
| 196 net::HttpResponseInfo info; | 197 net::HttpResponseInfo info; |
| 197 GetResponseInfoConst(&info); | 198 GetResponseInfoConst(&info); |
| 198 return info.headers && info.headers->GetMimeType(mime_type); | 199 return info.headers && info.headers->GetMimeType(mime_type); |
| 199 } | 200 } |
| OLD | NEW |