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

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

Issue 16174013: Remove dependency of WebData on content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 7 years, 6 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
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/ref_counted_delete_on_message_loop.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
15 #include "components/webdata/common/web_database_service.h" 16 #include "components/webdata/common/web_database_service.h"
16 #include "components/webdata/common/webdata_export.h" 17 #include "components/webdata/common/webdata_export.h"
17 #include "content/public/browser/browser_thread.h"
18
19 18
20 class WebDatabase; 19 class WebDatabase;
21 class WebDatabaseTable; 20 class WebDatabaseTable;
22 class WebDataRequest; 21 class WebDataRequest;
23 class WebDataRequestManager; 22 class WebDataRequestManager;
24 23
25 namespace tracked_objects { 24 namespace tracked_objects {
26 class Location; 25 class Location;
27 } 26 }
28 27
29 // WebDataServiceBackend handles all database tasks posted by 28 // WebDataServiceBackend handles all database tasks posted by
30 // WebDatabaseService. It is refcounted to allow asynchronous destruction on the 29 // WebDatabaseService. It is refcounted to allow asynchronous destruction on the
31 // DB thread. 30 // DB thread.
32 31
33 // TODO(caitkp): Rename this class to WebDatabaseBackend. 32 // TODO(caitkp): Rename this class to WebDatabaseBackend.
34 33
35 class WEBDATA_EXPORT WebDataServiceBackend 34 class WEBDATA_EXPORT WebDataServiceBackend
36 : public base::RefCountedThreadSafe< 35 : public base::RefCountedDeleteOnMessageLoop<WebDataServiceBackend> {
37 WebDataServiceBackend,
38 content::BrowserThread::DeleteOnDBThread> {
39 public: 36 public:
40 class Delegate { 37 class Delegate {
41 public: 38 public:
42 virtual ~Delegate() {} 39 virtual ~Delegate() {}
43 40
44 // Invoked when the backend has finished loading the db. 41 // Invoked when the backend has finished loading the db.
45 virtual void DBLoaded(sql::InitStatus status) = 0; 42 virtual void DBLoaded(sql::InitStatus status) = 0;
46 }; 43 };
47 44
48 explicit WebDataServiceBackend(const base::FilePath& path, 45 WebDataServiceBackend(const base::FilePath& path,
49 Delegate* delegate); 46 Delegate* delegate,
47 const scoped_refptr<base::MessageLoopProxy>& db_thread);
50 48
51 // Must call only before InitDatabaseWithCallback. 49 // Must call only before InitDatabaseWithCallback.
52 void AddTable(scoped_ptr<WebDatabaseTable> table); 50 void AddTable(scoped_ptr<WebDatabaseTable> table);
53 51
54 // Initializes the database and notifies caller via callback when complete. 52 // Initializes the database and notifies caller via callback when complete.
55 // Callback is called synchronously. 53 // Callback is called synchronously.
56 void InitDatabase(); 54 void InitDatabase();
57 55
58 // Opens the database file from the profile path if an init has not yet been 56 // Opens the database file from the profile path if an init has not yet been
59 // attempted. Separated from the constructor to ease construction/destruction 57 // attempted. Separated from the constructor to ease construction/destruction
(...skipping 21 matching lines...) Expand all
81 scoped_ptr<WDTypedResult> ExecuteReadTask( 79 scoped_ptr<WDTypedResult> ExecuteReadTask(
82 const WebDatabaseService::ReadTask& task); 80 const WebDatabaseService::ReadTask& task);
83 81
84 const scoped_refptr<WebDataRequestManager>& request_manager() { 82 const scoped_refptr<WebDataRequestManager>& request_manager() {
85 return request_manager_; 83 return request_manager_;
86 } 84 }
87 85
88 WebDatabase* database() { return db_.get(); } 86 WebDatabase* database() { return db_.get(); }
89 87
90 protected: 88 protected:
89 friend class base::RefCountedDeleteOnMessageLoop<WebDataServiceBackend>;
90 friend class base::DeleteHelper<WebDataServiceBackend>;
91
91 virtual ~WebDataServiceBackend(); 92 virtual ~WebDataServiceBackend();
92 93
93 private: 94 private:
94 friend struct content::BrowserThread::DeleteOnThread<
95 content::BrowserThread::DB>;
96 friend class base::DeleteHelper<WebDataServiceBackend>;
97 // We have to friend RCTS<> so WIN shared-lib build is happy
98 // (http://crbug/112250).
99 friend class base::RefCountedThreadSafe<WebDataServiceBackend,
100 content::BrowserThread::DeleteOnDBThread>;
101
102 // Commit the current transaction. 95 // Commit the current transaction.
103 void Commit(); 96 void Commit();
104 97
105 // Path to database file. 98 // Path to database file.
106 base::FilePath db_path_; 99 base::FilePath db_path_;
107 100
108 // The tables that participate in managing the database. These are 101 // The tables that participate in managing the database. These are
109 // owned here but other than that this class does nothing with 102 // owned here but other than that this class does nothing with
110 // them. Their initialization is in whatever factory creates 103 // them. Their initialization is in whatever factory creates
111 // WebDatabaseService, and lookup by type is provided by the 104 // WebDatabaseService, and lookup by type is provided by the
(...skipping 16 matching lines...) Expand all
128 // fails), used to avoid continually trying to reinit if the db init fails. 121 // fails), used to avoid continually trying to reinit if the db init fails.
129 bool init_complete_; 122 bool init_complete_;
130 123
131 // Delegate. See the class definition above for more information. 124 // Delegate. See the class definition above for more information.
132 scoped_ptr<Delegate> delegate_; 125 scoped_ptr<Delegate> delegate_;
133 126
134 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBackend); 127 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBackend);
135 }; 128 };
136 129
137 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_ 130 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BACKEND_H_
OLDNEW
« no previous file with comments | « components/webdata/common/web_data_request_manager.h ('k') | components/webdata/common/web_data_service_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698