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

Side by Side Diff: chrome/browser/download/chrome_download_manager_delegate.cc

Issue 10831302: Download resumption - Preliminary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed content unit tests. Created 8 years, 2 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 "chrome/browser/download/chrome_download_manager_delegate.h" 5 #include "chrome/browser/download/chrome_download_manager_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 l10n_util::GetStringUTF8(IDS_DOWNLOAD_UNCONFIRMED_PREFIX); 244 l10n_util::GetStringUTF8(IDS_DOWNLOAD_UNCONFIRMED_PREFIX);
245 #endif 245 #endif
246 base::SStringPrintf( 246 base::SStringPrintf(
247 &file_name, 247 &file_name,
248 unconfirmed_prefix.append( 248 unconfirmed_prefix.append(
249 FILE_PATH_LITERAL(" %d.crdownload")).c_str(), 249 FILE_PATH_LITERAL(" %d.crdownload")).c_str(),
250 base::RandInt(0, 1000000)); 250 base::RandInt(0, 1000000));
251 return dir.Append(file_name); 251 return dir.Append(file_name);
252 } 252 }
253 253
254 int64 ChromeDownloadManagerDelegate::GetIntermediateFileLength(
benjhayden 2012/10/15 17:59:37 Could this move to download_utils?
255 const FilePath& path, bool temporary) {
256 // Get the intermediate file name.
257 FilePath crpath = path;
258
259 if (!temporary)
260 crpath = download_util::GetCrDownloadPath(path);
261
262 // Validate the start offset.
263 int64 end = 0;
264 if (file_util::GetFileSize(crpath, &end))
265 return end;
266
267 return 0;
268 }
269
254 WebContents* ChromeDownloadManagerDelegate:: 270 WebContents* ChromeDownloadManagerDelegate::
255 GetAlternativeWebContentsToNotifyForDownload() { 271 GetAlternativeWebContentsToNotifyForDownload() {
256 #if defined(OS_ANDROID) 272 #if defined(OS_ANDROID)
257 // Android does not implement BrowserList or any other way to get an 273 // Android does not implement BrowserList or any other way to get an
258 // alternate web contents. 274 // alternate web contents.
259 return NULL; 275 return NULL;
260 #else 276 #else
261 // Start the download in the last active browser. This is not ideal but better 277 // Start the download in the last active browser. This is not ideal but better
262 // than fully hiding the download from the user. 278 // than fully hiding the download from the user.
263 Browser* last_active = browser::FindLastActiveWithProfile(profile_); 279 Browser* last_active = browser::FindLastActiveWithProfile(profile_);
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 int32 download_id, int64 db_handle) { 920 int32 download_id, int64 db_handle) {
905 // It's not immediately obvious, but HistoryBackend::CreateDownload() can 921 // It's not immediately obvious, but HistoryBackend::CreateDownload() can
906 // call this function with an invalid |db_handle|. For instance, this can 922 // call this function with an invalid |db_handle|. For instance, this can
907 // happen when the history database is offline. We cannot have multiple 923 // happen when the history database is offline. We cannot have multiple
908 // DownloadItems with the same invalid db_handle, so we need to assign a 924 // DownloadItems with the same invalid db_handle, so we need to assign a
909 // unique |db_handle| here. 925 // unique |db_handle| here.
910 if (db_handle == DownloadItem::kUninitializedHandle) 926 if (db_handle == DownloadItem::kUninitializedHandle)
911 db_handle = download_history_->GetNextFakeDbHandle(); 927 db_handle = download_history_->GetNextFakeDbHandle();
912 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); 928 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle);
913 } 929 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698