Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: content/browser/download/download_file_impl.cc

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_file_impl.h" 5 #include "content/browser/download/download_file_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 24 matching lines...) Expand all
35 // initial delay is specified by kInitialRenameRetryDelayMs. 35 // initial delay is specified by kInitialRenameRetryDelayMs.
36 const int kInitialRenameRetryDelayMs = 200; 36 const int kInitialRenameRetryDelayMs = 200;
37 37
38 // Number of times a failing rename is retried before giving up. 38 // Number of times a failing rename is retried before giving up.
39 const int kMaxRenameRetries = 3; 39 const int kMaxRenameRetries = 3;
40 40
41 DownloadFileImpl::DownloadFileImpl( 41 DownloadFileImpl::DownloadFileImpl(
42 std::unique_ptr<DownloadSaveInfo> save_info, 42 std::unique_ptr<DownloadSaveInfo> save_info,
43 const base::FilePath& default_download_directory, 43 const base::FilePath& default_download_directory,
44 std::unique_ptr<ByteStreamReader> stream, 44 std::unique_ptr<ByteStreamReader> stream,
45 const net::BoundNetLog& download_item_net_log, 45 const net::NetLogWithSource& download_item_net_log,
46 base::WeakPtr<DownloadDestinationObserver> observer) 46 base::WeakPtr<DownloadDestinationObserver> observer)
47 : bound_net_log_( 47 : net_log_(
48 net::BoundNetLog::Make(download_item_net_log.net_log(), 48 net::NetLogWithSource::Make(download_item_net_log.net_log(),
49 net::NetLogSourceType::DOWNLOAD_FILE)), 49 net::NetLogSourceType::DOWNLOAD_FILE)),
50 file_(bound_net_log_), 50 file_(net_log_),
51 save_info_(std::move(save_info)), 51 save_info_(std::move(save_info)),
52 default_download_directory_(default_download_directory), 52 default_download_directory_(default_download_directory),
53 stream_reader_(std::move(stream)), 53 stream_reader_(std::move(stream)),
54 bytes_seen_(0), 54 bytes_seen_(0),
55 observer_(observer), 55 observer_(observer),
56 weak_factory_(this) { 56 weak_factory_(this) {
57 download_item_net_log.AddEvent( 57 download_item_net_log.AddEvent(
58 net::NetLogEventType::DOWNLOAD_FILE_CREATED, 58 net::NetLogEventType::DOWNLOAD_FILE_CREATED,
59 bound_net_log_.source().ToEventParametersCallback()); 59 net_log_.source().ToEventParametersCallback());
60 bound_net_log_.BeginEvent( 60 net_log_.BeginEvent(
61 net::NetLogEventType::DOWNLOAD_FILE_ACTIVE, 61 net::NetLogEventType::DOWNLOAD_FILE_ACTIVE,
62 download_item_net_log.source().ToEventParametersCallback()); 62 download_item_net_log.source().ToEventParametersCallback());
63 } 63 }
64 64
65 DownloadFileImpl::~DownloadFileImpl() { 65 DownloadFileImpl::~DownloadFileImpl() {
66 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 66 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
67 bound_net_log_.EndEvent(net::NetLogEventType::DOWNLOAD_FILE_ACTIVE); 67 net_log_.EndEvent(net::NetLogEventType::DOWNLOAD_FILE_ACTIVE);
68 } 68 }
69 69
70 void DownloadFileImpl::Initialize(const InitializeCallback& callback) { 70 void DownloadFileImpl::Initialize(const InitializeCallback& callback) {
71 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 71 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
72 72
73 update_timer_.reset(new base::RepeatingTimer()); 73 update_timer_.reset(new base::RepeatingTimer());
74 DownloadInterruptReason result = 74 DownloadInterruptReason result =
75 file_.Initialize(save_info_->file_path, 75 file_.Initialize(save_info_->file_path,
76 default_download_directory_, 76 default_download_directory_,
77 std::move(save_info_->file), 77 std::move(save_info_->file),
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 SendUpdate(); 327 SendUpdate();
328 std::unique_ptr<crypto::SecureHash> hash_state = file_.Finish(); 328 std::unique_ptr<crypto::SecureHash> hash_state = file_.Finish();
329 BrowserThread::PostTask( 329 BrowserThread::PostTask(
330 BrowserThread::UI, 330 BrowserThread::UI,
331 FROM_HERE, 331 FROM_HERE,
332 base::Bind(&DownloadDestinationObserver::DestinationCompleted, 332 base::Bind(&DownloadDestinationObserver::DestinationCompleted,
333 observer_, 333 observer_,
334 file_.bytes_so_far(), 334 file_.bytes_so_far(),
335 base::Passed(&hash_state))); 335 base::Passed(&hash_state)));
336 } 336 }
337 if (bound_net_log_.IsCapturing()) { 337 if (net_log_.IsCapturing()) {
338 bound_net_log_.AddEvent(net::NetLogEventType::DOWNLOAD_STREAM_DRAINED, 338 net_log_.AddEvent(net::NetLogEventType::DOWNLOAD_STREAM_DRAINED,
339 base::Bind(&FileStreamDrainedNetLogCallback, 339 base::Bind(&FileStreamDrainedNetLogCallback,
340 total_incoming_data_size, num_buffers)); 340 total_incoming_data_size, num_buffers));
341 } 341 }
342 } 342 }
343 343
344 void DownloadFileImpl::SendUpdate() { 344 void DownloadFileImpl::SendUpdate() {
345 BrowserThread::PostTask( 345 BrowserThread::PostTask(
346 BrowserThread::UI, 346 BrowserThread::UI,
347 FROM_HERE, 347 FROM_HERE,
348 base::Bind(&DownloadDestinationObserver::DestinationUpdate, 348 base::Bind(&DownloadDestinationObserver::DestinationUpdate,
349 observer_, 349 observer_,
350 file_.bytes_so_far(), 350 file_.bytes_so_far(),
351 rate_estimator_.GetCountPerSecond())); 351 rate_estimator_.GetCountPerSecond()));
352 } 352 }
353 353
354 DownloadFileImpl::RenameParameters::RenameParameters( 354 DownloadFileImpl::RenameParameters::RenameParameters(
355 RenameOption option, 355 RenameOption option,
356 const base::FilePath& new_path, 356 const base::FilePath& new_path,
357 const RenameCompletionCallback& completion_callback) 357 const RenameCompletionCallback& completion_callback)
358 : option(option), 358 : option(option),
359 new_path(new_path), 359 new_path(new_path),
360 retries_left(kMaxRenameRetries), 360 retries_left(kMaxRenameRetries),
361 completion_callback(completion_callback) {} 361 completion_callback(completion_callback) {}
362 362
363 DownloadFileImpl::RenameParameters::~RenameParameters() {} 363 DownloadFileImpl::RenameParameters::~RenameParameters() {}
364 364
365 } // namespace content 365 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698