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

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

Issue 8487002: Basic tests for DownloadUrl/DownloadUrlToFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ifdef out breaking chromeos behavior with bug pointer. Created 9 years 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
« no previous file with comments | « content/browser/download/download_file_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 shutdown_needed_ = false; 176 shutdown_needed_ = false;
177 } 177 }
178 178
179 void DownloadManagerImpl::GetTemporaryDownloads( 179 void DownloadManagerImpl::GetTemporaryDownloads(
180 const FilePath& dir_path, DownloadVector* result) { 180 const FilePath& dir_path, DownloadVector* result) {
181 DCHECK(result); 181 DCHECK(result);
182 182
183 for (DownloadMap::iterator it = history_downloads_.begin(); 183 for (DownloadMap::iterator it = history_downloads_.begin();
184 it != history_downloads_.end(); ++it) { 184 it != history_downloads_.end(); ++it) {
185 if (it->second->IsTemporary() && 185 if (it->second->IsTemporary() &&
186 it->second->GetFullPath().DirName() == dir_path) 186 (dir_path.empty() || it->second->GetFullPath().DirName() == dir_path))
187 result->push_back(it->second); 187 result->push_back(it->second);
188 } 188 }
189 } 189 }
190 190
191 void DownloadManagerImpl::GetAllDownloads( 191 void DownloadManagerImpl::GetAllDownloads(
192 const FilePath& dir_path, DownloadVector* result) { 192 const FilePath& dir_path, DownloadVector* result) {
193 DCHECK(result); 193 DCHECK(result);
194 194
195 for (DownloadMap::iterator it = history_downloads_.begin(); 195 for (DownloadMap::iterator it = history_downloads_.begin();
196 it != history_downloads_.end(); ++it) { 196 it != history_downloads_.end(); ++it) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 376
377 int32 download_id = download->GetId(); 377 int32 download_id = download->GetId();
378 378
379 // NOTE(ahendrickson) Eventually |active_downloads_| will replace 379 // NOTE(ahendrickson) Eventually |active_downloads_| will replace
380 // |in_progress_|, but we don't want to change the semantics yet. 380 // |in_progress_|, but we don't want to change the semantics yet.
381 DCHECK(!ContainsKey(in_progress_, download_id)); 381 DCHECK(!ContainsKey(in_progress_, download_id));
382 DCHECK(ContainsKey(downloads_, download)); 382 DCHECK(ContainsKey(downloads_, download));
383 DCHECK(ContainsKey(active_downloads_, download_id)); 383 DCHECK(ContainsKey(active_downloads_, download_id));
384 384
385 // Make sure the initial file name is set only once. 385 // Make sure the initial file name is set only once.
386 DCHECK(download->GetFullPath().empty());
386 download->OnPathDetermined(chosen_file); 387 download->OnPathDetermined(chosen_file);
387 388
388 VLOG(20) << __FUNCTION__ << "()" 389 VLOG(20) << __FUNCTION__ << "()"
389 << " download = " << download->DebugString(true); 390 << " download = " << download->DebugString(true);
390 391
391 in_progress_[download_id] = download; 392 in_progress_[download_id] = download;
392 UpdateDownloadProgress(); // Reflect entry into in_progress_. 393 UpdateDownloadProgress(); // Reflect entry into in_progress_.
393 394
394 // Rename to intermediate name. 395 // Rename to intermediate name.
395 FilePath download_path; 396 FilePath download_path;
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 it != history_downloads_.end(); ++it) { 1117 it != history_downloads_.end(); ++it) {
1117 if (it->second->IsComplete() && !it->second->GetOpened()) 1118 if (it->second->IsComplete() && !it->second->GetOpened())
1118 ++num_unopened; 1119 ++num_unopened;
1119 } 1120 }
1120 download_stats::RecordOpensOutstanding(num_unopened); 1121 download_stats::RecordOpensOutstanding(num_unopened);
1121 } 1122 }
1122 1123
1123 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) { 1124 void DownloadManagerImpl::SetFileManager(DownloadFileManager* file_manager) {
1124 file_manager_ = file_manager; 1125 file_manager_ = file_manager;
1125 } 1126 }
OLDNEW
« no previous file with comments | « content/browser/download/download_file_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698