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

Side by Side Diff: chrome/browser/webdata/web_database.h

Issue 13392014: Move c/b/webdata/ code to components/webdata/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge Created 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATABASE_H_
6 #define CHROME_BROWSER_WEBDATA_WEB_DATABASE_H_
7
8 #include <map>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/webdata/web_database_table.h"
12 #include "sql/connection.h"
13 #include "sql/init_status.h"
14 #include "sql/meta_table.h"
15
16 namespace base {
17 class FilePath;
18 }
19
20 namespace content {
21 class NotificationService;
22 }
23
24 // This class manages a SQLite database that stores various web page meta data.
25 class WebDatabase {
26 public:
27 enum State {
28 COMMIT_NOT_NEEDED,
29 COMMIT_NEEDED
30 };
31 // Exposed publicly so the keyword table can access it.
32 static const int kCurrentVersionNumber;
33
34 WebDatabase();
35 virtual ~WebDatabase();
36
37 // Adds a database table. Ownership remains with the caller, which
38 // must ensure that the lifetime of |table| exceeds this object's
39 // lifetime. Must only be called before Init.
40 void AddTable(WebDatabaseTable* table);
41
42 // Retrieves a table based on its |key|.
43 WebDatabaseTable* GetTable(WebDatabaseTable::TypeKey key);
44
45 // Initialize the database given a name. The name defines where the SQLite
46 // file is. If this returns an error code, no other method should be called.
47 //
48 // Before calling this method, you must call AddTable for any
49 // WebDatabaseTable objects that are supposed to participate in
50 // managing the database.
51 sql::InitStatus Init(const base::FilePath& db_name);
52
53 // Transactions management
54 void BeginTransaction();
55 void CommitTransaction();
56
57 // Exposed for testing only.
58 sql::Connection* GetSQLConnection();
59
60 private:
61 // Used by |Init()| to migration database schema from older versions to
62 // current version.
63 sql::InitStatus MigrateOldVersionsAsNeeded();
64
65 sql::Connection db_;
66 sql::MetaTable meta_table_;
67
68 // Map of all the different tables that have been added to this
69 // object. Non-owning.
70 typedef std::map<WebDatabaseTable::TypeKey, WebDatabaseTable*> TableMap;
71 TableMap tables_;
72
73 scoped_ptr<content::NotificationService> notification_service_;
74
75 DISALLOW_COPY_AND_ASSIGN(WebDatabase);
76 };
77
78 #endif // CHROME_BROWSER_WEBDATA_WEB_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698