| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 "http://url.handled.by.slow.download/download-unknown-size"; | 23 "http://url.handled.by.slow.download/download-unknown-size"; |
| 24 const char URLRequestSlowDownloadJob::kKnownSizeUrl[] = | 24 const char URLRequestSlowDownloadJob::kKnownSizeUrl[] = |
| 25 "http://url.handled.by.slow.download/download-known-size"; | 25 "http://url.handled.by.slow.download/download-known-size"; |
| 26 const char URLRequestSlowDownloadJob::kFinishDownloadUrl[] = | 26 const char URLRequestSlowDownloadJob::kFinishDownloadUrl[] = |
| 27 "http://url.handled.by.slow.download/download-finish"; | 27 "http://url.handled.by.slow.download/download-finish"; |
| 28 | 28 |
| 29 const int URLRequestSlowDownloadJob::kFirstDownloadSize = 1024 * 35; | 29 const int URLRequestSlowDownloadJob::kFirstDownloadSize = 1024 * 35; |
| 30 const int URLRequestSlowDownloadJob::kSecondDownloadSize = 1024 * 10; | 30 const int URLRequestSlowDownloadJob::kSecondDownloadSize = 1024 * 10; |
| 31 | 31 |
| 32 // static | 32 // static |
| 33 base::LazyInstance< | 33 base::LazyInstance<URLRequestSlowDownloadJob::SlowJobsSet>::Leaky |
| 34 URLRequestSlowDownloadJob::SlowJobsSet, | 34 URLRequestSlowDownloadJob::pending_requests_ = LAZY_INSTANCE_INITIALIZER; |
| 35 base::LeakyLazyInstanceTraits<URLRequestSlowDownloadJob::SlowJobsSet> > | |
| 36 URLRequestSlowDownloadJob::pending_requests_ = | |
| 37 LAZY_INSTANCE_INITIALIZER; | |
| 38 | 35 |
| 39 void URLRequestSlowDownloadJob::Start() { | 36 void URLRequestSlowDownloadJob::Start() { |
| 40 MessageLoop::current()->PostTask( | 37 MessageLoop::current()->PostTask( |
| 41 FROM_HERE, | 38 FROM_HERE, |
| 42 base::Bind(&URLRequestSlowDownloadJob::StartAsync, | 39 base::Bind(&URLRequestSlowDownloadJob::StartAsync, |
| 43 weak_factory_.GetWeakPtr())); | 40 weak_factory_.GetWeakPtr())); |
| 44 } | 41 } |
| 45 | 42 |
| 46 // static | 43 // static |
| 47 void URLRequestSlowDownloadJob::AddUrlHandler() { | 44 void URLRequestSlowDownloadJob::AddUrlHandler() { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // ParseRawHeaders expects \0 to end each header line. | 232 // ParseRawHeaders expects \0 to end each header line. |
| 236 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 233 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
| 237 info->headers = new net::HttpResponseHeaders(raw_headers); | 234 info->headers = new net::HttpResponseHeaders(raw_headers); |
| 238 } | 235 } |
| 239 | 236 |
| 240 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { | 237 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { |
| 241 net::HttpResponseInfo info; | 238 net::HttpResponseInfo info; |
| 242 GetResponseInfoConst(&info); | 239 GetResponseInfoConst(&info); |
| 243 return info.headers && info.headers->GetMimeType(mime_type); | 240 return info.headers && info.headers->GetMimeType(mime_type); |
| 244 } | 241 } |
| OLD | NEW |