| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/string16.h" | 16 #include "base/string16.h" |
| 17 #include "chrome/browser/history/shortcuts_backend.h" | 17 #include "chrome/browser/history/shortcuts_backend.h" |
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 #include "sql/connection.h" | 19 #include "sql/connection.h" |
| 20 | 20 |
| 21 class Profile; |
| 22 |
| 21 namespace history { | 23 namespace history { |
| 22 | 24 |
| 23 // This class manages the shortcut provider table within the SQLite database | 25 // This class manages the shortcut provider table within the SQLite database |
| 24 // passed to the constructor. It expects the following schema: | 26 // passed to the constructor. It expects the following schema: |
| 25 // | 27 // |
| 26 // Note: The database stores time in seconds, UTC. | 28 // Note: The database stores time in seconds, UTC. |
| 27 // | 29 // |
| 28 // omni_box_shortcuts | 30 // omni_box_shortcuts |
| 29 // id Unique id of the entry (needed for the sync). | 31 // id Unique id of the entry (needed for the sync). |
| 30 // search_text Text that shortcuts was searched with. | 32 // search_text Text that shortcuts was searched with. |
| 31 // url The url of the shortcut. | 33 // url The url of the shortcut. |
| 32 // contents Contents of the original omni-box entry. | 34 // contents Contents of the original omni-box entry. |
| 33 // contents_matches Comma separated matches of the |search_text| in | 35 // contents_matches Comma separated matches of the |search_text| in |
| 34 // |contents|, for example "0,0,5,3,9,0". | 36 // |contents|, for example "0,0,5,3,9,0". |
| 35 // description Description of the original omni-box entry. | 37 // description Description of the original omni-box entry. |
| 36 // description_matches Comma separated matches of the |search_text| in | 38 // description_matches Comma separated matches of the |search_text| in |
| 37 // |description|. | 39 // |description|. |
| 38 // last_access_time Time the entry was accessed last, stored in seconds, | 40 // last_access_time Time the entry was accessed last, stored in seconds, |
| 39 // UTC. | 41 // UTC. |
| 40 // number_of_hits Number of times that the entry has been selected. | 42 // number_of_hits Number of times that the entry has been selected. |
| 41 class ShortcutsDatabase : public base::RefCountedThreadSafe<ShortcutsDatabase> { | 43 class ShortcutsDatabase : public base::RefCountedThreadSafe<ShortcutsDatabase> { |
| 42 public: | 44 public: |
| 43 typedef std::map<std::string, ShortcutsBackend::Shortcut> GuidToShortcutMap; | 45 typedef std::map<std::string, ShortcutsBackend::Shortcut> GuidToShortcutMap; |
| 44 | 46 |
| 45 explicit ShortcutsDatabase(const FilePath& folder_path); | 47 explicit ShortcutsDatabase(Profile* profile); |
| 46 | 48 |
| 47 bool Init(); | 49 bool Init(); |
| 48 | 50 |
| 49 // Adds the ShortcutsProvider::Shortcut to the database. | 51 // Adds the ShortcutsProvider::Shortcut to the database. |
| 50 bool AddShortcut(const ShortcutsBackend::Shortcut& shortcut); | 52 bool AddShortcut(const ShortcutsBackend::Shortcut& shortcut); |
| 51 | 53 |
| 52 // Updates timing and selection count for the ShortcutsProvider::Shortcut. | 54 // Updates timing and selection count for the ShortcutsProvider::Shortcut. |
| 53 bool UpdateShortcut(const ShortcutsBackend::Shortcut& shortcut); | 55 bool UpdateShortcut(const ShortcutsBackend::Shortcut& shortcut); |
| 54 | 56 |
| 55 // Deletes the ShortcutsProvider::Shortcuts with the id. | 57 // Deletes the ShortcutsProvider::Shortcuts with the id. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 84 FilePath database_path_; | 86 FilePath database_path_; |
| 85 | 87 |
| 86 static const FilePath::CharType kShortcutsDatabaseName[]; | 88 static const FilePath::CharType kShortcutsDatabaseName[]; |
| 87 | 89 |
| 88 DISALLOW_COPY_AND_ASSIGN(ShortcutsDatabase); | 90 DISALLOW_COPY_AND_ASSIGN(ShortcutsDatabase); |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 } // namespace history | 93 } // namespace history |
| 92 | 94 |
| 93 #endif // CHROME_BROWSER_HISTORY_SHORTCUTS_DATABASE_H_ | 95 #endif // CHROME_BROWSER_HISTORY_SHORTCUTS_DATABASE_H_ |
| OLD | NEW |