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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // | 43 // |
44 // WebDatabaseService defines the interface to a generic data repository | 44 // WebDatabaseService defines the interface to a generic data repository |
45 // responsible for controlling access to the web database (metadata associated | 45 // responsible for controlling access to the web database (metadata associated |
46 // with web pages). | 46 // with web pages). |
47 // | 47 // |
48 //////////////////////////////////////////////////////////////////////////////// | 48 //////////////////////////////////////////////////////////////////////////////// |
49 | 49 |
50 class WEBDATA_EXPORT WebDatabaseService | 50 class WEBDATA_EXPORT WebDatabaseService |
51 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseService> { | 51 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseService> { |
52 public: | 52 public: |
53 typedef base::Callback<std::unique_ptr<WDTypedResult>(WebDatabase*)> ReadTask; | 53 using ReadTask = base::Callback<std::unique_ptr<WDTypedResult>(WebDatabase*)>; |
54 typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask; | 54 using WriteTask = base::Callback<WebDatabase::State(WebDatabase*)>; |
55 | 55 |
56 // Types for managing DB loading callbacks. | 56 // Types for managing DB loading callbacks. |
57 typedef base::Closure DBLoadedCallback; | 57 using DBLoadedCallback = base::Closure; |
58 typedef base::Callback<void(sql::InitStatus)> DBLoadErrorCallback; | 58 using DBLoadErrorCallback = |
| 59 base::Callback<void(sql::InitStatus, const std::string&)>; |
59 | 60 |
60 // Takes the path to the WebDatabase file. | 61 // Takes the path to the WebDatabase file. |
61 // WebDatabaseService lives on |ui_thread| and posts tasks to |db_thread|. | 62 // WebDatabaseService lives on |ui_thread| and posts tasks to |db_thread|. |
62 WebDatabaseService(const base::FilePath& path, | 63 WebDatabaseService(const base::FilePath& path, |
63 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, | 64 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, |
64 scoped_refptr<base::SingleThreadTaskRunner> db_thread); | 65 scoped_refptr<base::SingleThreadTaskRunner> db_thread); |
65 | 66 |
66 // Adds |table| as a WebDatabaseTable that will participate in | 67 // Adds |table| as a WebDatabaseTable that will participate in |
67 // managing the database, transferring ownership. All calls to this | 68 // managing the database, transferring ownership. All calls to this |
68 // method must be made before |LoadDatabase| is called. | 69 // method must be made before |LoadDatabase| is called. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 class BackendDelegate; | 118 class BackendDelegate; |
118 friend class BackendDelegate; | 119 friend class BackendDelegate; |
119 friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseService>; | 120 friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseService>; |
120 friend class base::DeleteHelper<WebDatabaseService>; | 121 friend class base::DeleteHelper<WebDatabaseService>; |
121 | 122 |
122 typedef std::vector<DBLoadedCallback> LoadedCallbacks; | 123 typedef std::vector<DBLoadedCallback> LoadedCallbacks; |
123 typedef std::vector<DBLoadErrorCallback> ErrorCallbacks; | 124 typedef std::vector<DBLoadErrorCallback> ErrorCallbacks; |
124 | 125 |
125 virtual ~WebDatabaseService(); | 126 virtual ~WebDatabaseService(); |
126 | 127 |
127 void OnDatabaseLoadDone(sql::InitStatus status); | 128 void OnDatabaseLoadDone(sql::InitStatus status, |
| 129 const std::string& diagnostics); |
128 | 130 |
129 base::FilePath path_; | 131 base::FilePath path_; |
130 | 132 |
131 // The primary owner is |WebDatabaseService| but is refcounted because | 133 // The primary owner is |WebDatabaseService| but is refcounted because |
132 // PostTask on DB thread may outlive us. | 134 // PostTask on DB thread may outlive us. |
133 scoped_refptr<WebDatabaseBackend> web_db_backend_; | 135 scoped_refptr<WebDatabaseBackend> web_db_backend_; |
134 | 136 |
135 // Callbacks to be called once the DB has loaded. | 137 // Callbacks to be called once the DB has loaded. |
136 LoadedCallbacks loaded_callbacks_; | 138 LoadedCallbacks loaded_callbacks_; |
137 | 139 |
138 // Callbacks to be called if the DB has failed to load. | 140 // Callbacks to be called if the DB has failed to load. |
139 ErrorCallbacks error_callbacks_; | 141 ErrorCallbacks error_callbacks_; |
140 | 142 |
141 // True if the WebDatabase has loaded. | 143 // True if the WebDatabase has loaded. |
142 bool db_loaded_; | 144 bool db_loaded_; |
143 | 145 |
144 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; | 146 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; |
145 | 147 |
146 // All vended weak pointers are invalidated in ShutdownDatabase(). | 148 // All vended weak pointers are invalidated in ShutdownDatabase(). |
147 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; | 149 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; |
148 | 150 |
149 DISALLOW_COPY_AND_ASSIGN(WebDatabaseService); | 151 DISALLOW_COPY_AND_ASSIGN(WebDatabaseService); |
150 }; | 152 }; |
151 | 153 |
152 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 154 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
OLD | NEW |