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

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

Issue 10071032: RefCounted types should not have public destructors, chrome/browser/ part 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_SHORTCUTS_DATABASE_H_ 5 #ifndef CHROME_BROWSER_HISTORY_SHORTCUTS_DATABASE_H_
6 #define CHROME_BROWSER_HISTORY_SHORTCUTS_DATABASE_H_ 6 #define CHROME_BROWSER_HISTORY_SHORTCUTS_DATABASE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 25 matching lines...) Expand all
36 // description_matches Comma separated matches of the |search_text| in 36 // description_matches Comma separated matches of the |search_text| in
37 // |description|. 37 // |description|.
38 // last_access_time Time the entry was accessed last, stored in seconds, 38 // last_access_time Time the entry was accessed last, stored in seconds,
39 // UTC. 39 // UTC.
40 // number_of_hits Number of times that the entry has been selected. 40 // number_of_hits Number of times that the entry has been selected.
41 class ShortcutsDatabase : public base::RefCountedThreadSafe<ShortcutsDatabase> { 41 class ShortcutsDatabase : public base::RefCountedThreadSafe<ShortcutsDatabase> {
42 public: 42 public:
43 typedef std::map<std::string, ShortcutsBackend::Shortcut> GuidToShortcutMap; 43 typedef std::map<std::string, ShortcutsBackend::Shortcut> GuidToShortcutMap;
44 44
45 explicit ShortcutsDatabase(const FilePath& folder_path); 45 explicit ShortcutsDatabase(const FilePath& folder_path);
46 virtual ~ShortcutsDatabase();
47 46
48 bool Init(); 47 bool Init();
49 48
50 // Adds the ShortcutsProvider::Shortcut to the database. 49 // Adds the ShortcutsProvider::Shortcut to the database.
51 bool AddShortcut(const ShortcutsBackend::Shortcut& shortcut); 50 bool AddShortcut(const ShortcutsBackend::Shortcut& shortcut);
52 51
53 // Updates timing and selection count for the ShortcutsProvider::Shortcut. 52 // Updates timing and selection count for the ShortcutsProvider::Shortcut.
54 bool UpdateShortcut(const ShortcutsBackend::Shortcut& shortcut); 53 bool UpdateShortcut(const ShortcutsBackend::Shortcut& shortcut);
55 54
56 // Deletes the ShortcutsProvider::Shortcuts with the id. 55 // Deletes the ShortcutsProvider::Shortcuts with the id.
57 bool DeleteShortcutsWithIds(const std::vector<std::string>& shortcut_ids); 56 bool DeleteShortcutsWithIds(const std::vector<std::string>& shortcut_ids);
58 57
59 // Deletes the ShortcutsProvider::Shortcuts with the url. 58 // Deletes the ShortcutsProvider::Shortcuts with the url.
60 bool DeleteShortcutsWithUrl(const std::string& shortcut_url_spec); 59 bool DeleteShortcutsWithUrl(const std::string& shortcut_url_spec);
61 60
62 // Deletes all of the ShortcutsProvider::Shortcuts. 61 // Deletes all of the ShortcutsProvider::Shortcuts.
63 bool DeleteAllShortcuts(); 62 bool DeleteAllShortcuts();
64 63
65 // Loads all of the shortcuts. 64 // Loads all of the shortcuts.
66 bool LoadShortcuts(GuidToShortcutMap* shortcuts); 65 bool LoadShortcuts(GuidToShortcutMap* shortcuts);
67 66
68 private: 67 private:
68 friend class base::RefCountedThreadSafe<ShortcutsDatabase>;
69
70 virtual ~ShortcutsDatabase();
sky 2012/04/13 15:50:52 Move implementation to match.
71
69 // Ensures that the table is present. 72 // Ensures that the table is present.
70 bool EnsureTable(); 73 bool EnsureTable();
71 74
72 friend class ShortcutsDatabaseTest; 75 friend class ShortcutsDatabaseTest;
73 FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, AddShortcut); 76 FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, AddShortcut);
74 FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, UpdateShortcut); 77 FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, UpdateShortcut);
75 FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, DeleteShortcutsWithIds); 78 FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, DeleteShortcutsWithIds);
76 FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, DeleteShortcutsWithUrl); 79 FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, DeleteShortcutsWithUrl);
77 FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, LoadShortcuts); 80 FRIEND_TEST_ALL_PREFIXES(ShortcutsDatabaseTest, LoadShortcuts);
78 81
79 // The sql database. Not valid until Init is called. 82 // The sql database. Not valid until Init is called.
80 sql::Connection db_; 83 sql::Connection db_;
81 FilePath database_path_; 84 FilePath database_path_;
82 85
83 static const FilePath::CharType kShortcutsDatabaseName[]; 86 static const FilePath::CharType kShortcutsDatabaseName[];
84 87
85 DISALLOW_COPY_AND_ASSIGN(ShortcutsDatabase); 88 DISALLOW_COPY_AND_ASSIGN(ShortcutsDatabase);
86 }; 89 };
87 90
88 } // namespace history 91 } // namespace history
89 92
90 #endif // CHROME_BROWSER_HISTORY_SHORTCUTS_DATABASE_H_ 93 #endif // CHROME_BROWSER_HISTORY_SHORTCUTS_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698