OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_BASE_H_ | 5 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ |
6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ | 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/ref_counted_delete_on_message_loop.h" | 12 #include "base/memory/ref_counted_delete_on_message_loop.h" |
13 #include "components/webdata/common/webdata_export.h" | 13 #include "components/webdata/common/webdata_export.h" |
| 14 #include "sql/db_diagnostic_map.h" |
14 #include "sql/init_status.h" | 15 #include "sql/init_status.h" |
15 | 16 |
16 class WebDatabase; | 17 class WebDatabase; |
17 class WebDatabaseService; | 18 class WebDatabaseService; |
18 class WebDatabaseTable; | 19 class WebDatabaseTable; |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 // TODO(skyostil): Migrate to SingleThreadTaskRunner (crbug.com/465354). | 22 // TODO(skyostil): Migrate to SingleThreadTaskRunner (crbug.com/465354). |
22 class SingleThreadTaskRunner; | 23 class SingleThreadTaskRunner; |
23 class Thread; | 24 class Thread; |
24 } | 25 } |
25 | 26 |
26 // Base for WebDataService class hierarchy. | 27 // Base for WebDataService class hierarchy. |
27 // WebDataServiceBase is destroyed on the UI thread. | 28 // WebDataServiceBase is destroyed on the UI thread. |
28 class WEBDATA_EXPORT WebDataServiceBase | 29 class WEBDATA_EXPORT WebDataServiceBase |
29 : public base::RefCountedDeleteOnMessageLoop<WebDataServiceBase> { | 30 : public base::RefCountedDeleteOnMessageLoop<WebDataServiceBase> { |
30 public: | 31 public: |
31 // All requests return an opaque handle of the following type. | 32 // All requests return an opaque handle of the following type. |
32 typedef int Handle; | 33 typedef int Handle; |
33 | 34 |
34 // Users of this class may provide a callback to handle errors | 35 // Users of this class may provide a callback to handle errors |
35 // (e.g. by showing a UI). The callback is called only on error, and | 36 // (e.g. by showing a UI). The callback is called only on error, and |
36 // takes a single parameter, the sql::InitStatus value from trying | 37 // takes a single parameter, the sql::InitStatus value from trying |
37 // to open the database. | 38 // to open the database. |
38 // TODO(joi): Should we combine this with WebDatabaseService::InitCallback? | 39 // TODO(joi): Should we combine this with WebDatabaseService::InitCallback? |
39 typedef base::Callback<void(sql::InitStatus)> ProfileErrorCallback; | 40 typedef base::Callback<void(sql::InitStatus, |
| 41 const sql::DatabaseDiagnosticMap&)> |
| 42 ProfileErrorCallback; |
40 | 43 |
41 typedef base::Closure DBLoadedCallback; | 44 typedef base::Closure DBLoadedCallback; |
42 | 45 |
43 // |callback| will only be invoked on error, and only if | 46 // |callback| will only be invoked on error, and only if |
44 // |callback.is_null()| evaluates to false. | 47 // |callback.is_null()| evaluates to false. |
45 // | 48 // |
46 // The ownership of |wdbs| is shared, with the primary owner being the | 49 // The ownership of |wdbs| is shared, with the primary owner being the |
47 // WebDataServiceWrapper, and secondary owners being subclasses of | 50 // WebDataServiceWrapper, and secondary owners being subclasses of |
48 // WebDataServiceBase, which receive |wdbs| upon construction. The | 51 // WebDataServiceBase, which receive |wdbs| upon construction. The |
49 // WebDataServiceWrapper handles the initializing and shutting down and of | 52 // WebDataServiceWrapper handles the initializing and shutting down and of |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // Our database service. | 96 // Our database service. |
94 scoped_refptr<WebDatabaseService> wdbs_; | 97 scoped_refptr<WebDatabaseService> wdbs_; |
95 | 98 |
96 private: | 99 private: |
97 ProfileErrorCallback profile_error_callback_; | 100 ProfileErrorCallback profile_error_callback_; |
98 | 101 |
99 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBase); | 102 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBase); |
100 }; | 103 }; |
101 | 104 |
102 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ | 105 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ |
OLD | NEW |