OLD | NEW |
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 // Chromium settings and storage represent user-selected preferences and | 5 // Chromium settings and storage represent user-selected preferences and |
6 // information and MUST not be extracted, overwritten or modified except | 6 // information and MUST not be extracted, overwritten or modified except |
7 // through Chromium defined APIs. | 7 // through Chromium defined APIs. |
8 | 8 |
9 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 9 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
10 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 10 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // | 46 // |
47 //////////////////////////////////////////////////////////////////////////////// | 47 //////////////////////////////////////////////////////////////////////////////// |
48 | 48 |
49 class WEBDATA_EXPORT WebDatabaseService | 49 class WEBDATA_EXPORT WebDatabaseService |
50 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseService> { | 50 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseService> { |
51 public: | 51 public: |
52 typedef base::Callback<scoped_ptr<WDTypedResult>(WebDatabase*)> ReadTask; | 52 typedef base::Callback<scoped_ptr<WDTypedResult>(WebDatabase*)> ReadTask; |
53 typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask; | 53 typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask; |
54 | 54 |
55 // Takes the path to the WebDatabase file. | 55 // Takes the path to the WebDatabase file. |
| 56 // WebDatabaseService lives on |ui_thread| and posts tasks to |db_thread|. |
56 WebDatabaseService(const base::FilePath& path, | 57 WebDatabaseService(const base::FilePath& path, |
57 const scoped_refptr<base::MessageLoopProxy>& ui_thread); | 58 const scoped_refptr<base::MessageLoopProxy>& ui_thread, |
| 59 const scoped_refptr<base::MessageLoopProxy>& db_thread); |
58 | 60 |
59 // Adds |table| as a WebDatabaseTable that will participate in | 61 // Adds |table| as a WebDatabaseTable that will participate in |
60 // managing the database, transferring ownership. All calls to this | 62 // managing the database, transferring ownership. All calls to this |
61 // method must be made before |LoadDatabase| is called. | 63 // method must be made before |LoadDatabase| is called. |
62 virtual void AddTable(scoped_ptr<WebDatabaseTable> table); | 64 virtual void AddTable(scoped_ptr<WebDatabaseTable> table); |
63 | 65 |
64 // Initializes the web database service. | 66 // Initializes the web database service. |
65 virtual void LoadDatabase(); | 67 virtual void LoadDatabase(); |
66 | 68 |
67 // Unloads the database without actually shutting down the service. This can | 69 // Unloads the database without actually shutting down the service. This can |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 typedef std::vector<DBLoadErrorCallback> ErrorCallbacks; | 140 typedef std::vector<DBLoadErrorCallback> ErrorCallbacks; |
139 | 141 |
140 // Callbacks to be called once the DB has loaded. | 142 // Callbacks to be called once the DB has loaded. |
141 LoadedCallbacks loaded_callbacks_; | 143 LoadedCallbacks loaded_callbacks_; |
142 | 144 |
143 // Callbacks to be called if the DB has failed to load. | 145 // Callbacks to be called if the DB has failed to load. |
144 ErrorCallbacks error_callbacks_; | 146 ErrorCallbacks error_callbacks_; |
145 | 147 |
146 // True if the WebDatabase has loaded. | 148 // True if the WebDatabase has loaded. |
147 bool db_loaded_; | 149 bool db_loaded_; |
| 150 |
| 151 scoped_refptr<base::MessageLoopProxy> db_thread_; |
148 }; | 152 }; |
149 | 153 |
150 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 154 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
OLD | NEW |