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

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: comments Created 9 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 | 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 #include <string>
10 11
11 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
12 #include "chrome/browser/history/history_types.h" 13 #include "chrome/browser/history/history_types.h"
13 #include "sql/meta_table.h" 14 #include "sql/meta_table.h"
14 15
15 struct DownloadPersistentStoreInfo; 16 struct DownloadPersistentStoreInfo;
16 class FilePath; 17 class FilePath;
17 18
18 namespace sql { 19 namespace sql {
19 class Connection; 20 class Connection;
20 } 21 }
21 22
22 namespace history { 23 namespace history {
23 24
24 // Maintains a table of downloads. 25 // Maintains a table of downloads.
25 class DownloadDatabase { 26 class DownloadDatabase {
26 public: 27 public:
27 // Must call InitDownloadTable before using any other functions. 28 // Must call InitDownloadTable before using any other functions.
28 DownloadDatabase(); 29 DownloadDatabase();
29 virtual ~DownloadDatabase(); 30 virtual ~DownloadDatabase();
30 31
31 int next_download_id() const { return next_id_; } 32 int next_download_id() const { return next_id_; }
32 33
33 // Get all the downloads from the database. 34 // Get all the downloads from the database.
34 void QueryDownloads(std::vector<DownloadPersistentStoreInfo>* results); 35 void QueryDownloads(std::vector<DownloadPersistentStoreInfo>* results);
35 36
36 // Update the state of one download. Returns true if successful. 37 // Update the state of one download. Returns true if successful.
37 bool UpdateDownload(int64 received_bytes, int32 state, DownloadID db_handle); 38 // Does not update |url|, |start_time|, |total_bytes|, or |db_handle|.
Randy Smith (Not in Mondays) 2011/10/04 18:34:31 The comment that it doesn't update db_handle is a
benjhayden 2011/10/06 21:25:16 Done.
39 bool UpdateDownload(const DownloadPersistentStoreInfo& data);
38 40
39 // Update the path of one download. Returns true if successful. 41 // Update the path of one download. Returns true if successful.
40 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle); 42 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle);
41 43
42 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS 44 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS
43 // state are not updated during browser shutdown (particularly when crashing). 45 // state are not updated during browser shutdown (particularly when crashing).
44 // On the next start such entries are considered canceled. This functions 46 // On the next start such entries are considered canceled. This functions
45 // fixes such entries. 47 // fixes such entries.
46 bool CleanUpInProgressEntries(); 48 bool CleanUpInProgressEntries();
47 49
(...skipping 14 matching lines...) Expand all
62 virtual sql::Connection& GetDB() = 0; 64 virtual sql::Connection& GetDB() = 0;
63 65
64 // Creates the downloads table if needed. 66 // Creates the downloads table if needed.
65 bool InitDownloadTable(); 67 bool InitDownloadTable();
66 68
67 // Used to quickly clear the downloads. First you would drop it, then you 69 // Used to quickly clear the downloads. First you would drop it, then you
68 // would re-initialize it. 70 // would re-initialize it.
69 bool DropDownloadTable(); 71 bool DropDownloadTable();
70 72
71 private: 73 private:
74 bool EnsureColumnExists(const std::string& name, const std::string& type);
75
72 // TODO(rdsmith): Remove after http://crbug.com/96627 has been resolved. 76 // TODO(rdsmith): Remove after http://crbug.com/96627 has been resolved.
73 std::set<int64> returned_ids_; 77 std::set<int64> returned_ids_;
74 bool owning_thread_set_; 78 bool owning_thread_set_;
75 base::PlatformThreadId owning_thread_; 79 base::PlatformThreadId owning_thread_;
76 80
77 int next_id_; 81 int next_id_;
78 sql::MetaTable meta_table_; 82 sql::MetaTable meta_table_;
79 83
80 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); 84 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase);
81 }; 85 };
82 86
83 } // namespace history 87 } // namespace history
84 88
85 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ 89 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698