| 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 #include "components/webdata/common/web_database_service.h" | 5 #include "components/webdata/common/web_database_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "components/webdata/common/web_data_request_manager.h" | 9 #include "components/webdata/common/web_data_request_manager.h" |
| 10 #include "components/webdata/common/web_data_results.h" | 10 #include "components/webdata/common/web_data_results.h" |
| 11 #include "components/webdata/common/web_data_service_backend.h" | 11 #include "components/webdata/common/web_data_service_backend.h" |
| 12 #include "components/webdata/common/web_data_service_consumer.h" | 12 #include "components/webdata/common/web_data_service_consumer.h" |
| 13 | 13 |
| 14 using base::Bind; | 14 using base::Bind; |
| 15 using base::FilePath; | 15 using base::FilePath; |
| 16 | 16 |
| 17 // Receives messages from the backend on the DB thread, posts them to | 17 // Receives messages from the backend on the DB thread, posts them to |
| 18 // WebDatabaseService on the UI thread. | 18 // WebDatabaseService on the UI thread. |
| 19 class WebDatabaseService::BackendDelegate : | 19 class WebDatabaseService::BackendDelegate : |
| 20 public WebDataServiceBackend::Delegate { | 20 public WebDataServiceBackend::Delegate { |
| 21 public: | 21 public: |
| 22 BackendDelegate( | 22 BackendDelegate( |
| 23 const base::WeakPtr<WebDatabaseService>& web_database_service) | 23 const base::WeakPtr<WebDatabaseService>& web_database_service) |
| 24 : web_database_service_(web_database_service), | 24 : web_database_service_(web_database_service), |
| 25 callback_thread_(base::MessageLoopProxy::current()) { | 25 callback_thread_(base::MessageLoopProxy::current()) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 virtual void DBLoaded(sql::InitStatus status) OVERRIDE { | 28 virtual void DBLoaded(sql::InitStatus status) override { |
| 29 callback_thread_->PostTask( | 29 callback_thread_->PostTask( |
| 30 FROM_HERE, | 30 FROM_HERE, |
| 31 base::Bind(&WebDatabaseService::OnDatabaseLoadDone, | 31 base::Bind(&WebDatabaseService::OnDatabaseLoadDone, |
| 32 web_database_service_, | 32 web_database_service_, |
| 33 status)); | 33 status)); |
| 34 } | 34 } |
| 35 private: | 35 private: |
| 36 const base::WeakPtr<WebDatabaseService> web_database_service_; | 36 const base::WeakPtr<WebDatabaseService> web_database_service_; |
| 37 scoped_refptr<base::MessageLoopProxy> callback_thread_; | 37 scoped_refptr<base::MessageLoopProxy> callback_thread_; |
| 38 }; | 38 }; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } else { | 146 } else { |
| 147 // Notify that the database load failed. | 147 // Notify that the database load failed. |
| 148 for (size_t i = 0; i < error_callbacks_.size(); i++) { | 148 for (size_t i = 0; i < error_callbacks_.size(); i++) { |
| 149 if (!error_callbacks_[i].is_null()) | 149 if (!error_callbacks_[i].is_null()) |
| 150 error_callbacks_[i].Run(status); | 150 error_callbacks_[i].Run(status); |
| 151 } | 151 } |
| 152 | 152 |
| 153 error_callbacks_.clear(); | 153 error_callbacks_.clear(); |
| 154 } | 154 } |
| 155 } | 155 } |
| OLD | NEW |