OLD | NEW |
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_IN_MEMORY_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_IN_MEMORY_DATABASE_H_ |
6 #define CHROME_BROWSER_HISTORY_IN_MEMORY_DATABASE_H_ | 6 #define CHROME_BROWSER_HISTORY_IN_MEMORY_DATABASE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "chrome/browser/history/url_database.h" | 9 #include "chrome/browser/history/url_database.h" |
10 #include "sql/connection.h" | 10 #include "sql/connection.h" |
11 | 11 |
| 12 namespace base { |
12 class FilePath; | 13 class FilePath; |
| 14 } |
13 | 15 |
14 namespace history { | 16 namespace history { |
15 | 17 |
16 // Class used for a fast in-memory cache of typed URLs. Used for inline | 18 // Class used for a fast in-memory cache of typed URLs. Used for inline |
17 // autocomplete since it is fast enough to be called synchronously as the user | 19 // autocomplete since it is fast enough to be called synchronously as the user |
18 // is typing. | 20 // is typing. |
19 class InMemoryDatabase : public URLDatabase { | 21 class InMemoryDatabase : public URLDatabase { |
20 public: | 22 public: |
21 InMemoryDatabase(); | 23 InMemoryDatabase(); |
22 virtual ~InMemoryDatabase(); | 24 virtual ~InMemoryDatabase(); |
23 | 25 |
24 // Creates an empty in-memory database. | 26 // Creates an empty in-memory database. |
25 bool InitFromScratch(); | 27 bool InitFromScratch(); |
26 | 28 |
27 // Initializes the database by directly slurping the data from the given | 29 // Initializes the database by directly slurping the data from the given |
28 // file. Conceptually, the InMemoryHistoryBackend should do the populating | 30 // file. Conceptually, the InMemoryHistoryBackend should do the populating |
29 // after this object does some common initialization, but that would be | 31 // after this object does some common initialization, but that would be |
30 // much slower. | 32 // much slower. |
31 bool InitFromDisk(const FilePath& history_name); | 33 bool InitFromDisk(const base::FilePath& history_name); |
32 | 34 |
33 protected: | 35 protected: |
34 // Implemented for URLDatabase. | 36 // Implemented for URLDatabase. |
35 virtual sql::Connection& GetDB() OVERRIDE; | 37 virtual sql::Connection& GetDB() OVERRIDE; |
36 | 38 |
37 private: | 39 private: |
38 // Initializes the database connection, this is the shared code between | 40 // Initializes the database connection, this is the shared code between |
39 // InitFromScratch() and InitFromDisk() above. Returns true on success. | 41 // InitFromScratch() and InitFromDisk() above. Returns true on success. |
40 bool InitDB(); | 42 bool InitDB(); |
41 | 43 |
42 sql::Connection db_; | 44 sql::Connection db_; |
43 | 45 |
44 DISALLOW_COPY_AND_ASSIGN(InMemoryDatabase); | 46 DISALLOW_COPY_AND_ASSIGN(InMemoryDatabase); |
45 }; | 47 }; |
46 | 48 |
47 } // namespace history | 49 } // namespace history |
48 | 50 |
49 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_DATABASE_H_ | 51 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_DATABASE_H_ |
OLD | NEW |