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 <cerrno> | 5 #include <cerrno> |
6 | 6 |
7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 base::ScopedTempDir temp_directory; | 79 base::ScopedTempDir temp_directory; |
80 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); | 80 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
81 const base::FilePath path = temp_directory.path(); | 81 const base::FilePath path = temp_directory.path(); |
82 net::URLRequestContext* request_context = NULL; | 82 net::URLRequestContext* request_context = NULL; |
83 MockLevelDBFactory mock_leveldb_factory; | 83 MockLevelDBFactory mock_leveldb_factory; |
84 blink::WebIDBDataLoss data_loss = | 84 blink::WebIDBDataLoss data_loss = |
85 blink::WebIDBDataLossNone; | 85 blink::WebIDBDataLossNone; |
86 std::string data_loss_message; | 86 std::string data_loss_message; |
87 bool disk_full = false; | 87 bool disk_full = false; |
88 base::TaskRunner* task_runner = NULL; | 88 base::TaskRunner* task_runner = NULL; |
| 89 bool clean_journal = false; |
89 scoped_refptr<IndexedDBBackingStore> backing_store = | 90 scoped_refptr<IndexedDBBackingStore> backing_store = |
90 IndexedDBBackingStore::Open(factory, | 91 IndexedDBBackingStore::Open(factory, |
91 origin, | 92 origin, |
92 path, | 93 path, |
93 request_context, | 94 request_context, |
94 &data_loss, | 95 &data_loss, |
95 &data_loss_message, | 96 &data_loss_message, |
96 &disk_full, | 97 &disk_full, |
97 &mock_leveldb_factory, | 98 &mock_leveldb_factory, |
98 task_runner, | 99 task_runner, |
99 false /* clean_journal */); | 100 clean_journal); |
100 } | 101 } |
101 | 102 |
102 // TODO(dgrogan): Remove expect_destroy if we end up not using it again. It is | 103 // TODO(dgrogan): Remove expect_destroy if we end up not using it again. It is |
103 // currently set to false in all 4 calls below. | 104 // currently set to false in all 4 calls below. |
104 template <class T> | 105 template <class T> |
105 class MockErrorLevelDBFactory : public LevelDBFactory { | 106 class MockErrorLevelDBFactory : public LevelDBFactory { |
106 public: | 107 public: |
107 MockErrorLevelDBFactory(T error, bool expect_destroy) | 108 MockErrorLevelDBFactory(T error, bool expect_destroy) |
108 : error_(error), | 109 : error_(error), |
109 expect_destroy_(expect_destroy), | 110 expect_destroy_(expect_destroy), |
(...skipping 27 matching lines...) Expand all Loading... |
137 const GURL origin("http://localhost:81"); | 138 const GURL origin("http://localhost:81"); |
138 net::URLRequestContext* request_context = NULL; | 139 net::URLRequestContext* request_context = NULL; |
139 base::ScopedTempDir temp_directory; | 140 base::ScopedTempDir temp_directory; |
140 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); | 141 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
141 const base::FilePath path = temp_directory.path(); | 142 const base::FilePath path = temp_directory.path(); |
142 blink::WebIDBDataLoss data_loss = | 143 blink::WebIDBDataLoss data_loss = |
143 blink::WebIDBDataLossNone; | 144 blink::WebIDBDataLossNone; |
144 std::string data_loss_reason; | 145 std::string data_loss_reason; |
145 bool disk_full = false; | 146 bool disk_full = false; |
146 base::TaskRunner* task_runner = NULL; | 147 base::TaskRunner* task_runner = NULL; |
| 148 bool clean_journal = false; |
147 | 149 |
148 MockErrorLevelDBFactory<int> mock_leveldb_factory(ENOSPC, false); | 150 MockErrorLevelDBFactory<int> mock_leveldb_factory(ENOSPC, false); |
149 scoped_refptr<IndexedDBBackingStore> backing_store = | 151 scoped_refptr<IndexedDBBackingStore> backing_store = |
150 IndexedDBBackingStore::Open(factory, | 152 IndexedDBBackingStore::Open(factory, |
151 origin, | 153 origin, |
152 path, | 154 path, |
153 request_context, | 155 request_context, |
154 &data_loss, | 156 &data_loss, |
155 &data_loss_reason, | 157 &data_loss_reason, |
156 &disk_full, | 158 &disk_full, |
157 &mock_leveldb_factory, | 159 &mock_leveldb_factory, |
158 task_runner, | 160 task_runner, |
159 false /* clean_journal */); | 161 clean_journal); |
160 | 162 |
161 MockErrorLevelDBFactory<base::File::Error> mock_leveldb_factory2( | 163 MockErrorLevelDBFactory<base::File::Error> mock_leveldb_factory2( |
162 base::File::FILE_ERROR_NO_MEMORY, false); | 164 base::File::FILE_ERROR_NO_MEMORY, false); |
163 scoped_refptr<IndexedDBBackingStore> backing_store2 = | 165 scoped_refptr<IndexedDBBackingStore> backing_store2 = |
164 IndexedDBBackingStore::Open(factory, | 166 IndexedDBBackingStore::Open(factory, |
165 origin, | 167 origin, |
166 path, | 168 path, |
167 request_context, | 169 request_context, |
168 &data_loss, | 170 &data_loss, |
169 &data_loss_reason, | 171 &data_loss_reason, |
170 &disk_full, | 172 &disk_full, |
171 &mock_leveldb_factory2, | 173 &mock_leveldb_factory2, |
172 task_runner, | 174 task_runner, |
173 false /* clean_journal */); | 175 clean_journal); |
174 | 176 |
175 MockErrorLevelDBFactory<int> mock_leveldb_factory3(EIO, false); | 177 MockErrorLevelDBFactory<int> mock_leveldb_factory3(EIO, false); |
176 scoped_refptr<IndexedDBBackingStore> backing_store3 = | 178 scoped_refptr<IndexedDBBackingStore> backing_store3 = |
177 IndexedDBBackingStore::Open(factory, | 179 IndexedDBBackingStore::Open(factory, |
178 origin, | 180 origin, |
179 path, | 181 path, |
180 request_context, | 182 request_context, |
181 &data_loss, | 183 &data_loss, |
182 &data_loss_reason, | 184 &data_loss_reason, |
183 &disk_full, | 185 &disk_full, |
184 &mock_leveldb_factory3, | 186 &mock_leveldb_factory3, |
185 task_runner, | 187 task_runner, |
186 false /* clean_journal */); | 188 clean_journal); |
187 | 189 |
188 MockErrorLevelDBFactory<base::File::Error> mock_leveldb_factory4( | 190 MockErrorLevelDBFactory<base::File::Error> mock_leveldb_factory4( |
189 base::File::FILE_ERROR_FAILED, false); | 191 base::File::FILE_ERROR_FAILED, false); |
190 scoped_refptr<IndexedDBBackingStore> backing_store4 = | 192 scoped_refptr<IndexedDBBackingStore> backing_store4 = |
191 IndexedDBBackingStore::Open(factory, | 193 IndexedDBBackingStore::Open(factory, |
192 origin, | 194 origin, |
193 path, | 195 path, |
194 request_context, | 196 request_context, |
195 &data_loss, | 197 &data_loss, |
196 &data_loss_reason, | 198 &data_loss_reason, |
197 &disk_full, | 199 &disk_full, |
198 &mock_leveldb_factory4, | 200 &mock_leveldb_factory4, |
199 task_runner, | 201 task_runner, |
200 false /* clean_journal */); | 202 clean_journal); |
201 } | 203 } |
202 | 204 |
203 } // namespace | 205 } // namespace |
OLD | NEW |