| 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_backend.h" | 5 #include "components/webdata/common/web_database_backend.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 init_status_ = sql::INIT_FAILURE; | 49 init_status_ = sql::INIT_FAILURE; |
| 50 } | 50 } |
| 51 | 51 |
| 52 void WebDatabaseBackend::DBWriteTaskWrapper( | 52 void WebDatabaseBackend::DBWriteTaskWrapper( |
| 53 const WebDatabaseService::WriteTask& task, | 53 const WebDatabaseService::WriteTask& task, |
| 54 std::unique_ptr<WebDataRequest> request) { | 54 std::unique_ptr<WebDataRequest> request) { |
| 55 if (request->IsCancelled()) | 55 if (request->IsCancelled()) |
| 56 return; | 56 return; |
| 57 | 57 |
| 58 ExecuteWriteTask(task); | 58 ExecuteWriteTask(task); |
| 59 request_manager_->RequestCompleted(std::move(request)); | 59 request_manager_->RequestCompleted(std::move(request), nullptr); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void WebDatabaseBackend::ExecuteWriteTask( | 62 void WebDatabaseBackend::ExecuteWriteTask( |
| 63 const WebDatabaseService::WriteTask& task) { | 63 const WebDatabaseService::WriteTask& task) { |
| 64 LoadDatabaseIfNecessary(); | 64 LoadDatabaseIfNecessary(); |
| 65 if (db_ && init_status_ == sql::INIT_OK) { | 65 if (db_ && init_status_ == sql::INIT_OK) { |
| 66 WebDatabase::State state = task.Run(db_.get()); | 66 WebDatabase::State state = task.Run(db_.get()); |
| 67 if (state == WebDatabase::COMMIT_NEEDED) | 67 if (state == WebDatabase::COMMIT_NEEDED) |
| 68 Commit(); | 68 Commit(); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 void WebDatabaseBackend::DBReadTaskWrapper( | 72 void WebDatabaseBackend::DBReadTaskWrapper( |
| 73 const WebDatabaseService::ReadTask& task, | 73 const WebDatabaseService::ReadTask& task, |
| 74 std::unique_ptr<WebDataRequest> request) { | 74 std::unique_ptr<WebDataRequest> request) { |
| 75 if (request->IsCancelled()) | 75 if (request->IsCancelled()) |
| 76 return; | 76 return; |
| 77 | 77 |
| 78 request->SetResult(ExecuteReadTask(task)); | 78 std::unique_ptr<WDTypedResult> result = ExecuteReadTask(task); |
| 79 request_manager_->RequestCompleted(std::move(request)); | 79 request_manager_->RequestCompleted(std::move(request), std::move(result)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 std::unique_ptr<WDTypedResult> WebDatabaseBackend::ExecuteReadTask( | 82 std::unique_ptr<WDTypedResult> WebDatabaseBackend::ExecuteReadTask( |
| 83 const WebDatabaseService::ReadTask& task) { | 83 const WebDatabaseService::ReadTask& task) { |
| 84 LoadDatabaseIfNecessary(); | 84 LoadDatabaseIfNecessary(); |
| 85 if (db_ && init_status_ == sql::INIT_OK) { | 85 if (db_ && init_status_ == sql::INIT_OK) { |
| 86 return task.Run(db_.get()); | 86 return task.Run(db_.get()); |
| 87 } | 87 } |
| 88 return nullptr; | 88 return nullptr; |
| 89 } | 89 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 db_->GetSQLConnection()->RazeAndClose(); | 135 db_->GetSQLConnection()->RazeAndClose(); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 void WebDatabaseBackend::Commit() { | 139 void WebDatabaseBackend::Commit() { |
| 140 DCHECK(db_); | 140 DCHECK(db_); |
| 141 DCHECK_EQ(sql::INIT_OK, init_status_); | 141 DCHECK_EQ(sql::INIT_OK, init_status_); |
| 142 db_->CommitTransaction(); | 142 db_->CommitTransaction(); |
| 143 db_->BeginTransaction(); | 143 db_->BeginTransaction(); |
| 144 } | 144 } |
| OLD | NEW |