OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/indexed_db/indexed_db_backing_store.h" | 5 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
16 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "base/test/test_simple_task_runner.h" | 19 #include "base/test/test_simple_task_runner.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 86 |
86 scoped_ptr<LevelDBDatabase> db; | 87 scoped_ptr<LevelDBDatabase> db; |
87 bool is_disk_full = false; | 88 bool is_disk_full = false; |
88 *status = leveldb_factory->OpenLevelDB( | 89 *status = leveldb_factory->OpenLevelDB( |
89 file_path, comparator.get(), &db, &is_disk_full); | 90 file_path, comparator.get(), &db, &is_disk_full); |
90 | 91 |
91 if (!db || !status->ok()) | 92 if (!db || !status->ok()) |
92 return scoped_refptr<TestableIndexedDBBackingStore>(); | 93 return scoped_refptr<TestableIndexedDBBackingStore>(); |
93 | 94 |
94 scoped_refptr<TestableIndexedDBBackingStore> backing_store( | 95 scoped_refptr<TestableIndexedDBBackingStore> backing_store( |
95 new TestableIndexedDBBackingStore(indexed_db_factory, | 96 new TestableIndexedDBBackingStore( |
96 origin_url, | 97 indexed_db_factory, origin_url, blob_path, request_context, |
97 blob_path, | 98 std::move(db), std::move(comparator), task_runner)); |
98 request_context, | |
99 db.Pass(), | |
100 comparator.Pass(), | |
101 task_runner)); | |
102 | 99 |
103 *status = backing_store->SetUpMetadata(); | 100 *status = backing_store->SetUpMetadata(); |
104 if (!status->ok()) | 101 if (!status->ok()) |
105 return scoped_refptr<TestableIndexedDBBackingStore>(); | 102 return scoped_refptr<TestableIndexedDBBackingStore>(); |
106 | 103 |
107 return backing_store; | 104 return backing_store; |
108 } | 105 } |
109 | 106 |
110 const std::vector<IndexedDBBackingStore::Transaction::WriteDescriptor>& | 107 const std::vector<IndexedDBBackingStore::Transaction::WriteDescriptor>& |
111 writes() const { | 108 writes() const { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 const GURL& origin_url, | 155 const GURL& origin_url, |
159 const base::FilePath& blob_path, | 156 const base::FilePath& blob_path, |
160 net::URLRequestContext* request_context, | 157 net::URLRequestContext* request_context, |
161 scoped_ptr<LevelDBDatabase> db, | 158 scoped_ptr<LevelDBDatabase> db, |
162 scoped_ptr<LevelDBComparator> comparator, | 159 scoped_ptr<LevelDBComparator> comparator, |
163 base::SequencedTaskRunner* task_runner) | 160 base::SequencedTaskRunner* task_runner) |
164 : IndexedDBBackingStore(indexed_db_factory, | 161 : IndexedDBBackingStore(indexed_db_factory, |
165 origin_url, | 162 origin_url, |
166 blob_path, | 163 blob_path, |
167 request_context, | 164 request_context, |
168 db.Pass(), | 165 std::move(db), |
169 comparator.Pass(), | 166 std::move(comparator), |
170 task_runner), | 167 task_runner), |
171 database_id_(0) {} | 168 database_id_(0) {} |
172 | 169 |
173 int64_t database_id_; | 170 int64_t database_id_; |
174 std::vector<Transaction::WriteDescriptor> writes_; | 171 std::vector<Transaction::WriteDescriptor> writes_; |
175 | 172 |
176 // This is modified in an overridden virtual function that is properly const | 173 // This is modified in an overridden virtual function that is properly const |
177 // in the real implementation, therefore must be mutable here. | 174 // in the real implementation, therefore must be mutable here. |
178 mutable std::vector<int64_t> removals_; | 175 mutable std::vector<int64_t> removals_; |
179 | 176 |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 | 1043 |
1047 std::vector<base::string16> names = backing_store_->GetDatabaseNames(&s); | 1044 std::vector<base::string16> names = backing_store_->GetDatabaseNames(&s); |
1048 EXPECT_TRUE(s.ok()); | 1045 EXPECT_TRUE(s.ok()); |
1049 EXPECT_EQ(names.size(), 1ULL); | 1046 EXPECT_EQ(names.size(), 1ULL); |
1050 EXPECT_EQ(names[0], db1_name); | 1047 EXPECT_EQ(names[0], db1_name); |
1051 } | 1048 } |
1052 | 1049 |
1053 } // namespace | 1050 } // namespace |
1054 | 1051 |
1055 } // namespace content | 1052 } // namespace content |
OLD | NEW |