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

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

Issue 2107493002: Offer user to send feedback from profile error dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky's Created 4 years, 4 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_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
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 // |status| is the result of initializing the db.
43 // |diagnostics| contains diagnostic information about the db, and it will
44 // only be populated when an error occurs.
45 virtual void DBLoaded(sql::InitStatus status,
46 const std::string& diagnostics) = 0;
43 }; 47 };
44 48
45 WebDatabaseBackend( 49 WebDatabaseBackend(
46 const base::FilePath& path, 50 const base::FilePath& path,
47 Delegate* delegate, 51 Delegate* delegate,
48 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread); 52 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread);
49 53
50 // Must call only before InitDatabaseWithCallback. 54 // Must call only before InitDatabaseWithCallback.
51 void AddTable(std::unique_ptr<WebDatabaseTable> table); 55 void AddTable(std::unique_ptr<WebDatabaseTable> table);
52 56
(...skipping 30 matching lines...) Expand all
83 87
84 WebDatabase* database() { return db_.get(); } 88 WebDatabase* database() { return db_.get(); }
85 89
86 protected: 90 protected:
87 friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseBackend>; 91 friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseBackend>;
88 friend class base::DeleteHelper<WebDatabaseBackend>; 92 friend class base::DeleteHelper<WebDatabaseBackend>;
89 93
90 virtual ~WebDatabaseBackend(); 94 virtual ~WebDatabaseBackend();
91 95
92 private: 96 private:
97 // Invoked on a db error.
98 void DatabaseErrorCallback(int error, sql::Statement* stmt);
Peter Kasting 2016/08/05 00:20:45 Nit: Prefer to spell out "statement" rather than a
afakhry 2016/08/05 16:13:22 Done.
99
93 // Commit the current transaction. 100 // Commit the current transaction.
94 void Commit(); 101 void Commit();
95 102
96 // Path to database file. 103 // Path to database file.
97 base::FilePath db_path_; 104 base::FilePath db_path_;
98 105
99 // The tables that participate in managing the database. These are 106 // The tables that participate in managing the database. These are
100 // owned here but other than that this class does nothing with 107 // owned here but other than that this class does nothing with
101 // them. Their initialization is in whatever factory creates 108 // them. Their initialization is in whatever factory creates
102 // WebDatabaseService, and lookup by type is provided by the 109 // WebDatabaseService, and lookup by type is provided by the
103 // WebDatabase class. The tables need to be owned by this refcounted 110 // WebDatabase class. The tables need to be owned by this refcounted
104 // object, or they themselves would need to be refcounted. Owning 111 // object, or they themselves would need to be refcounted. Owning
105 // them here rather than having WebDatabase own them makes for 112 // them here rather than having WebDatabase own them makes for
106 // easier unit testing of WebDatabase. 113 // easier unit testing of WebDatabase.
107 ScopedVector<WebDatabaseTable> tables_; 114 ScopedVector<WebDatabaseTable> tables_;
108 115
109 std::unique_ptr<WebDatabase> db_; 116 std::unique_ptr<WebDatabase> db_;
110 117
111 // Keeps track of all pending requests made to the db. 118 // Keeps track of all pending requests made to the db.
112 scoped_refptr<WebDataRequestManager> request_manager_; 119 scoped_refptr<WebDataRequestManager> request_manager_;
113 120
114 // State of database initialization. Used to prevent the executing of tasks 121 // State of database initialization. Used to prevent the executing of tasks
115 // before the db is ready. 122 // before the db is ready.
116 sql::InitStatus init_status_; 123 sql::InitStatus init_status_;
117 124
125 // Contains diagnostic information about the database that is non-empty when
126 // a catastrophic error occurs.
Peter Kasting 2016/08/05 00:20:45 Nit: Confusing antecedent; how about "If a catastr
afakhry 2016/08/05 16:13:22 Done.
127 std::string db_diagnostics_;
Peter Kasting 2016/08/05 00:20:45 Nit: Dunno that the "db_" part of this is really n
afakhry 2016/08/05 16:13:22 Done.
128
118 // True if an attempt has been made to load the database (even if the attempt 129 // 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. 130 // fails), used to avoid continually trying to reinit if the db init fails.
120 bool init_complete_; 131 bool init_complete_;
121 132
133 // True if a catastrophic database error occurs and further error callbacks
134 // from the database should be ignored.
Peter Kasting 2016/08/05 00:20:44 Since both this comment and the one above talk abo
afakhry 2016/08/05 16:13:22 Done.
135 bool should_ignore_db_errors_;
136
122 // Delegate. See the class definition above for more information. 137 // Delegate. See the class definition above for more information.
123 std::unique_ptr<Delegate> delegate_; 138 std::unique_ptr<Delegate> delegate_;
124 139
125 DISALLOW_COPY_AND_ASSIGN(WebDatabaseBackend); 140 DISALLOW_COPY_AND_ASSIGN(WebDatabaseBackend);
126 }; 141 };
127 142
128 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ 143 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698