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

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: fix windows auto_closed_ 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|; uses |db_handle| only
39 // to select the row in the database table to update.
40 bool UpdateDownload(const DownloadPersistentStoreInfo& data);
38 41
39 // Update the path of one download. Returns true if successful. 42 // Update the path of one download. Returns true if successful.
40 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle); 43 bool UpdateDownloadPath(const FilePath& path, DownloadID db_handle);
41 44
42 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS 45 // Fixes state of the download entries. Sometimes entries with IN_PROGRESS
43 // state are not updated during browser shutdown (particularly when crashing). 46 // state are not updated during browser shutdown (particularly when crashing).
44 // On the next start such entries are considered canceled. This functions 47 // On the next start such entries are considered canceled. This functions
45 // fixes such entries. 48 // fixes such entries.
46 bool CleanUpInProgressEntries(); 49 bool CleanUpInProgressEntries();
47 50
(...skipping 14 matching lines...) Expand all
62 virtual sql::Connection& GetDB() = 0; 65 virtual sql::Connection& GetDB() = 0;
63 66
64 // Creates the downloads table if needed. 67 // Creates the downloads table if needed.
65 bool InitDownloadTable(); 68 bool InitDownloadTable();
66 69
67 // Used to quickly clear the downloads. First you would drop it, then you 70 // Used to quickly clear the downloads. First you would drop it, then you
68 // would re-initialize it. 71 // would re-initialize it.
69 bool DropDownloadTable(); 72 bool DropDownloadTable();
70 73
71 private: 74 private:
75 bool EnsureColumnExists(const std::string& name, const std::string& type);
76
72 // TODO(rdsmith): Remove after http://crbug.com/96627 has been resolved. 77 // TODO(rdsmith): Remove after http://crbug.com/96627 has been resolved.
73 std::set<int64> returned_ids_; 78 std::set<int64> returned_ids_;
74 bool owning_thread_set_; 79 bool owning_thread_set_;
75 base::PlatformThreadId owning_thread_; 80 base::PlatformThreadId owning_thread_;
76 81
77 int next_id_; 82 int next_id_;
78 sql::MetaTable meta_table_; 83 sql::MetaTable meta_table_;
79 84
80 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); 85 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase);
81 }; 86 };
82 87
83 } // namespace history 88 } // namespace history
84 89
85 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_ 90 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698