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/download/download_resource_handler.h" | 5 #include "content/browser/download/download_resource_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop_proxy.h" |
11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
12 #include "base/metrics/stats_counters.h" | 13 #include "base/metrics/stats_counters.h" |
13 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
14 #include "content/browser/download/download_buffer.h" | |
15 #include "content/browser/download/download_create_info.h" | 15 #include "content/browser/download/download_create_info.h" |
16 #include "content/browser/download/download_file_manager.h" | 16 #include "content/browser/download/download_file_manager.h" |
17 #include "content/browser/download/download_interrupt_reasons_impl.h" | 17 #include "content/browser/download/download_interrupt_reasons_impl.h" |
18 #include "content/browser/download/download_manager_impl.h" | 18 #include "content/browser/download/download_manager_impl.h" |
19 #include "content/browser/download/download_request_handle.h" | 19 #include "content/browser/download/download_request_handle.h" |
| 20 #include "content/browser/download/byte_stream.h" |
20 #include "content/browser/download/download_stats.h" | 21 #include "content/browser/download/download_stats.h" |
21 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 22 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
22 #include "content/browser/renderer_host/resource_request_info_impl.h" | 23 #include "content/browser/renderer_host/resource_request_info_impl.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/download_interrupt_reasons.h" | 25 #include "content/public/browser/download_interrupt_reasons.h" |
25 #include "content/public/browser/download_item.h" | 26 #include "content/public/browser/download_item.h" |
26 #include "content/public/browser/download_manager_delegate.h" | 27 #include "content/public/browser/download_manager_delegate.h" |
27 #include "content/public/common/resource_response.h" | 28 #include "content/public/common/resource_response.h" |
28 #include "net/base/io_buffer.h" | 29 #include "net/base/io_buffer.h" |
29 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
30 #include "net/http/http_response_headers.h" | 31 #include "net/http/http_response_headers.h" |
31 #include "net/url_request/url_request_context.h" | 32 #include "net/url_request/url_request_context.h" |
32 | 33 |
33 using content::BrowserThread; | 34 using content::BrowserThread; |
34 using content::DownloadId; | 35 using content::DownloadId; |
35 using content::DownloadItem; | 36 using content::DownloadItem; |
36 using content::DownloadManager; | 37 using content::DownloadManager; |
37 using content::ResourceDispatcherHostImpl; | 38 using content::ResourceDispatcherHostImpl; |
38 using content::ResourceRequestInfoImpl; | 39 using content::ResourceRequestInfoImpl; |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
| 43 static const int kDownloadPipeSize = 100 * 1024; |
| 44 |
42 void CallStartedCBOnUIThread( | 45 void CallStartedCBOnUIThread( |
43 const DownloadResourceHandler::OnStartedCallback& started_cb, | 46 const DownloadResourceHandler::OnStartedCallback& started_cb, |
44 DownloadId id, | 47 DownloadId id, |
45 net::Error error) { | 48 net::Error error) { |
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
47 if (started_cb.is_null()) | 50 if (started_cb.is_null()) |
48 return; | 51 return; |
49 started_cb.Run(id, error); | 52 started_cb.Run(id, error); |
50 } | 53 } |
51 | 54 |
52 } // namespace | 55 } // namespace |
53 | 56 |
54 DownloadResourceHandler::DownloadResourceHandler( | 57 DownloadResourceHandler::DownloadResourceHandler( |
55 int render_process_host_id, | 58 int render_process_host_id, |
56 int render_view_id, | 59 int render_view_id, |
57 int request_id, | 60 int request_id, |
58 const GURL& url, | 61 const GURL& url, |
59 DownloadFileManager* download_file_manager, | 62 DownloadFileManager* download_file_manager, |
60 net::URLRequest* request, | 63 net::URLRequest* request, |
61 const DownloadResourceHandler::OnStartedCallback& started_cb, | 64 const DownloadResourceHandler::OnStartedCallback& started_cb, |
62 const content::DownloadSaveInfo& save_info) | 65 const content::DownloadSaveInfo& save_info) |
63 : download_id_(DownloadId::Invalid()), | 66 : download_id_(DownloadId::Invalid()), |
64 global_id_(render_process_host_id, request_id), | 67 global_id_(render_process_host_id, request_id), |
65 render_view_id_(render_view_id), | 68 render_view_id_(render_view_id), |
66 content_length_(0), | 69 content_length_(0), |
67 download_file_manager_(download_file_manager), | 70 download_file_manager_(download_file_manager), |
68 request_(request), | 71 request_(request), |
69 started_cb_(started_cb), | 72 started_cb_(started_cb), |
70 save_info_(save_info), | 73 save_info_(save_info), |
71 buffer_(new content::DownloadBuffer), | |
72 is_paused_(false), | |
73 last_buffer_size_(0), | 74 last_buffer_size_(0), |
74 bytes_read_(0) { | 75 bytes_read_(0) { |
75 download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT); | 76 download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT); |
76 } | 77 } |
77 | 78 |
78 bool DownloadResourceHandler::OnUploadProgress(int request_id, | 79 bool DownloadResourceHandler::OnUploadProgress(int request_id, |
79 uint64 position, | 80 uint64 position, |
80 uint64 size) { | 81 uint64 size) { |
81 return true; | 82 return true; |
82 } | 83 } |
(...skipping 30 matching lines...) Expand all Loading... |
113 set_content_length(response->content_length); | 114 set_content_length(response->content_length); |
114 | 115 |
115 const ResourceRequestInfoImpl* request_info = | 116 const ResourceRequestInfoImpl* request_info = |
116 ResourceRequestInfoImpl::ForRequest(request_); | 117 ResourceRequestInfoImpl::ForRequest(request_); |
117 | 118 |
118 // Deleted in DownloadManager. | 119 // Deleted in DownloadManager. |
119 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo( | 120 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo( |
120 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, | 121 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, |
121 request_->net_log(), request_info->has_user_gesture(), | 122 request_->net_log(), request_info->has_user_gesture(), |
122 request_info->transition_type())); | 123 request_info->transition_type())); |
| 124 |
| 125 // Create the ByteStream pipe for sending data to the download sink. |
| 126 scoped_ptr<content::ByteStreamOutput> pipe_output; |
| 127 CreateByteStream( |
| 128 base::MessageLoopProxy::current(), |
| 129 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 130 kDownloadPipeSize, &pipe_input_, &pipe_output); |
| 131 pipe_input_->RegisterCallback( |
| 132 // We're refcounted, so this is a safe callback to pass around. |
| 133 base::Bind(&DownloadResourceHandler::ResumeRequest, this)); |
| 134 |
123 info->url_chain = request_->url_chain(); | 135 info->url_chain = request_->url_chain(); |
124 info->referrer_url = GURL(request_->referrer()); | 136 info->referrer_url = GURL(request_->referrer()); |
125 info->start_time = base::Time::Now(); | 137 info->start_time = base::Time::Now(); |
126 info->received_bytes = save_info_.offset; | 138 info->received_bytes = save_info_.offset; |
127 info->total_bytes = content_length_; | 139 info->total_bytes = content_length_; |
128 info->state = DownloadItem::IN_PROGRESS; | 140 info->state = DownloadItem::IN_PROGRESS; |
129 info->has_user_gesture = request_info->has_user_gesture(); | 141 info->has_user_gesture = request_info->has_user_gesture(); |
130 info->content_disposition = content_disposition_; | 142 info->content_disposition = content_disposition_; |
131 info->mime_type = response->mime_type; | 143 info->mime_type = response->mime_type; |
132 info->remote_address = request_->GetSocketAddress().host(); | 144 info->remote_address = request_->GetSocketAddress().host(); |
(...skipping 24 matching lines...) Expand all Loading... |
157 "Accept-Ranges", | 169 "Accept-Ranges", |
158 &accept_ranges_)) { | 170 &accept_ranges_)) { |
159 accept_ranges_ = ""; | 171 accept_ranges_ = ""; |
160 } | 172 } |
161 | 173 |
162 info->prompt_user_for_save_location = | 174 info->prompt_user_for_save_location = |
163 save_info_.prompt_for_save_location && save_info_.file_path.empty(); | 175 save_info_.prompt_for_save_location && save_info_.file_path.empty(); |
164 info->referrer_charset = request_->context()->referrer_charset(); | 176 info->referrer_charset = request_->context()->referrer_charset(); |
165 info->save_info = save_info_; | 177 info->save_info = save_info_; |
166 | 178 |
167 | |
168 BrowserThread::PostTask( | 179 BrowserThread::PostTask( |
169 BrowserThread::UI, FROM_HERE, | 180 BrowserThread::UI, FROM_HERE, |
170 base::Bind(&DownloadResourceHandler::StartOnUIThread, this, | 181 base::Bind(&DownloadResourceHandler::StartOnUIThread, this, |
171 base::Passed(&info), request_handle)); | 182 base::Passed(info.Pass()), |
172 | 183 base::Passed(pipe_output.Pass()), |
173 // We can't start saving the data before we create the file on disk and have a | 184 request_handle)); |
174 // download id. The request will be un-paused in | |
175 // DownloadFileManager::CreateDownloadFile. | |
176 ResourceDispatcherHostImpl::Get()->PauseRequest(global_id_.child_id, | |
177 global_id_.request_id, | |
178 true); | |
179 | 185 |
180 return true; | 186 return true; |
181 } | 187 } |
182 | 188 |
183 void DownloadResourceHandler::CallStartedCB(DownloadId id, net::Error error) { | 189 void DownloadResourceHandler::CallStartedCB(DownloadId id, net::Error error) { |
184 if (started_cb_.is_null()) | 190 if (started_cb_.is_null()) |
185 return; | 191 return; |
186 BrowserThread::PostTask( | 192 BrowserThread::PostTask( |
187 BrowserThread::UI, FROM_HERE, | 193 BrowserThread::UI, FROM_HERE, |
188 base::Bind(&CallStartedCBOnUIThread, started_cb_, id, error)); | 194 base::Bind(&CallStartedCBOnUIThread, started_cb_, id, error)); |
(...skipping 15 matching lines...) Expand all Loading... |
204 *buf_size = min_size < 0 ? kReadBufSize : min_size; | 210 *buf_size = min_size < 0 ? kReadBufSize : min_size; |
205 last_buffer_size_ = *buf_size; | 211 last_buffer_size_ = *buf_size; |
206 read_buffer_ = new net::IOBuffer(*buf_size); | 212 read_buffer_ = new net::IOBuffer(*buf_size); |
207 } | 213 } |
208 *buf = read_buffer_.get(); | 214 *buf = read_buffer_.get(); |
209 return true; | 215 return true; |
210 } | 216 } |
211 | 217 |
212 // Pass the buffer to the download file writer. | 218 // Pass the buffer to the download file writer. |
213 bool DownloadResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { | 219 bool DownloadResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { |
| 220 if (!read_buffer_) { |
| 221 // Ignore spurious OnReadCompleted! PauseRequest(true) called from within |
| 222 // OnReadCompleted tells the ResourceDispatcherHost that we did not consume |
| 223 // the data. PauseRequest(false) then repeats the last OnReadCompleted |
| 224 // call. We pause the request after we transmit the buffer onwards, so |
| 225 // the ResourceDispatcherHost pause mechanism does not fit our use |
| 226 // case very well. |
| 227 // Note that this test makes redundant the DCHECK() below; it's being left |
| 228 // in in hopes that the TODO will be executed soon. |
| 229 // TODO(darin): Fix the ResourceDispatcherHost to avoid this hack! |
| 230 return true; |
| 231 } |
| 232 |
214 base::TimeTicks now(base::TimeTicks::Now()); | 233 base::TimeTicks now(base::TimeTicks::Now()); |
215 if (!last_read_time_.is_null()) { | 234 if (!last_read_time_.is_null()) { |
216 double seconds_since_last_read = (now - last_read_time_).InSecondsF(); | 235 double seconds_since_last_read = (now - last_read_time_).InSecondsF(); |
217 if (now == last_read_time_) | 236 if (now == last_read_time_) |
218 // Use 1/10 ms as a "very small number" so that we avoid | 237 // Use 1/10 ms as a "very small number" so that we avoid |
219 // divide-by-zero error and still record a very high potential bandwidth. | 238 // divide-by-zero error and still record a very high potential bandwidth. |
220 seconds_since_last_read = 0.00001; | 239 seconds_since_last_read = 0.00001; |
221 | 240 |
222 double actual_bandwidth = (*bytes_read)/seconds_since_last_read; | 241 double actual_bandwidth = (*bytes_read)/seconds_since_last_read; |
223 double potential_bandwidth = last_buffer_size_/seconds_since_last_read; | 242 double potential_bandwidth = last_buffer_size_/seconds_since_last_read; |
224 download_stats::RecordBandwidth(actual_bandwidth, potential_bandwidth); | 243 download_stats::RecordBandwidth(actual_bandwidth, potential_bandwidth); |
225 } | 244 } |
226 last_read_time_ = now; | 245 last_read_time_ = now; |
227 | 246 |
228 if (!*bytes_read) | 247 if (!*bytes_read) |
229 return true; | 248 return true; |
230 bytes_read_ += *bytes_read; | 249 bytes_read_ += *bytes_read; |
231 DCHECK(read_buffer_); | 250 DCHECK(read_buffer_); |
232 // Swap the data. | |
233 net::IOBuffer* io_buffer = NULL; | |
234 read_buffer_.swap(&io_buffer); | |
235 size_t vector_size = buffer_->AddData(io_buffer, *bytes_read); | |
236 bool need_update = (vector_size == 1); // Buffer was empty. | |
237 | 251 |
238 // We are passing ownership of this buffer to the download file manager. | 252 // Take the data ship it down the pipe. If the pipe is full, pause the |
239 if (need_update) { | 253 // request; the pipe callback will resume it. |
240 BrowserThread::PostTask( | 254 if (!pipe_input_->Write(read_buffer_, *bytes_read)) { |
241 BrowserThread::FILE, FROM_HERE, | 255 ResourceDispatcherHostImpl::Get()->PauseRequest(global_id_.child_id, |
242 base::Bind(&DownloadFileManager::UpdateDownload, | 256 global_id_.request_id, |
243 download_file_manager_, download_id_, buffer_)); | 257 true); |
244 } | 258 } |
245 | 259 |
246 // We schedule a pause outside of the read loop if there is too much file | 260 read_buffer_ = NULL; // Drop our reference. |
247 // writing work to do. | |
248 if (vector_size > kLoadsToWrite) | |
249 StartPauseTimer(); | |
250 | 261 |
251 return true; | 262 return true; |
252 } | 263 } |
253 | 264 |
254 bool DownloadResourceHandler::OnResponseCompleted( | 265 bool DownloadResourceHandler::OnResponseCompleted( |
255 int request_id, | 266 int request_id, |
256 const net::URLRequestStatus& status, | 267 const net::URLRequestStatus& status, |
257 const std::string& security_info) { | 268 const std::string& security_info) { |
258 VLOG(20) << __FUNCTION__ << "()" << DebugString() | 269 VLOG(20) << __FUNCTION__ << "()" << DebugString() |
259 << " request_id = " << request_id | 270 << " request_id = " << request_id |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 break; | 336 break; |
326 } | 337 } |
327 } | 338 } |
328 } | 339 } |
329 | 340 |
330 download_stats::RecordAcceptsRanges(accept_ranges_, bytes_read_); | 341 download_stats::RecordAcceptsRanges(accept_ranges_, bytes_read_); |
331 | 342 |
332 // If the callback was already run on the UI thread, this will be a noop. | 343 // If the callback was already run on the UI thread, this will be a noop. |
333 CallStartedCB(download_id_, error_code); | 344 CallStartedCB(download_id_, error_code); |
334 | 345 |
335 // We transfer ownership to |DownloadFileManager| to delete |buffer_|, | 346 // Send the info down the pipe. Conditional is in case we get |
336 // so that any functions queued up on the FILE thread are executed | 347 // OnResponseCompleted without OnResponseStarted. |
337 // before deletion. | 348 if (pipe_input_.get()) |
338 BrowserThread::PostTask( | 349 pipe_input_->Close(reason); |
339 BrowserThread::FILE, FROM_HERE, | 350 |
340 base::Bind(&DownloadFileManager::OnResponseCompleted, | 351 pipe_input_.reset(); // We no longer need the pipe. |
341 download_file_manager_, download_id_, reason, security_info)); | |
342 buffer_ = NULL; // The buffer is longer needed by |DownloadResourceHandler|. | |
343 read_buffer_ = NULL; | 352 read_buffer_ = NULL; |
344 } | 353 } |
345 | 354 |
346 void DownloadResourceHandler::OnRequestClosed() { | 355 void DownloadResourceHandler::OnRequestClosed() { |
347 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", | 356 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", |
348 base::TimeTicks::Now() - download_start_time_); | 357 base::TimeTicks::Now() - download_start_time_); |
349 } | 358 } |
350 | 359 |
351 void DownloadResourceHandler::StartOnUIThread( | 360 void DownloadResourceHandler::StartOnUIThread( |
352 scoped_ptr<DownloadCreateInfo> info, | 361 scoped_ptr<DownloadCreateInfo> info, |
| 362 scoped_ptr<content::ByteStreamOutput> pipe, |
353 const DownloadRequestHandle& handle) { | 363 const DownloadRequestHandle& handle) { |
354 DownloadManager* download_manager = handle.GetDownloadManager(); | 364 DownloadManager* download_manager = handle.GetDownloadManager(); |
355 if (!download_manager) { | 365 if (!download_manager) { |
356 // NULL in unittests or if the page closed right after starting the | 366 // NULL in unittests or if the page closed right after starting the |
357 // download. | 367 // download. |
358 CallStartedCB(download_id_, net::ERR_ACCESS_DENIED); | 368 CallStartedCB(download_id_, net::ERR_ACCESS_DENIED); |
359 return; | 369 return; |
360 } | 370 } |
361 DownloadId download_id = download_manager->delegate()->GetNextId(); | 371 DownloadId download_id = download_manager->delegate()->GetNextId(); |
362 info->download_id = download_id; | 372 info->download_id = download_id; |
363 BrowserThread::PostTask( | 373 BrowserThread::PostTask( |
364 BrowserThread::IO, FROM_HERE, | 374 BrowserThread::IO, FROM_HERE, |
365 base::Bind(&DownloadResourceHandler::set_download_id, this, | 375 base::Bind(&DownloadResourceHandler::set_download_id, this, |
366 info->download_id)); | 376 info->download_id)); |
367 // It's safe to continue on with download initiation before we have | 377 // It's safe to continue on with download initiation before we have |
368 // confirmation that that download_id_ has been set on the IO thread, as any | 378 // confirmation that that download_id_ has been set on the IO thread, as any |
369 // messages generated by the UI thread that affect the IO thread will be | 379 // messages generated by the UI thread that affect the IO thread will be |
370 // behind the message posted above. | 380 // behind the message posted above. |
371 download_file_manager_->StartDownload(info.release(), handle); | 381 download_file_manager_->StartDownload(info.Pass(), pipe.Pass(), handle); |
372 CallStartedCB(download_id, net::OK); | 382 CallStartedCB(download_id, net::OK); |
373 } | 383 } |
374 | 384 |
375 void DownloadResourceHandler::set_download_id(content::DownloadId id) { | 385 void DownloadResourceHandler::set_download_id(content::DownloadId id) { |
376 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
377 download_id_ = id; | 387 download_id_ = id; |
378 } | 388 } |
379 | 389 |
380 // If the content-length header is not present (or contains something other | 390 // If the content-length header is not present (or contains something other |
381 // than numbers), the incoming content_length is -1 (unknown size). | 391 // than numbers), the incoming content_length is -1 (unknown size). |
382 // Set the content length to 0 to indicate unknown size to DownloadManager. | 392 // Set the content length to 0 to indicate unknown size to DownloadManager. |
383 void DownloadResourceHandler::set_content_length(const int64& content_length) { | 393 void DownloadResourceHandler::set_content_length(const int64& content_length) { |
384 content_length_ = 0; | 394 content_length_ = 0; |
385 if (content_length > 0) | 395 if (content_length > 0) |
386 content_length_ = content_length; | 396 content_length_ = content_length; |
387 } | 397 } |
388 | 398 |
389 void DownloadResourceHandler::set_content_disposition( | 399 void DownloadResourceHandler::set_content_disposition( |
390 const std::string& content_disposition) { | 400 const std::string& content_disposition) { |
391 content_disposition_ = content_disposition; | 401 content_disposition_ = content_disposition; |
392 } | 402 } |
393 | 403 |
394 void DownloadResourceHandler::CheckWriteProgress() { | |
395 if (!buffer_.get()) | |
396 return; // The download completed while we were waiting to run. | |
397 | |
398 size_t contents_size = buffer_->size(); | |
399 | |
400 bool should_pause = contents_size > kLoadsToWrite; | |
401 | |
402 // We'll come back later and see if it's okay to unpause the request. | |
403 if (should_pause) | |
404 StartPauseTimer(); | |
405 | |
406 if (is_paused_ != should_pause) { | |
407 ResourceDispatcherHostImpl::Get()->PauseRequest(global_id_.child_id, | |
408 global_id_.request_id, | |
409 should_pause); | |
410 is_paused_ = should_pause; | |
411 } | |
412 } | |
413 | |
414 DownloadResourceHandler::~DownloadResourceHandler() { | 404 DownloadResourceHandler::~DownloadResourceHandler() { |
415 // This won't do anything if the callback was called before. | 405 // This won't do anything if the callback was called before. |
416 // If it goes through, it will likely be because OnWillStart() returned | 406 // If it goes through, it will likely be because OnWillStart() returned |
417 // false somewhere in the chain of resource handlers. | 407 // false somewhere in the chain of resource handlers. |
418 CallStartedCB(download_id_, net::ERR_ACCESS_DENIED); | 408 CallStartedCB(download_id_, net::ERR_ACCESS_DENIED); |
| 409 |
| 410 // Remove output pipe callback if a pipe exists. |
| 411 if (pipe_input_.get()) |
| 412 pipe_input_->RegisterCallback(base::Closure()); |
419 } | 413 } |
420 | 414 |
421 void DownloadResourceHandler::StartPauseTimer() { | 415 void DownloadResourceHandler::ResumeRequest() { |
422 if (!pause_timer_.IsRunning()) | 416 ResourceDispatcherHostImpl::Get()->PauseRequest(global_id_.child_id, |
423 pause_timer_.Start(FROM_HERE, | 417 global_id_.request_id, |
424 base::TimeDelta::FromMilliseconds(kThrottleTimeMs), this, | 418 false); |
425 &DownloadResourceHandler::CheckWriteProgress); | |
426 } | 419 } |
427 | 420 |
428 std::string DownloadResourceHandler::DebugString() const { | 421 std::string DownloadResourceHandler::DebugString() const { |
429 return base::StringPrintf("{" | 422 return base::StringPrintf("{" |
430 " url_ = " "\"%s\"" | 423 " url_ = " "\"%s\"" |
431 " download_id_ = " "%d" | 424 " download_id_ = " "%d" |
432 " global_id_ = {" | 425 " global_id_ = {" |
433 " child_id = " "%d" | 426 " child_id = " "%d" |
434 " request_id = " "%d" | 427 " request_id = " "%d" |
435 " }" | 428 " }" |
436 " render_view_id_ = " "%d" | 429 " render_view_id_ = " "%d" |
437 " save_info_.file_path = \"%" PRFilePath "\"" | 430 " save_info_.file_path = \"%" PRFilePath "\"" |
438 " }", | 431 " }", |
439 request_ ? | 432 request_ ? |
440 request_->url().spec().c_str() : | 433 request_->url().spec().c_str() : |
441 "<NULL request>", | 434 "<NULL request>", |
442 download_id_.local(), | 435 download_id_.local(), |
443 global_id_.child_id, | 436 global_id_.child_id, |
444 global_id_.request_id, | 437 global_id_.request_id, |
445 render_view_id_, | 438 render_view_id_, |
446 save_info_.file_path.value().c_str()); | 439 save_info_.file_path.value().c_str()); |
447 } | 440 } |
OLD | NEW |