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

Side by Side Diff: components/webdata/common/web_database_service.cc

Issue 2107493002: Offer user to send feedback from profile error dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet more compile errors Created 4 years, 5 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 #include "components/webdata/common/web_database_service.h" 5 #include "components/webdata/common/web_database_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "components/webdata/common/web_data_request_manager.h" 13 #include "components/webdata/common/web_data_request_manager.h"
14 #include "components/webdata/common/web_data_results.h" 14 #include "components/webdata/common/web_data_results.h"
15 #include "components/webdata/common/web_data_service_consumer.h" 15 #include "components/webdata/common/web_data_service_consumer.h"
16 #include "components/webdata/common/web_database_backend.h" 16 #include "components/webdata/common/web_database_backend.h"
17 17
18 using base::Bind; 18 using base::Bind;
19 using base::FilePath; 19 using base::FilePath;
20 20
21 // Receives messages from the backend on the DB thread, posts them to 21 // Receives messages from the backend on the DB thread, posts them to
22 // WebDatabaseService on the UI thread. 22 // WebDatabaseService on the UI thread.
23 class WebDatabaseService::BackendDelegate 23 class WebDatabaseService::BackendDelegate
24 : public WebDatabaseBackend::Delegate { 24 : public WebDatabaseBackend::Delegate {
25 public: 25 public:
26 BackendDelegate(const base::WeakPtr<WebDatabaseService>& web_database_service) 26 BackendDelegate(const base::WeakPtr<WebDatabaseService>& web_database_service)
27 : web_database_service_(web_database_service), 27 : web_database_service_(web_database_service),
28 callback_thread_(base::ThreadTaskRunnerHandle::Get()) {} 28 callback_thread_(base::ThreadTaskRunnerHandle::Get()) {}
29 29
30 void DBLoaded(sql::InitStatus status) override { 30 void DBLoaded(sql::InitStatus status,
31 const sql::DatabaseDiagnosticMap& diagnostics) override {
31 callback_thread_->PostTask( 32 callback_thread_->PostTask(
32 FROM_HERE, 33 FROM_HERE, base::Bind(&WebDatabaseService::OnDatabaseLoadDone,
33 base::Bind(&WebDatabaseService::OnDatabaseLoadDone, 34 web_database_service_, status, diagnostics));
34 web_database_service_,
35 status));
36 } 35 }
37 private: 36 private:
38 const base::WeakPtr<WebDatabaseService> web_database_service_; 37 const base::WeakPtr<WebDatabaseService> web_database_service_;
39 scoped_refptr<base::SingleThreadTaskRunner> callback_thread_; 38 scoped_refptr<base::SingleThreadTaskRunner> callback_thread_;
40 }; 39 };
41 40
42 WebDatabaseService::WebDatabaseService( 41 WebDatabaseService::WebDatabaseService(
43 const base::FilePath& path, 42 const base::FilePath& path,
44 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, 43 scoped_refptr<base::SingleThreadTaskRunner> ui_thread,
45 scoped_refptr<base::SingleThreadTaskRunner> db_thread) 44 scoped_refptr<base::SingleThreadTaskRunner> db_thread)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 void WebDatabaseService::RegisterDBLoadedCallback( 125 void WebDatabaseService::RegisterDBLoadedCallback(
127 const DBLoadedCallback& callback) { 126 const DBLoadedCallback& callback) {
128 loaded_callbacks_.push_back(callback); 127 loaded_callbacks_.push_back(callback);
129 } 128 }
130 129
131 void WebDatabaseService::RegisterDBErrorCallback( 130 void WebDatabaseService::RegisterDBErrorCallback(
132 const DBLoadErrorCallback& callback) { 131 const DBLoadErrorCallback& callback) {
133 error_callbacks_.push_back(callback); 132 error_callbacks_.push_back(callback);
134 } 133 }
135 134
136 void WebDatabaseService::OnDatabaseLoadDone(sql::InitStatus status) { 135 void WebDatabaseService::OnDatabaseLoadDone(
136 sql::InitStatus status,
137 const sql::DatabaseDiagnosticMap& diagnostics) {
137 if (status == sql::INIT_OK) { 138 if (status == sql::INIT_OK) {
138 db_loaded_ = true; 139 db_loaded_ = true;
139 140
140 for (size_t i = 0; i < loaded_callbacks_.size(); i++) { 141 for (size_t i = 0; i < loaded_callbacks_.size(); i++) {
141 if (!loaded_callbacks_[i].is_null()) 142 if (!loaded_callbacks_[i].is_null())
142 loaded_callbacks_[i].Run(); 143 loaded_callbacks_[i].Run();
143 } 144 }
144 145
145 loaded_callbacks_.clear(); 146 loaded_callbacks_.clear();
146 } else { 147 } else {
147 // Notify that the database load failed. 148 // Notify that the database load failed.
148 for (size_t i = 0; i < error_callbacks_.size(); i++) { 149 for (size_t i = 0; i < error_callbacks_.size(); i++) {
149 if (!error_callbacks_[i].is_null()) 150 if (!error_callbacks_[i].is_null())
150 error_callbacks_[i].Run(status); 151 error_callbacks_[i].Run(status, diagnostics);
151 } 152 }
152 153
153 error_callbacks_.clear(); 154 error_callbacks_.clear();
154 } 155 }
michaeln 2016/07/09 03:00:38 off topic: should both set of callbacks be cleared
afakhry 2016/07/11 16:47:45 I'm not sure of the expectations of the clients; i
155 } 156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698