| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/location.h" | 11 #include "base/location.h" |
| 11 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 12 #include "components/webdata/common/web_data_request_manager.h" | 13 #include "components/webdata/common/web_data_request_manager.h" |
| 13 #include "components/webdata/common/web_data_results.h" | 14 #include "components/webdata/common/web_data_results.h" |
| 14 #include "components/webdata/common/web_data_service_consumer.h" | 15 #include "components/webdata/common/web_data_service_consumer.h" |
| 15 #include "components/webdata/common/web_database_backend.h" | 16 #include "components/webdata/common/web_database_backend.h" |
| 16 | 17 |
| 17 using base::Bind; | 18 using base::Bind; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 55 } |
| 55 | 56 |
| 56 WebDatabaseService::~WebDatabaseService() { | 57 WebDatabaseService::~WebDatabaseService() { |
| 57 } | 58 } |
| 58 | 59 |
| 59 void WebDatabaseService::AddTable(scoped_ptr<WebDatabaseTable> table) { | 60 void WebDatabaseService::AddTable(scoped_ptr<WebDatabaseTable> table) { |
| 60 if (!web_db_backend_.get()) { | 61 if (!web_db_backend_.get()) { |
| 61 web_db_backend_ = new WebDatabaseBackend( | 62 web_db_backend_ = new WebDatabaseBackend( |
| 62 path_, new BackendDelegate(weak_ptr_factory_.GetWeakPtr()), db_thread_); | 63 path_, new BackendDelegate(weak_ptr_factory_.GetWeakPtr()), db_thread_); |
| 63 } | 64 } |
| 64 web_db_backend_->AddTable(table.Pass()); | 65 web_db_backend_->AddTable(std::move(table)); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void WebDatabaseService::LoadDatabase() { | 68 void WebDatabaseService::LoadDatabase() { |
| 68 DCHECK(web_db_backend_.get()); | 69 DCHECK(web_db_backend_.get()); |
| 69 db_thread_->PostTask( | 70 db_thread_->PostTask( |
| 70 FROM_HERE, Bind(&WebDatabaseBackend::InitDatabase, web_db_backend_)); | 71 FROM_HERE, Bind(&WebDatabaseBackend::InitDatabase, web_db_backend_)); |
| 71 } | 72 } |
| 72 | 73 |
| 73 void WebDatabaseService::ShutdownDatabase() { | 74 void WebDatabaseService::ShutdownDatabase() { |
| 74 db_loaded_ = false; | 75 db_loaded_ = false; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } else { | 146 } else { |
| 146 // Notify that the database load failed. | 147 // Notify that the database load failed. |
| 147 for (size_t i = 0; i < error_callbacks_.size(); i++) { | 148 for (size_t i = 0; i < error_callbacks_.size(); i++) { |
| 148 if (!error_callbacks_[i].is_null()) | 149 if (!error_callbacks_[i].is_null()) |
| 149 error_callbacks_[i].Run(status); | 150 error_callbacks_[i].Run(status); |
| 150 } | 151 } |
| 151 | 152 |
| 152 error_callbacks_.clear(); | 153 error_callbacks_.clear(); |
| 153 } | 154 } |
| 154 } | 155 } |
| OLD | NEW |