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

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

Issue 9296012: Hooked up NetLog to DownloadItem, DownloadFile, and FileStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with trunk Created 8 years, 10 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 | Annotate | Revision Log
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_manager_impl.h" 5 #include "content/browser/download/download_manager_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 base::hash_map<int64, DownloadItem*>::const_iterator iter_; 120 base::hash_map<int64, DownloadItem*>::const_iterator iter_;
121 // Allow copy and assign. 121 // Allow copy and assign.
122 }; 122 };
123 123
124 } // namespace 124 } // namespace
125 125
126 namespace content { 126 namespace content {
127 127
128 // static 128 // static
129 DownloadManager* DownloadManager::Create( 129 DownloadManager* DownloadManager::Create(
130 content::DownloadManagerDelegate* delegate) { 130 content::DownloadManagerDelegate* delegate,
131 return new DownloadManagerImpl(delegate); 131 net::NetLog* net_log) {
132 return new DownloadManagerImpl(delegate, net_log);
132 } 133 }
133 134
134 } // namespace content 135 } // namespace content
135 136
136 DownloadManagerImpl::DownloadManagerImpl( 137 DownloadManagerImpl::DownloadManagerImpl(
137 content::DownloadManagerDelegate* delegate) 138 content::DownloadManagerDelegate* delegate,
139 net::NetLog* net_log)
138 : shutdown_needed_(false), 140 : shutdown_needed_(false),
139 browser_context_(NULL), 141 browser_context_(NULL),
140 file_manager_(NULL), 142 file_manager_(NULL),
141 delegate_(delegate), 143 delegate_(delegate),
142 largest_db_handle_in_history_(DownloadItem::kUninitializedHandle) { 144 largest_db_handle_in_history_(DownloadItem::kUninitializedHandle),
145 net_log_(net_log) {
143 } 146 }
144 147
145 DownloadManagerImpl::~DownloadManagerImpl() { 148 DownloadManagerImpl::~DownloadManagerImpl() {
146 DCHECK(!shutdown_needed_); 149 DCHECK(!shutdown_needed_);
147 } 150 }
148 151
149 DownloadId DownloadManagerImpl::GetNextId() { 152 DownloadId DownloadManagerImpl::GetNextId() {
150 return delegate_->GetNextId(); 153 return delegate_->GetNextId();
151 } 154 }
152 155
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 385 }
383 386
384 content::BrowserContext* DownloadManagerImpl::GetBrowserContext() const { 387 content::BrowserContext* DownloadManagerImpl::GetBrowserContext() const {
385 return browser_context_; 388 return browser_context_;
386 } 389 }
387 390
388 FilePath DownloadManagerImpl::LastDownloadPath() { 391 FilePath DownloadManagerImpl::LastDownloadPath() {
389 return last_download_path_; 392 return last_download_path_;
390 } 393 }
391 394
392 void DownloadManagerImpl::CreateDownloadItem( 395 net::BoundNetLog DownloadManagerImpl::CreateDownloadItem(
393 DownloadCreateInfo* info, const DownloadRequestHandle& request_handle) { 396 DownloadCreateInfo* info, const DownloadRequestHandle& request_handle) {
394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
395 398
399 net::BoundNetLog bound_net_log =
400 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
396 DownloadItem* download = new DownloadItemImpl( 401 DownloadItem* download = new DownloadItemImpl(
397 this, *info, new DownloadRequestHandle(request_handle), 402 this, *info, new DownloadRequestHandle(request_handle),
398 browser_context_->IsOffTheRecord(), net::BoundNetLog()); 403 browser_context_->IsOffTheRecord(), bound_net_log);
399 int32 download_id = info->download_id.local(); 404 int32 download_id = info->download_id.local();
400 DCHECK(!ContainsKey(in_progress_, download_id)); 405 DCHECK(!ContainsKey(in_progress_, download_id));
401 406
402 CHECK_96627(!ContainsKey(active_downloads_, download_id)); 407 CHECK_96627(!ContainsKey(active_downloads_, download_id));
403 downloads_.insert(download); 408 downloads_.insert(download);
404 active_downloads_[download_id] = download; 409 active_downloads_[download_id] = download;
410
411 return bound_net_log;
405 } 412 }
406 413
407 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem( 414 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem(
408 const FilePath& main_file_path, 415 const FilePath& main_file_path,
409 const GURL& page_url, 416 const GURL& page_url,
410 bool is_otr, 417 bool is_otr,
411 DownloadItem::Observer* observer) { 418 DownloadItem::Observer* observer) {
419 net::BoundNetLog bound_net_log =
420 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
412 DownloadItem* download = new DownloadItemImpl( 421 DownloadItem* download = new DownloadItemImpl(
413 this, main_file_path, page_url, is_otr, GetNextId(), net::BoundNetLog()); 422 this, main_file_path, page_url, is_otr, GetNextId(), bound_net_log);
414 423
415 download->AddObserver(observer); 424 download->AddObserver(observer);
416 425
417 DCHECK(!ContainsKey(save_page_downloads_, download->GetId())); 426 DCHECK(!ContainsKey(save_page_downloads_, download->GetId()));
418 downloads_.insert(download); 427 downloads_.insert(download);
419 save_page_downloads_[download->GetId()] = download; 428 save_page_downloads_[download->GetId()] = download;
420 429
421 // Will notify the observer in the callback. 430 // Will notify the observer in the callback.
422 delegate_->AddItemToPersistentStore(download); 431 delegate_->AddItemToPersistentStore(download);
423 432
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 916
908 // The history service has retrieved all download entries. 'entries' contains 917 // The history service has retrieved all download entries. 'entries' contains
909 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time). 918 // 'DownloadPersistentStoreInfo's in sorted order (by ascending start_time).
910 void DownloadManagerImpl::OnPersistentStoreQueryComplete( 919 void DownloadManagerImpl::OnPersistentStoreQueryComplete(
911 std::vector<DownloadPersistentStoreInfo>* entries) { 920 std::vector<DownloadPersistentStoreInfo>* entries) {
912 // TODO(rdsmith): Remove this and related logic when 921 // TODO(rdsmith): Remove this and related logic when
913 // http://crbug.com/96627 is fixed. 922 // http://crbug.com/96627 is fixed.
914 largest_db_handle_in_history_ = 0; 923 largest_db_handle_in_history_ = 0;
915 924
916 for (size_t i = 0; i < entries->size(); ++i) { 925 for (size_t i = 0; i < entries->size(); ++i) {
926 net::BoundNetLog bound_net_log =
927 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
917 DownloadItem* download = new DownloadItemImpl( 928 DownloadItem* download = new DownloadItemImpl(
918 this, GetNextId(), entries->at(i), net::BoundNetLog()); 929 this, GetNextId(), entries->at(i), bound_net_log);
919 CHECK_96627(!ContainsKey(history_downloads_, download->GetDbHandle())); 930 CHECK_96627(!ContainsKey(history_downloads_, download->GetDbHandle()));
920 downloads_.insert(download); 931 downloads_.insert(download);
921 history_downloads_[download->GetDbHandle()] = download; 932 history_downloads_[download->GetDbHandle()] = download;
922 VLOG(20) << __FUNCTION__ << "()" << i << ">" 933 VLOG(20) << __FUNCTION__ << "()" << i << ">"
923 << " download = " << download->DebugString(true); 934 << " download = " << download->DebugString(true);
924 935
925 if (download->GetDbHandle() > largest_db_handle_in_history_) 936 if (download->GetDbHandle() > largest_db_handle_in_history_)
926 largest_db_handle_in_history_ = download->GetDbHandle(); 937 largest_db_handle_in_history_ = download->GetDbHandle();
927 } 938 }
928 NotifyModelChanged(); 939 NotifyModelChanged();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 it != history_downloads_.end(); ++it) { 1177 it != history_downloads_.end(); ++it) {
1167 if (it->second->IsComplete() && !it->second->GetOpened()) 1178 if (it->second->IsComplete() && !it->second->GetOpened())
1168 ++num_unopened; 1179 ++num_unopened;
1169 } 1180 }
1170 download_stats::RecordOpensOutstanding(num_unopened); 1181 download_stats::RecordOpensOutstanding(num_unopened);
1171 } 1182 }
1172 1183
1173 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { 1184 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) {
1174 file_manager_ = file_manager; 1185 file_manager_ = file_manager;
1175 } 1186 }
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.h ('k') | content/browser/download/download_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698