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 "content/browser/indexed_db/indexed_db_factory.h" | 5 #include "content/browser/indexed_db/indexed_db_factory.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 private: | 33 private: |
34 DISALLOW_COPY_AND_ASSIGN(IndexedDBFactoryTest); | 34 DISALLOW_COPY_AND_ASSIGN(IndexedDBFactoryTest); |
35 }; | 35 }; |
36 | 36 |
37 class MockIDBFactory : public IndexedDBFactory { | 37 class MockIDBFactory : public IndexedDBFactory { |
38 public: | 38 public: |
39 MockIDBFactory() : IndexedDBFactory(NULL) {} | 39 MockIDBFactory() : IndexedDBFactory(NULL) {} |
40 scoped_refptr<IndexedDBBackingStore> TestOpenBackingStore( | 40 scoped_refptr<IndexedDBBackingStore> TestOpenBackingStore( |
41 const GURL& origin, | 41 const GURL& origin, |
42 const base::FilePath& data_directory) { | 42 const base::FilePath& data_directory) { |
43 WebKit::WebIDBCallbacks::DataLoss data_loss = | 43 blink::WebIDBCallbacks::DataLoss data_loss = |
44 WebKit::WebIDBCallbacks::DataLossNone; | 44 blink::WebIDBCallbacks::DataLossNone; |
45 std::string data_loss_message; | 45 std::string data_loss_message; |
46 bool disk_full; | 46 bool disk_full; |
47 scoped_refptr<IndexedDBBackingStore> backing_store = | 47 scoped_refptr<IndexedDBBackingStore> backing_store = |
48 OpenBackingStore(origin, | 48 OpenBackingStore(origin, |
49 data_directory, | 49 data_directory, |
50 &data_loss, | 50 &data_loss, |
51 &data_loss_message, | 51 &data_loss_message, |
52 &disk_full); | 52 &disk_full); |
53 EXPECT_EQ(WebKit::WebIDBCallbacks::DataLossNone, data_loss); | 53 EXPECT_EQ(blink::WebIDBCallbacks::DataLossNone, data_loss); |
54 return backing_store; | 54 return backing_store; |
55 } | 55 } |
56 | 56 |
57 void TestCloseBackingStore(IndexedDBBackingStore* backing_store) { | 57 void TestCloseBackingStore(IndexedDBBackingStore* backing_store) { |
58 CloseBackingStore(backing_store->origin_url()); | 58 CloseBackingStore(backing_store->origin_url()); |
59 } | 59 } |
60 | 60 |
61 void TestReleaseBackingStore(IndexedDBBackingStore* backing_store, | 61 void TestReleaseBackingStore(IndexedDBBackingStore* backing_store, |
62 bool immediate) { | 62 bool immediate) { |
63 ReleaseBackingStore(backing_store->origin_url(), immediate); | 63 ReleaseBackingStore(backing_store->origin_url(), immediate); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 class DiskFullFactory : public IndexedDBFactory { | 181 class DiskFullFactory : public IndexedDBFactory { |
182 public: | 182 public: |
183 DiskFullFactory() : IndexedDBFactory(NULL) {} | 183 DiskFullFactory() : IndexedDBFactory(NULL) {} |
184 | 184 |
185 private: | 185 private: |
186 virtual ~DiskFullFactory() {} | 186 virtual ~DiskFullFactory() {} |
187 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( | 187 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( |
188 const GURL& origin_url, | 188 const GURL& origin_url, |
189 const base::FilePath& data_directory, | 189 const base::FilePath& data_directory, |
190 WebKit::WebIDBCallbacks::DataLoss* data_loss, | 190 blink::WebIDBCallbacks::DataLoss* data_loss, |
191 std::string* data_loss_message, | 191 std::string* data_loss_message, |
192 bool* disk_full) OVERRIDE { | 192 bool* disk_full) OVERRIDE { |
193 *disk_full = true; | 193 *disk_full = true; |
194 return scoped_refptr<IndexedDBBackingStore>(); | 194 return scoped_refptr<IndexedDBBackingStore>(); |
195 } | 195 } |
196 }; | 196 }; |
197 | 197 |
198 class LookingForQuotaErrorMockCallbacks : public IndexedDBCallbacks { | 198 class LookingForQuotaErrorMockCallbacks : public IndexedDBCallbacks { |
199 public: | 199 public: |
200 LookingForQuotaErrorMockCallbacks() | 200 LookingForQuotaErrorMockCallbacks() |
201 : IndexedDBCallbacks(NULL, 0, 0), error_called_(false) {} | 201 : IndexedDBCallbacks(NULL, 0, 0), error_called_(false) {} |
202 virtual void OnError(const IndexedDBDatabaseError& error) OVERRIDE { | 202 virtual void OnError(const IndexedDBDatabaseError& error) OVERRIDE { |
203 error_called_ = true; | 203 error_called_ = true; |
204 EXPECT_EQ(WebKit::WebIDBDatabaseExceptionQuotaError, error.code()); | 204 EXPECT_EQ(blink::WebIDBDatabaseExceptionQuotaError, error.code()); |
205 } | 205 } |
206 | 206 |
207 private: | 207 private: |
208 virtual ~LookingForQuotaErrorMockCallbacks() { EXPECT_TRUE(error_called_); } | 208 virtual ~LookingForQuotaErrorMockCallbacks() { EXPECT_TRUE(error_called_); } |
209 bool error_called_; | 209 bool error_called_; |
210 }; | 210 }; |
211 | 211 |
212 TEST_F(IndexedDBFactoryTest, QuotaErrorOnDiskFull) { | 212 TEST_F(IndexedDBFactoryTest, QuotaErrorOnDiskFull) { |
213 const GURL origin("http://localhost:81"); | 213 const GURL origin("http://localhost:81"); |
214 | 214 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // Now simulate shutdown, which should stop the timer. | 290 // Now simulate shutdown, which should stop the timer. |
291 factory->ContextDestroyed(); | 291 factory->ContextDestroyed(); |
292 EXPECT_TRUE(store->HasOneRef()); // Local. | 292 EXPECT_TRUE(store->HasOneRef()); // Local. |
293 EXPECT_FALSE(store->close_timer()->IsRunning()); | 293 EXPECT_FALSE(store->close_timer()->IsRunning()); |
294 EXPECT_FALSE(factory->IsBackingStoreOpenForTesting(origin)); | 294 EXPECT_FALSE(factory->IsBackingStoreOpenForTesting(origin)); |
295 } | 295 } |
296 | 296 |
297 } // namespace | 297 } // namespace |
298 | 298 |
299 } // namespace content | 299 } // namespace content |
OLD | NEW |