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 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ | 5 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ |
6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ | 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 // DB thread. | 32 // DB thread. |
33 | 33 |
34 class WEBDATA_EXPORT WebDatabaseBackend | 34 class WEBDATA_EXPORT WebDatabaseBackend |
35 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseBackend> { | 35 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseBackend> { |
36 public: | 36 public: |
37 class Delegate { | 37 class Delegate { |
38 public: | 38 public: |
39 virtual ~Delegate() {} | 39 virtual ~Delegate() {} |
40 | 40 |
41 // Invoked when the backend has finished loading the db. | 41 // Invoked when the backend has finished loading the db. |
42 virtual void DBLoaded(sql::InitStatus status) = 0; | 42 virtual void DBLoaded(sql::InitStatus status, |
43 const sql::DatabaseDiagnosticMap& diagnostics) = 0; | |
michaeln
2016/07/09 03:00:38
could use a comment about |diagnostics| only being
afakhry
2016/07/11 16:47:45
Done.
| |
43 }; | 44 }; |
44 | 45 |
45 WebDatabaseBackend( | 46 WebDatabaseBackend( |
46 const base::FilePath& path, | 47 const base::FilePath& path, |
47 Delegate* delegate, | 48 Delegate* delegate, |
48 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread); | 49 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread); |
49 | 50 |
50 // Must call only before InitDatabaseWithCallback. | 51 // Must call only before InitDatabaseWithCallback. |
51 void AddTable(std::unique_ptr<WebDatabaseTable> table); | 52 void AddTable(std::unique_ptr<WebDatabaseTable> table); |
52 | 53 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 | 109 |
109 std::unique_ptr<WebDatabase> db_; | 110 std::unique_ptr<WebDatabase> db_; |
110 | 111 |
111 // Keeps track of all pending requests made to the db. | 112 // Keeps track of all pending requests made to the db. |
112 scoped_refptr<WebDataRequestManager> request_manager_; | 113 scoped_refptr<WebDataRequestManager> request_manager_; |
113 | 114 |
114 // State of database initialization. Used to prevent the executing of tasks | 115 // State of database initialization. Used to prevent the executing of tasks |
115 // before the db is ready. | 116 // before the db is ready. |
116 sql::InitStatus init_status_; | 117 sql::InitStatus init_status_; |
117 | 118 |
119 // Contains diagnostic information about the database that will be filled when | |
120 // a catastrophic error occurs. | |
121 sql::DatabaseDiagnosticMap db_diagnostics_; | |
122 | |
118 // True if an attempt has been made to load the database (even if the attempt | 123 // True if an attempt has been made to load the database (even if the attempt |
119 // fails), used to avoid continually trying to reinit if the db init fails. | 124 // fails), used to avoid continually trying to reinit if the db init fails. |
120 bool init_complete_; | 125 bool init_complete_; |
121 | 126 |
122 // Delegate. See the class definition above for more information. | 127 // Delegate. See the class definition above for more information. |
123 std::unique_ptr<Delegate> delegate_; | 128 std::unique_ptr<Delegate> delegate_; |
124 | 129 |
125 DISALLOW_COPY_AND_ASSIGN(WebDatabaseBackend); | 130 DISALLOW_COPY_AND_ASSIGN(WebDatabaseBackend); |
126 }; | 131 }; |
127 | 132 |
128 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ | 133 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ |
OLD | NEW |