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

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: Added protected IndexedDBFactory constructor prototype. 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 explicit MockIDBFactory(IndexedDBContextImpl* context) 30 explicit MockIDBFactory(IndexedDBContextImpl* context)
32 : IndexedDBFactory(context) {} 31 : IndexedDBFactoryImpl(context) {}
33 scoped_refptr<IndexedDBBackingStore> TestOpenBackingStore( 32 scoped_refptr<IndexedDBBackingStore> TestOpenBackingStore(
34 const GURL& origin, 33 const GURL& origin,
35 const base::FilePath& data_directory) { 34 const base::FilePath& data_directory) {
36 blink::WebIDBDataLoss data_loss = 35 blink::WebIDBDataLoss data_loss =
37 blink::WebIDBDataLossNone; 36 blink::WebIDBDataLossNone;
38 std::string data_loss_message; 37 std::string data_loss_message;
39 bool disk_full; 38 bool disk_full;
40 scoped_refptr<IndexedDBBackingStore> backing_store = 39 scoped_refptr<IndexedDBBackingStore> backing_store =
41 OpenBackingStore(origin, 40 OpenBackingStore(origin,
42 data_directory, 41 data_directory,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 scoped_refptr<IndexedDBBackingStore> diskStore1 = 189 scoped_refptr<IndexedDBBackingStore> diskStore1 =
191 factory()->TestOpenBackingStore(too_long_origin, base_path); 190 factory()->TestOpenBackingStore(too_long_origin, base_path);
192 EXPECT_FALSE(diskStore1); 191 EXPECT_FALSE(diskStore1);
193 192
194 GURL ok_origin("http://someorigin.com:82/"); 193 GURL ok_origin("http://someorigin.com:82/");
195 scoped_refptr<IndexedDBBackingStore> diskStore2 = 194 scoped_refptr<IndexedDBBackingStore> diskStore2 =
196 factory()->TestOpenBackingStore(ok_origin, base_path); 195 factory()->TestOpenBackingStore(ok_origin, base_path);
197 EXPECT_TRUE(diskStore2); 196 EXPECT_TRUE(diskStore2);
198 } 197 }
199 198
200 class DiskFullFactory : public IndexedDBFactory { 199 class DiskFullFactory : public IndexedDBFactoryImpl {
201 public: 200 public:
202 explicit DiskFullFactory(IndexedDBContextImpl* context) 201 explicit DiskFullFactory(IndexedDBContextImpl* context)
203 : IndexedDBFactory(context) {} 202 : IndexedDBFactoryImpl(context) {}
204 203
205 private: 204 private:
206 virtual ~DiskFullFactory() {} 205 virtual ~DiskFullFactory() {}
207 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( 206 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore(
208 const GURL& origin_url, 207 const GURL& origin_url,
209 const base::FilePath& data_directory, 208 const base::FilePath& data_directory,
210 net::URLRequestContext* request_context, 209 net::URLRequestContext* request_context,
211 blink::WebIDBDataLoss* data_loss, 210 blink::WebIDBDataLoss* data_loss,
212 std::string* data_loss_message, 211 std::string* data_loss_message,
213 bool* disk_full) OVERRIDE { 212 bool* disk_full) OVERRIDE {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 temp_directory.path()); 519 temp_directory.path());
521 EXPECT_TRUE(callbacks->saw_error()); 520 EXPECT_TRUE(callbacks->saw_error());
522 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name)); 521 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name));
523 } 522 }
524 523
525 // Terminate all pending-close timers. 524 // Terminate all pending-close timers.
526 factory()->ForceClose(origin); 525 factory()->ForceClose(origin);
527 } 526 }
528 527
529 } // namespace content 528 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698