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

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

Issue 8487002: Basic tests for DownloadUrl/DownloadUrlToFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed early setting of info->path to avoid assertion. Created 9 years, 1 month 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) 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.h" 5 #include "content/browser/download/download_manager.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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 shutdown_needed_ = false; 167 shutdown_needed_ = false;
168 } 168 }
169 169
170 void DownloadManager::GetTemporaryDownloads( 170 void DownloadManager::GetTemporaryDownloads(
171 const FilePath& dir_path, DownloadVector* result) { 171 const FilePath& dir_path, DownloadVector* result) {
172 DCHECK(result); 172 DCHECK(result);
173 173
174 for (DownloadMap::iterator it = history_downloads_.begin(); 174 for (DownloadMap::iterator it = history_downloads_.begin();
175 it != history_downloads_.end(); ++it) { 175 it != history_downloads_.end(); ++it) {
176 if (it->second->is_temporary() && 176 if (it->second->is_temporary() &&
177 it->second->full_path().DirName() == dir_path) 177 (dir_path.empty() || it->second->full_path().DirName() == dir_path))
178 result->push_back(it->second); 178 result->push_back(it->second);
179 } 179 }
180 } 180 }
181 181
182 void DownloadManager::GetAllDownloads( 182 void DownloadManager::GetAllDownloads(
183 const FilePath& dir_path, DownloadVector* result) { 183 const FilePath& dir_path, DownloadVector* result) {
184 DCHECK(result); 184 DCHECK(result);
185 185
186 for (DownloadMap::iterator it = history_downloads_.begin(); 186 for (DownloadMap::iterator it = history_downloads_.begin();
187 it != history_downloads_.end(); ++it) { 187 it != history_downloads_.end(); ++it) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 337
338 int32 download_id = download->id(); 338 int32 download_id = download->id();
339 339
340 // NOTE(ahendrickson) Eventually |active_downloads_| will replace 340 // NOTE(ahendrickson) Eventually |active_downloads_| will replace
341 // |in_progress_|, but we don't want to change the semantics yet. 341 // |in_progress_|, but we don't want to change the semantics yet.
342 DCHECK(!ContainsKey(in_progress_, download_id)); 342 DCHECK(!ContainsKey(in_progress_, download_id));
343 DCHECK(ContainsKey(downloads_, download)); 343 DCHECK(ContainsKey(downloads_, download));
344 DCHECK(ContainsKey(active_downloads_, download_id)); 344 DCHECK(ContainsKey(active_downloads_, download_id));
345 345
346 // Make sure the initial file name is set only once. 346 // Make sure the initial file name is set only once.
347 DCHECK(download->full_path().empty());
347 download->OnPathDetermined(chosen_file); 348 download->OnPathDetermined(chosen_file);
348 349
349 VLOG(20) << __FUNCTION__ << "()" 350 VLOG(20) << __FUNCTION__ << "()"
350 << " download = " << download->DebugString(true); 351 << " download = " << download->DebugString(true);
351 352
352 in_progress_[download_id] = download; 353 in_progress_[download_id] = download;
353 UpdateDownloadProgress(); // Reflect entry into in_progress_. 354 UpdateDownloadProgress(); // Reflect entry into in_progress_.
354 355
355 // Rename to intermediate name. 356 // Rename to intermediate name.
356 FilePath download_path; 357 FilePath download_path;
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 void DownloadManager::MarkDownloadOpened(DownloadItem* download) { 1075 void DownloadManager::MarkDownloadOpened(DownloadItem* download) {
1075 delegate_->UpdateItemInPersistentStore(download); 1076 delegate_->UpdateItemInPersistentStore(download);
1076 int num_unopened = 0; 1077 int num_unopened = 0;
1077 for (DownloadMap::iterator it = history_downloads_.begin(); 1078 for (DownloadMap::iterator it = history_downloads_.begin();
1078 it != history_downloads_.end(); ++it) { 1079 it != history_downloads_.end(); ++it) {
1079 if (it->second->IsComplete() && !it->second->opened()) 1080 if (it->second->IsComplete() && !it->second->opened())
1080 ++num_unopened; 1081 ++num_unopened;
1081 } 1082 }
1082 download_stats::RecordOpensOutstanding(num_unopened); 1083 download_stats::RecordOpensOutstanding(num_unopened);
1083 } 1084 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698