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

Side by Side Diff: chrome/browser/history/download_database.h

Issue 8008021: Add new UMA stats to get a handle on Downloads UI Usage (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: uma Created 9 years, 3 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 | 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 #ifndef CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ 5 #ifndef CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_
6 #define CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ 6 #define CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 16 matching lines...) Expand all
27 // Must call InitDownloadTable before using any other functions. 27 // Must call InitDownloadTable before using any other functions.
28 DownloadDatabase(); 28 DownloadDatabase();
29 virtual ~DownloadDatabase(); 29 virtual ~DownloadDatabase();
30 30
31 int next_download_id() const { return next_id_; } 31 int next_download_id() const { return next_id_; }
32 32
33 // Get all the downloads from the database. 33 // Get all the downloads from the database.
34 void QueryDownloads(std::vector<DownloadPersistentStoreInfo>* results); 34 void QueryDownloads(std::vector<DownloadPersistentStoreInfo>* results);
35 35
36 // Update the state of one download. Returns true if successful. 36 // Update the state of one download. Returns true if successful.
37 bool UpdateDownload(int64 received_bytes, int32 state, DownloadID db_handle); 37 bool UpdateDownload(int64 received_bytes, int32 state,
38 const base::Time& end_time, DownloadID db_handle);
38 39
39 // Update the path of one download. Returns true if successful. 40 // Update the path of one download. Returns true if successful.
40 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle); 41 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle);
41 42
42 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS 43 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS
43 // state are not updated during browser shutdown (particularly when crashing). 44 // state are not updated during browser shutdown (particularly when crashing).
44 // On the next start such entries are considered canceled. This functions 45 // On the next start such entries are considered canceled. This functions
45 // fixes such entries. 46 // fixes such entries.
46 bool CleanUpInProgressEntries(); 47 bool CleanUpInProgressEntries();
47 48
48 // Create a new database entry for one download and return its primary db id. 49 // Create a new database entry for one download and return its primary db id.
49 int64 CreateDownload(const DownloadPersistentStoreInfo& info); 50 int64 CreateDownload(const DownloadPersistentStoreInfo& info);
50 51
51 // Remove a download from the database. 52 // Remove a download from the database.
52 void RemoveDownload(DownloadID db_handle); 53 void RemoveDownload(DownloadID db_handle);
53 54
54 // Remove all completed downloads that started after |remove_begin| 55 // Remove all completed downloads that started after |remove_begin|
55 // (inclusive) and before |remove_end|. You may use null Time values 56 // (inclusive) and before |remove_end|. You may use null Time values
56 // to do an unbounded delete in either direction. This function ignores 57 // to do an unbounded delete in either direction. This function ignores
57 // all downloads that are in progress or are waiting to be cancelled. 58 // all downloads that are in progress or are waiting to be cancelled.
58 void RemoveDownloadsBetween(base::Time remove_begin, base::Time remove_end); 59 void RemoveDownloadsBetween(base::Time remove_begin, base::Time remove_end);
59 60
61 // Set the |opened| flag to true.
62 void MarkDownloadOpened(DownloadID db_handle);
63
60 protected: 64 protected:
61 // Returns the database for the functions in this interface. 65 // Returns the database for the functions in this interface.
62 virtual sql::Connection& GetDB() = 0; 66 virtual sql::Connection& GetDB() = 0;
63 67
64 // Creates the downloads table if needed. 68 // Creates the downloads table if needed.
65 bool InitDownloadTable(); 69 bool InitDownloadTable();
66 70
67 // Used to quickly clear the downloads. First you would drop it, then you 71 // Used to quickly clear the downloads. First you would drop it, then you
68 // would re-initialize it. 72 // would re-initialize it.
69 bool DropDownloadTable(); 73 bool DropDownloadTable();
70 74
75 bool MaybeUpgradeDownloadsSchema();
76
77 bool CreateDownloadsTable();
78
79 enum DownloadsSchemaVersion {
80 DOWNLOADS_SCHEMA_VERSION_UNINITIALIZED = -1,
81 DOWNLOADS_SCHEMA_VERSION_BASE = 0,
82 DOWNLOADS_SCHEMA_VERSION_OPENED = 1,
83 // Add new schema versions here with explicit numbers, update kCurrent, and
84 // support your new version in CreateDownloadsTable,
85 // MaybeUpgradeDownloadsSchema, and QueryDownloads.
86 };
87 static const DownloadsSchemaVersion kCurrentDownloadsSchemaVersion =
88 DOWNLOADS_SCHEMA_VERSION_OPENED;
89
90 DownloadsSchemaVersion downloads_schema_version() const {
91 return schema_version_;
92 }
93
71 private: 94 private:
72 // TODO(rdsmith): Remove after http://crbug.com/96627 has been resolved. 95 // TODO(rdsmith): Remove after http://crbug.com/96627 has been resolved.
73 std::set<int64> returned_ids_; 96 std::set<int64> returned_ids_;
74 bool owning_thread_set_; 97 bool owning_thread_set_;
75 base::PlatformThreadId owning_thread_; 98 base::PlatformThreadId owning_thread_;
76 99
77 int next_id_; 100 int next_id_;
78 sql::MetaTable meta_table_; 101 sql::MetaTable meta_table_;
102 DownloadsSchemaVersion schema_version_;
79 103
80 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); 104 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase);
81 }; 105 };
82 106
83 } // namespace history 107 } // namespace history
84 108
85 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ 109 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698