Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: content/browser/indexed_db/indexed_db_factory_unittest.cc

Issue 313883003: Split IndexedDBFactory into virtual base + impl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
6
7 #include "base/file_util.h" 5 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 7 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
11 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
12 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
13 #include "content/browser/indexed_db/indexed_db_connection.h" 11 #include "content/browser/indexed_db/indexed_db_connection.h"
14 #include "content/browser/indexed_db/indexed_db_context_impl.h" 12 #include "content/browser/indexed_db/indexed_db_context_impl.h"
13 #include "content/browser/indexed_db/indexed_db_factory_impl.h"
15 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" 14 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h"
16 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" 15 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" 17 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h"
19 #include "third_party/WebKit/public/platform/WebIDBTypes.h" 18 #include "third_party/WebKit/public/platform/WebIDBTypes.h"
20 #include "url/gurl.h" 19 #include "url/gurl.h"
21 #include "webkit/common/database/database_identifier.h" 20 #include "webkit/common/database/database_identifier.h"
22 21
23 using base::ASCIIToUTF16; 22 using base::ASCIIToUTF16;
24 23
25 namespace content { 24 namespace content {
26 25
27 namespace { 26 namespace {
28 27
29 class MockIDBFactory : public IndexedDBFactory { 28 class MockIDBFactory : public IndexedDBFactoryImpl {
30 public: 29 public:
31 MockIDBFactory(IndexedDBContextImpl* context) : IndexedDBFactory(context) {} 30 MockIDBFactory(IndexedDBContextImpl* context)
31 : IndexedDBFactoryImpl(context) {}
32 scoped_refptr<IndexedDBBackingStore> TestOpenBackingStore( 32 scoped_refptr<IndexedDBBackingStore> TestOpenBackingStore(
33 const GURL& origin, 33 const GURL& origin,
34 const base::FilePath& data_directory) { 34 const base::FilePath& data_directory) {
35 blink::WebIDBDataLoss data_loss = 35 blink::WebIDBDataLoss data_loss =
36 blink::WebIDBDataLossNone; 36 blink::WebIDBDataLossNone;
37 std::string data_loss_message; 37 std::string data_loss_message;
38 bool disk_full; 38 bool disk_full;
39 scoped_refptr<IndexedDBBackingStore> backing_store = 39 scoped_refptr<IndexedDBBackingStore> backing_store =
40 OpenBackingStore(origin, 40 OpenBackingStore(origin,
41 data_directory, 41 data_directory,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 scoped_refptr<IndexedDBBackingStore> diskStore1 = 187 scoped_refptr<IndexedDBBackingStore> diskStore1 =
188 factory()->TestOpenBackingStore(too_long_origin, base_path); 188 factory()->TestOpenBackingStore(too_long_origin, base_path);
189 EXPECT_FALSE(diskStore1); 189 EXPECT_FALSE(diskStore1);
190 190
191 GURL ok_origin("http://someorigin.com:82/"); 191 GURL ok_origin("http://someorigin.com:82/");
192 scoped_refptr<IndexedDBBackingStore> diskStore2 = 192 scoped_refptr<IndexedDBBackingStore> diskStore2 =
193 factory()->TestOpenBackingStore(ok_origin, base_path); 193 factory()->TestOpenBackingStore(ok_origin, base_path);
194 EXPECT_TRUE(diskStore2); 194 EXPECT_TRUE(diskStore2);
195 } 195 }
196 196
197 class DiskFullFactory : public IndexedDBFactory { 197 class DiskFullFactory : public IndexedDBFactoryImpl {
198 public: 198 public:
199 DiskFullFactory(IndexedDBContextImpl* context) : IndexedDBFactory(context) {} 199 DiskFullFactory(IndexedDBContextImpl* context)
200 : IndexedDBFactoryImpl(context) {}
200 201
201 private: 202 private:
202 virtual ~DiskFullFactory() {} 203 virtual ~DiskFullFactory() {}
203 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( 204 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore(
204 const GURL& origin_url, 205 const GURL& origin_url,
205 const base::FilePath& data_directory, 206 const base::FilePath& data_directory,
206 net::URLRequestContext* request_context, 207 net::URLRequestContext* request_context,
207 blink::WebIDBDataLoss* data_loss, 208 blink::WebIDBDataLoss* data_loss,
208 std::string* data_loss_message, 209 std::string* data_loss_message,
209 bool* disk_full) OVERRIDE { 210 bool* disk_full) OVERRIDE {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 temp_directory.path()); 506 temp_directory.path());
506 EXPECT_TRUE(callbacks->saw_error()); 507 EXPECT_TRUE(callbacks->saw_error());
507 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name)); 508 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name));
508 } 509 }
509 510
510 // Terminate all pending-close timers. 511 // Terminate all pending-close timers.
511 factory()->ForceClose(origin); 512 factory()->ForceClose(origin);
512 } 513 }
513 514
514 } // namespace content 515 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698