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

Unified Diff: chrome/browser/download/download_prefs.cc

Issue 7237034: sql::MetaTable.next_download_id, DownloadManager::GetNextId() (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: DownloadPrefs::GetNextId() Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_prefs.cc
diff --git a/chrome/browser/download/download_prefs.cc b/chrome/browser/download/download_prefs.cc
index c627bf7896c6424f8362956e2f4dde6c4693dc90..9b2758dcf0a209cac6f86c85e1e4b1462d234320 100644
--- a/chrome/browser/download/download_prefs.cc
+++ b/chrome/browser/download/download_prefs.cc
@@ -18,6 +18,7 @@
#include "content/browser/browser_thread.h"
DownloadPrefs::DownloadPrefs(PrefService* prefs) : prefs_(prefs) {
+ next_download_id_.Init(prefs::kNextDownloadId, prefs, NULL);
prompt_for_download_.Init(prefs::kPromptForDownload, prefs, NULL);
download_path_.Init(prefs::kDownloadDefaultDirectory, prefs, NULL);
save_file_type_.Init(prefs::kSaveFileType, prefs, NULL);
@@ -47,6 +48,9 @@ DownloadPrefs::~DownloadPrefs() {
// static
void DownloadPrefs::RegisterUserPrefs(PrefService* prefs) {
+ prefs->RegisterIntegerPref(prefs::kNextDownloadId,
+ 0,
+ PrefService::UNSYNCABLE_PREF);
prefs->RegisterBooleanPref(prefs::kPromptForDownload,
false,
PrefService::SYNCABLE_PREF);
@@ -135,6 +139,13 @@ void DownloadPrefs::ResetAutoOpen() {
SaveAutoOpenState();
}
+int DownloadPrefs::GetNextId() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ int next_id = *next_download_id_;
+ prefs_->SetInteger(prefs::kNextDownloadId, next_id + 1);
+ return next_id;
+}
+
void DownloadPrefs::SaveAutoOpenState() {
std::string extensions;
for (AutoOpenSet::iterator it = auto_open_.begin();

Powered by Google App Engine
This is Rietveld 408576698