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_impl.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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/test/test_simple_task_runner.h" | 12 #include "base/test/test_simple_task_runner.h" |
13 #include "content/browser/indexed_db/indexed_db_connection.h" | 13 #include "content/browser/indexed_db/indexed_db_connection.h" |
14 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 14 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
15 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" | 15 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" |
16 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" | 16 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" | 18 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" |
19 #include "third_party/WebKit/public/platform/WebIDBTypes.h" | 19 #include "third_party/WebKit/public/platform/WebIDBTypes.h" |
20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
21 #include "webkit/common/database/database_identifier.h" | 21 #include "webkit/common/database/database_identifier.h" |
22 | 22 |
23 using base::ASCIIToUTF16; | 23 using base::ASCIIToUTF16; |
24 | 24 |
25 namespace content { | 25 namespace content { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 class MockIDBFactory : public IndexedDBFactory { | 29 class MockIDBFactory : public IndexedDBFactoryImpl { |
30 public: | 30 public: |
31 explicit MockIDBFactory(IndexedDBContextImpl* context) | 31 explicit MockIDBFactory(IndexedDBContextImpl* context) |
32 : IndexedDBFactory(context) {} | 32 : IndexedDBFactoryImpl(context) {} |
33 scoped_refptr<IndexedDBBackingStore> TestOpenBackingStore( | 33 scoped_refptr<IndexedDBBackingStore> TestOpenBackingStore( |
34 const GURL& origin, | 34 const GURL& origin, |
35 const base::FilePath& data_directory) { | 35 const base::FilePath& data_directory) { |
36 blink::WebIDBDataLoss data_loss = | 36 blink::WebIDBDataLoss data_loss = |
37 blink::WebIDBDataLossNone; | 37 blink::WebIDBDataLossNone; |
38 std::string data_loss_message; | 38 std::string data_loss_message; |
39 bool disk_full; | 39 bool disk_full; |
40 leveldb::Status s; | 40 leveldb::Status s; |
41 scoped_refptr<IndexedDBBackingStore> backing_store = | 41 scoped_refptr<IndexedDBBackingStore> backing_store = |
42 OpenBackingStore(origin, | 42 OpenBackingStore(origin, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 scoped_refptr<IndexedDBBackingStore> diskStore1 = | 192 scoped_refptr<IndexedDBBackingStore> diskStore1 = |
193 factory()->TestOpenBackingStore(too_long_origin, base_path); | 193 factory()->TestOpenBackingStore(too_long_origin, base_path); |
194 EXPECT_FALSE(diskStore1); | 194 EXPECT_FALSE(diskStore1); |
195 | 195 |
196 GURL ok_origin("http://someorigin.com:82/"); | 196 GURL ok_origin("http://someorigin.com:82/"); |
197 scoped_refptr<IndexedDBBackingStore> diskStore2 = | 197 scoped_refptr<IndexedDBBackingStore> diskStore2 = |
198 factory()->TestOpenBackingStore(ok_origin, base_path); | 198 factory()->TestOpenBackingStore(ok_origin, base_path); |
199 EXPECT_TRUE(diskStore2); | 199 EXPECT_TRUE(diskStore2); |
200 } | 200 } |
201 | 201 |
202 class DiskFullFactory : public IndexedDBFactory { | 202 class DiskFullFactory : public IndexedDBFactoryImpl { |
203 public: | 203 public: |
204 explicit DiskFullFactory(IndexedDBContextImpl* context) | 204 explicit DiskFullFactory(IndexedDBContextImpl* context) |
205 : IndexedDBFactory(context) {} | 205 : IndexedDBFactoryImpl(context) {} |
206 | 206 |
207 private: | 207 private: |
208 virtual ~DiskFullFactory() {} | 208 virtual ~DiskFullFactory() {} |
209 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( | 209 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( |
210 const GURL& origin_url, | 210 const GURL& origin_url, |
211 const base::FilePath& data_directory, | 211 const base::FilePath& data_directory, |
212 net::URLRequestContext* request_context, | 212 net::URLRequestContext* request_context, |
213 blink::WebIDBDataLoss* data_loss, | 213 blink::WebIDBDataLoss* data_loss, |
214 std::string* data_loss_message, | 214 std::string* data_loss_message, |
215 bool* disk_full, | 215 bool* disk_full, |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 temp_directory.path()); | 524 temp_directory.path()); |
525 EXPECT_TRUE(callbacks->saw_error()); | 525 EXPECT_TRUE(callbacks->saw_error()); |
526 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name)); | 526 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name)); |
527 } | 527 } |
528 | 528 |
529 // Terminate all pending-close timers. | 529 // Terminate all pending-close timers. |
530 factory()->ForceClose(origin); | 530 factory()->ForceClose(origin); |
531 } | 531 } |
532 | 532 |
533 } // namespace content | 533 } // namespace content |
OLD | NEW |