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 <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/location.h" | 10 #include "base/location.h" |
9 #include "components/webdata/common/web_data_request_manager.h" | 11 #include "components/webdata/common/web_data_request_manager.h" |
10 #include "components/webdata/common/web_database.h" | 12 #include "components/webdata/common/web_database.h" |
11 #include "components/webdata/common/web_database_table.h" | 13 #include "components/webdata/common/web_database_table.h" |
12 | 14 |
13 using base::Bind; | 15 using base::Bind; |
14 using base::FilePath; | 16 using base::FilePath; |
15 | 17 |
16 WebDatabaseBackend::WebDatabaseBackend( | 18 WebDatabaseBackend::WebDatabaseBackend( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 init_status_ = sql::INIT_FAILURE; | 70 init_status_ = sql::INIT_FAILURE; |
69 } | 71 } |
70 | 72 |
71 void WebDatabaseBackend::DBWriteTaskWrapper( | 73 void WebDatabaseBackend::DBWriteTaskWrapper( |
72 const WebDatabaseService::WriteTask& task, | 74 const WebDatabaseService::WriteTask& task, |
73 scoped_ptr<WebDataRequest> request) { | 75 scoped_ptr<WebDataRequest> request) { |
74 if (request->IsCancelled()) | 76 if (request->IsCancelled()) |
75 return; | 77 return; |
76 | 78 |
77 ExecuteWriteTask(task); | 79 ExecuteWriteTask(task); |
78 request_manager_->RequestCompleted(request.Pass()); | 80 request_manager_->RequestCompleted(std::move(request)); |
79 } | 81 } |
80 | 82 |
81 void WebDatabaseBackend::ExecuteWriteTask( | 83 void WebDatabaseBackend::ExecuteWriteTask( |
82 const WebDatabaseService::WriteTask& task) { | 84 const WebDatabaseService::WriteTask& task) { |
83 LoadDatabaseIfNecessary(); | 85 LoadDatabaseIfNecessary(); |
84 if (db_ && init_status_ == sql::INIT_OK) { | 86 if (db_ && init_status_ == sql::INIT_OK) { |
85 WebDatabase::State state = task.Run(db_.get()); | 87 WebDatabase::State state = task.Run(db_.get()); |
86 if (state == WebDatabase::COMMIT_NEEDED) | 88 if (state == WebDatabase::COMMIT_NEEDED) |
87 Commit(); | 89 Commit(); |
88 } | 90 } |
89 } | 91 } |
90 | 92 |
91 void WebDatabaseBackend::DBReadTaskWrapper( | 93 void WebDatabaseBackend::DBReadTaskWrapper( |
92 const WebDatabaseService::ReadTask& task, | 94 const WebDatabaseService::ReadTask& task, |
93 scoped_ptr<WebDataRequest> request) { | 95 scoped_ptr<WebDataRequest> request) { |
94 if (request->IsCancelled()) | 96 if (request->IsCancelled()) |
95 return; | 97 return; |
96 | 98 |
97 request->SetResult(ExecuteReadTask(task).Pass()); | 99 request->SetResult(ExecuteReadTask(task)); |
98 request_manager_->RequestCompleted(request.Pass()); | 100 request_manager_->RequestCompleted(std::move(request)); |
99 } | 101 } |
100 | 102 |
101 scoped_ptr<WDTypedResult> WebDatabaseBackend::ExecuteReadTask( | 103 scoped_ptr<WDTypedResult> WebDatabaseBackend::ExecuteReadTask( |
102 const WebDatabaseService::ReadTask& task) { | 104 const WebDatabaseService::ReadTask& task) { |
103 LoadDatabaseIfNecessary(); | 105 LoadDatabaseIfNecessary(); |
104 if (db_ && init_status_ == sql::INIT_OK) { | 106 if (db_ && init_status_ == sql::INIT_OK) { |
105 return task.Run(db_.get()); | 107 return task.Run(db_.get()); |
106 } | 108 } |
107 return scoped_ptr<WDTypedResult>(); | 109 return scoped_ptr<WDTypedResult>(); |
108 } | 110 } |
109 | 111 |
110 WebDatabaseBackend::~WebDatabaseBackend() { | 112 WebDatabaseBackend::~WebDatabaseBackend() { |
111 ShutdownDatabase(); | 113 ShutdownDatabase(); |
112 } | 114 } |
113 | 115 |
114 void WebDatabaseBackend::Commit() { | 116 void WebDatabaseBackend::Commit() { |
115 DCHECK(db_); | 117 DCHECK(db_); |
116 DCHECK_EQ(sql::INIT_OK, init_status_); | 118 DCHECK_EQ(sql::INIT_OK, init_status_); |
117 db_->CommitTransaction(); | 119 db_->CommitTransaction(); |
118 db_->BeginTransaction(); | 120 db_->BeginTransaction(); |
119 } | 121 } |
OLD | NEW |