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

Side by Side Diff: components/webdata/common/web_data_service_backend.h

Issue 14679005: Create an AutofillBackend interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix WIN Created 7 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ 5 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_
6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback_forward.h" 9 #include "base/callback_forward.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "components/webdata/common/web_database_service.h" 15 #include "components/webdata/common/web_database_service.h"
16 #include "components/webdata/common/webdata_export.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 18
18 19
19 class WebDatabase; 20 class WebDatabase;
20 class WebDatabaseTable; 21 class WebDatabaseTable;
21 class WebDataRequest; 22 class WebDataRequest;
22 class WebDataRequestManager; 23 class WebDataRequestManager;
23 24
24 namespace tracked_objects { 25 namespace tracked_objects {
25 class Location; 26 class Location;
26 } 27 }
27 28
28 // WebDataServiceBackend handles all database tasks posted by 29 // WebDataServiceBackend handles all database tasks posted by
29 // WebDatabaseService. It is refcounted to allow asynchronous destruction on the 30 // WebDatabaseService. It is refcounted to allow asynchronous destruction on the
30 // DB thread. 31 // DB thread.
31 32
32 class WebDataServiceBackend 33 // TODO(caitkp): Rename this class to WebDatabaseBackend.
34
35 class WEBDATA_EXPORT WebDataServiceBackend
33 : public base::RefCountedThreadSafe< 36 : public base::RefCountedThreadSafe<
34 WebDataServiceBackend, 37 WebDataServiceBackend,
35 content::BrowserThread::DeleteOnDBThread> { 38 content::BrowserThread::DeleteOnDBThread> {
36 public: 39 public:
37 class Delegate { 40 class Delegate {
38 public: 41 public:
39 virtual ~Delegate() {} 42 virtual ~Delegate() {}
40 43
41 // Invoked when the backend has finished loading the db. 44 // Invoked when the backend has finished loading the db.
42 virtual void DBLoaded(sql::InitStatus status) = 0; 45 virtual void DBLoaded(sql::InitStatus status) = 0;
(...skipping 12 matching lines...) Expand all
55 // Opens the database file from the profile path if an init has not yet been 58 // Opens the database file from the profile path if an init has not yet been
56 // attempted. Separated from the constructor to ease construction/destruction 59 // attempted. Separated from the constructor to ease construction/destruction
57 // of this object on one thread but database access on the DB thread. Returns 60 // of this object on one thread but database access on the DB thread. Returns
58 // the status of the database. 61 // the status of the database.
59 sql::InitStatus LoadDatabaseIfNecessary(); 62 sql::InitStatus LoadDatabaseIfNecessary();
60 63
61 // Shuts down database. |should_reinit| tells us whether or not it should be 64 // Shuts down database. |should_reinit| tells us whether or not it should be
62 // possible to re-initialize the DB after the shutdown. 65 // possible to re-initialize the DB after the shutdown.
63 void ShutdownDatabase(bool should_reinit); 66 void ShutdownDatabase(bool should_reinit);
64 67
65 // Task wrappers to run database tasks. 68 // Task wrappers to update requests and and notify |request_manager_|. These
69 // are used in cases where the request is being made from the UI thread and an
70 // asyncronous callback is required to notify the client of |request|'s
71 // completion.
66 void DBWriteTaskWrapper( 72 void DBWriteTaskWrapper(
67 const WebDatabaseService::WriteTask& task, 73 const WebDatabaseService::WriteTask& task,
68 scoped_ptr<WebDataRequest> request); 74 scoped_ptr<WebDataRequest> request);
69 void DBReadTaskWrapper( 75 void DBReadTaskWrapper(
70 const WebDatabaseService::ReadTask& task, 76 const WebDatabaseService::ReadTask& task,
71 scoped_ptr<WebDataRequest> request); 77 scoped_ptr<WebDataRequest> request);
72 78
79 // Task runners to run database tasks.
80 void ExecuteWriteTask(const WebDatabaseService::WriteTask& task);
81 scoped_ptr<WDTypedResult> ExecuteReadTask(
82 const WebDatabaseService::ReadTask& task);
83
73 const scoped_refptr<WebDataRequestManager>& request_manager() { 84 const scoped_refptr<WebDataRequestManager>& request_manager() {
74 return request_manager_; 85 return request_manager_;
75 } 86 }
76 87
77 WebDatabase* database() { return db_.get(); } 88 WebDatabase* database() { return db_.get(); }
78 89
90 protected:
91 virtual ~WebDataServiceBackend();
92
79 private: 93 private:
80 friend struct content::BrowserThread::DeleteOnThread< 94 friend struct content::BrowserThread::DeleteOnThread<
81 content::BrowserThread::DB>; 95 content::BrowserThread::DB>;
82 friend class base::DeleteHelper<WebDataServiceBackend>; 96 friend class base::DeleteHelper<WebDataServiceBackend>;
83 97 // We have to friend RCTS<> so WIN shared-lib build is happy
84 virtual ~WebDataServiceBackend(); 98 // (http://crbug/112250).
99 friend class base::RefCountedThreadSafe<WebDataServiceBackend,
100 content::BrowserThread::DeleteOnDBThread>;
85 101
86 // Commit the current transaction. 102 // Commit the current transaction.
87 void Commit(); 103 void Commit();
88 104
89 // Path to database file. 105 // Path to database file.
90 base::FilePath db_path_; 106 base::FilePath db_path_;
91 107
92 // The tables that participate in managing the database. These are 108 // The tables that participate in managing the database. These are
93 // owned here but other than that this class does nothing with 109 // owned here but other than that this class does nothing with
94 // them. Their initialization is in whatever factory creates 110 // them. Their initialization is in whatever factory creates
(...skipping 17 matching lines...) Expand all
112 // fails), used to avoid continually trying to reinit if the db init fails. 128 // fails), used to avoid continually trying to reinit if the db init fails.
113 bool init_complete_; 129 bool init_complete_;
114 130
115 // Delegate. See the class definition above for more information. 131 // Delegate. See the class definition above for more information.
116 scoped_ptr<Delegate> delegate_; 132 scoped_ptr<Delegate> delegate_;
117 133
118 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBackend); 134 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBackend);
119 }; 135 };
120 136
121 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ 137 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_
OLDNEW
« no previous file with comments | « components/autofill/browser/webdata/autofill_webdata_service.cc ('k') | components/webdata/common/web_data_service_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698