summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/download_manager.h
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-21 05:31:42 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-21 05:31:42 +0000
commitd2a8fb7eb4aecf52a6f3b7a5d82dc8821e62e08f (patch)
tree1edff0a5ad2b9e16f87376a9c207eb232710cfb9 /chrome/browser/download/download_manager.h
parent934f373771313423cd91274549e4b6a73b91ff8f (diff)
downloadchromium_src-d2a8fb7eb4aecf52a6f3b7a5d82dc8821e62e08f.zip
chromium_src-d2a8fb7eb4aecf52a6f3b7a5d82dc8821e62e08f.tar.gz
chromium_src-d2a8fb7eb4aecf52a6f3b7a5d82dc8821e62e08f.tar.bz2
Don't accidentally add downloads with db_handle = kUninitializedHandle, which can happen if the sqlite history db is corrupt / offline.
BUG=25492 TEST=none Review URL: http://codereview.chromium.org/492017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/download_manager.h')
-rw-r--r--chrome/browser/download/download_manager.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/chrome/browser/download/download_manager.h b/chrome/browser/download/download_manager.h
index 5a5bda2..b562bc2 100644
--- a/chrome/browser/download/download_manager.h
+++ b/chrome/browser/download/download_manager.h
@@ -35,11 +35,9 @@
#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_
-#include "build/build_config.h"
-
-#include <string>
#include <map>
#include <set>
+#include <string>
#include <vector>
#include "base/basictypes.h"
@@ -381,7 +379,7 @@ class DownloadManager : public base::RefCountedThreadSafe<DownloadManager>,
void UpdateDownload(int32 download_id, int64 size);
void DownloadFinished(int32 download_id, int64 size);
- // Called from a view when a user clicks a UI button or link.
+ // Called from a view when a user clicks a UI button or link.
void DownloadCancelled(int32 download_id);
void PauseDownload(int32 download_id, bool pause);
void RemoveDownload(int64 download_handle);
@@ -510,6 +508,16 @@ class DownloadManager : public base::RefCountedThreadSafe<DownloadManager>,
FilePath* generated_name);
private:
+
+ class FakeDbHandleGenerator {
+ public:
+ explicit FakeDbHandleGenerator(int64 start_value) : value_(start_value) {}
+
+ int64 GetNext() { return value_--; }
+ private:
+ int64 value_;
+ };
+
friend class base::RefCountedThreadSafe<DownloadManager>;
~DownloadManager();
@@ -671,6 +679,12 @@ class DownloadManager : public base::RefCountedThreadSafe<DownloadManager>,
// saved.
scoped_refptr<SelectFileDialog> select_file_dialog_;
+ // In case we don't have a valid db_handle, we use |fake_db_handle_| instead.
+ // This is useful for incognito mode or when the history database is offline.
+ // Downloads are expected to have unique handles, so FakeDbHandleGenerator
+ // automatically decrement the handle value on every use.
+ FakeDbHandleGenerator fake_db_handle_;
+
DISALLOW_COPY_AND_ASSIGN(DownloadManager);
};