| OLD | NEW |
| 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 Loading... |
| 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(); |
| 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_ |
| OLD | NEW |