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

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

Issue 312093005: IndexedDB: Sprinkle DISALLOW_COPY_AND_ASSIGN where appropriate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing private: 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 | Annotate | Revision Log
OLDNEW
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 "content/browser/indexed_db/indexed_db_backing_store.h" 5 #include "content/browser/indexed_db/indexed_db_backing_store.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 22 matching lines...) Expand all
33 public: 33 public:
34 virtual int Compare(const base::StringPiece& a, 34 virtual int Compare(const base::StringPiece& a,
35 const base::StringPiece& b) const OVERRIDE { 35 const base::StringPiece& b) const OVERRIDE {
36 return content::Compare(a, b, false /*index_keys*/); 36 return content::Compare(a, b, false /*index_keys*/);
37 } 37 }
38 virtual const char* Name() const OVERRIDE { return "idb_cmp1"; } 38 virtual const char* Name() const OVERRIDE { return "idb_cmp1"; }
39 }; 39 };
40 40
41 class DefaultLevelDBFactory : public LevelDBFactory { 41 class DefaultLevelDBFactory : public LevelDBFactory {
42 public: 42 public:
43 DefaultLevelDBFactory() {}
43 virtual leveldb::Status OpenLevelDB(const base::FilePath& file_name, 44 virtual leveldb::Status OpenLevelDB(const base::FilePath& file_name,
44 const LevelDBComparator* comparator, 45 const LevelDBComparator* comparator,
45 scoped_ptr<LevelDBDatabase>* db, 46 scoped_ptr<LevelDBDatabase>* db,
46 bool* is_disk_full) OVERRIDE { 47 bool* is_disk_full) OVERRIDE {
47 return LevelDBDatabase::Open(file_name, comparator, db, is_disk_full); 48 return LevelDBDatabase::Open(file_name, comparator, db, is_disk_full);
48 } 49 }
49 virtual leveldb::Status DestroyLevelDB( 50 virtual leveldb::Status DestroyLevelDB(
50 const base::FilePath& file_name) OVERRIDE { 51 const base::FilePath& file_name) OVERRIDE {
51 return LevelDBDatabase::Destroy(file_name); 52 return LevelDBDatabase::Destroy(file_name);
52 } 53 }
54
55 private:
56 DISALLOW_COPY_AND_ASSIGN(DefaultLevelDBFactory);
53 }; 57 };
54 58
55 class TestableIndexedDBBackingStore : public IndexedDBBackingStore { 59 class TestableIndexedDBBackingStore : public IndexedDBBackingStore {
56 public: 60 public:
57 static scoped_refptr<TestableIndexedDBBackingStore> Open( 61 static scoped_refptr<TestableIndexedDBBackingStore> Open(
58 IndexedDBFactory* indexed_db_factory, 62 IndexedDBFactory* indexed_db_factory,
59 const GURL& origin_url, 63 const GURL& origin_url,
60 const base::FilePath& path_base, 64 const base::FilePath& path_base,
61 net::URLRequestContext* request_context, 65 net::URLRequestContext* request_context,
62 LevelDBFactory* leveldb_factory, 66 LevelDBFactory* leveldb_factory,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 blob_path, 157 blob_path,
154 request_context, 158 request_context,
155 db.Pass(), 159 db.Pass(),
156 comparator.Pass(), 160 comparator.Pass(),
157 task_runner), 161 task_runner),
158 database_id_(0) {} 162 database_id_(0) {}
159 163
160 int64 database_id_; 164 int64 database_id_;
161 std::vector<Transaction::WriteDescriptor> writes_; 165 std::vector<Transaction::WriteDescriptor> writes_;
162 std::vector<int64> removals_; 166 std::vector<int64> removals_;
167
168 DISALLOW_COPY_AND_ASSIGN(TestableIndexedDBBackingStore);
163 }; 169 };
164 170
165 class TestIDBFactory : public IndexedDBFactory { 171 class TestIDBFactory : public IndexedDBFactory {
166 public: 172 public:
167 TestIDBFactory(IndexedDBContextImpl* idb_context) 173 TestIDBFactory(IndexedDBContextImpl* idb_context)
168 : IndexedDBFactory(idb_context) {} 174 : IndexedDBFactory(idb_context) {}
169 175
170 scoped_refptr<TestableIndexedDBBackingStore> OpenBackingStoreForTest( 176 scoped_refptr<TestableIndexedDBBackingStore> OpenBackingStoreForTest(
171 const GURL& origin, 177 const GURL& origin,
172 net::URLRequestContext* url_request_context) { 178 net::URLRequestContext* url_request_context) {
(...skipping 24 matching lines...) Expand all
197 bool* disk_full, 203 bool* disk_full,
198 bool first_time) OVERRIDE { 204 bool first_time) OVERRIDE {
199 DefaultLevelDBFactory leveldb_factory; 205 DefaultLevelDBFactory leveldb_factory;
200 return TestableIndexedDBBackingStore::Open(this, 206 return TestableIndexedDBBackingStore::Open(this,
201 origin_url, 207 origin_url,
202 data_directory, 208 data_directory,
203 request_context, 209 request_context,
204 &leveldb_factory, 210 &leveldb_factory,
205 context()->TaskRunner()); 211 context()->TaskRunner());
206 } 212 }
213
214 private:
215 DISALLOW_COPY_AND_ASSIGN(TestIDBFactory);
207 }; 216 };
208 217
209 class IndexedDBBackingStoreTest : public testing::Test { 218 class IndexedDBBackingStoreTest : public testing::Test {
210 public: 219 public:
211 IndexedDBBackingStoreTest() {} 220 IndexedDBBackingStoreTest() {}
212 virtual void SetUp() { 221 virtual void SetUp() {
213 const GURL origin("http://localhost:81"); 222 const GURL origin("http://localhost:81");
214 task_runner_ = new base::TestSimpleTaskRunner(); 223 task_runner_ = new base::TestSimpleTaskRunner();
215 special_storage_policy_ = new MockSpecialStoragePolicy(); 224 special_storage_policy_ = new MockSpecialStoragePolicy();
216 special_storage_policy_->SetAllUnlimited(true); 225 special_storage_policy_->SetAllUnlimited(true);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 TestCallback() : called(false), succeeded(false) {} 345 TestCallback() : called(false), succeeded(false) {}
337 virtual void Run(bool succeeded_in) OVERRIDE { 346 virtual void Run(bool succeeded_in) OVERRIDE {
338 called = true; 347 called = true;
339 succeeded = succeeded_in; 348 succeeded = succeeded_in;
340 } 349 }
341 bool called; 350 bool called;
342 bool succeeded; 351 bool succeeded;
343 352
344 protected: 353 protected:
345 virtual ~TestCallback() {} 354 virtual ~TestCallback() {}
355
356 private:
357 DISALLOW_COPY_AND_ASSIGN(TestCallback);
346 }; 358 };
347 359
348 TEST_F(IndexedDBBackingStoreTest, PutGetConsistency) { 360 TEST_F(IndexedDBBackingStoreTest, PutGetConsistency) {
349 { 361 {
350 IndexedDBBackingStore::Transaction transaction1(backing_store_); 362 IndexedDBBackingStore::Transaction transaction1(backing_store_);
351 transaction1.Begin(); 363 transaction1.Begin();
352 ScopedVector<webkit_blob::BlobDataHandle> handles; 364 ScopedVector<webkit_blob::BlobDataHandle> handles;
353 IndexedDBBackingStore::RecordIdentifier record; 365 IndexedDBBackingStore::RecordIdentifier record;
354 leveldb::Status s = backing_store_->PutRecord( 366 leveldb::Status s = backing_store_->PutRecord(
355 &transaction1, 1, 1, m_key1, m_value1, &handles, &record); 367 &transaction1, 1, 1, m_key1, m_value1, &handles, &record);
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 EXPECT_EQ(index_name, index.name); 953 EXPECT_EQ(index_name, index.name);
942 EXPECT_EQ(index_key_path, index.key_path); 954 EXPECT_EQ(index_key_path, index.key_path);
943 EXPECT_EQ(unique, index.unique); 955 EXPECT_EQ(unique, index.unique);
944 EXPECT_EQ(multi_entry, index.multi_entry); 956 EXPECT_EQ(multi_entry, index.multi_entry);
945 } 957 }
946 } 958 }
947 959
948 } // namespace 960 } // namespace
949 961
950 } // namespace content 962 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_backing_store.cc ('k') | content/browser/indexed_db/indexed_db_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698