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

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

Issue 16256014: IndexedDB: Convert decoding functions to pass StringPieces vs. pointers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 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/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // and object_store_id still work. 83 // and object_store_id still work.
84 TEST_F(IndexedDBBackingStoreTest, HighIds) { 84 TEST_F(IndexedDBBackingStoreTest, HighIds) {
85 const int64 high_database_id = 1ULL << 35; 85 const int64 high_database_id = 1ULL << 35;
86 const int64 high_object_store_id = 1ULL << 39; 86 const int64 high_object_store_id = 1ULL << 39;
87 // index_ids are capped at 32 bits for storage purposes. 87 // index_ids are capped at 32 bits for storage purposes.
88 const int64 high_index_id = 1ULL << 29; 88 const int64 high_index_id = 1ULL << 29;
89 89
90 const int64 invalid_high_index_id = 1ULL << 37; 90 const int64 invalid_high_index_id = 1ULL << 37;
91 91
92 const IndexedDBKey& index_key = m_key2; 92 const IndexedDBKey& index_key = m_key2;
93 std::vector<char> index_key_raw = EncodeIDBKey(index_key); 93 std::vector<char> index_key_raw;
94 EncodeIDBKey(index_key, &index_key_raw);
94 { 95 {
95 IndexedDBBackingStore::Transaction transaction1(backing_store_.get()); 96 IndexedDBBackingStore::Transaction transaction1(backing_store_.get());
96 transaction1.begin(); 97 transaction1.begin();
97 IndexedDBBackingStore::RecordIdentifier record; 98 IndexedDBBackingStore::RecordIdentifier record;
98 bool ok = backing_store_->PutRecord(&transaction1, 99 bool ok = backing_store_->PutRecord(&transaction1,
99 high_database_id, 100 high_database_id,
100 high_object_store_id, 101 high_object_store_id,
101 m_key1, 102 m_key1,
102 m_value1, 103 m_value1,
103 &record); 104 &record);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 373
373 TEST(IndexedDBFactoryTest, MemoryBackingStoreLifetime) { 374 TEST(IndexedDBFactoryTest, MemoryBackingStoreLifetime) {
374 WebSecurityOrigin origin1 = 375 WebSecurityOrigin origin1 =
375 WebSecurityOrigin::createFromString("http://localhost:81"); 376 WebSecurityOrigin::createFromString("http://localhost:81");
376 WebSecurityOrigin origin2 = 377 WebSecurityOrigin origin2 =
377 WebSecurityOrigin::createFromString("http://localhost:82"); 378 WebSecurityOrigin::createFromString("http://localhost:82");
378 379
379 scoped_refptr<MockIDBFactory> factory = MockIDBFactory::Create(); 380 scoped_refptr<MockIDBFactory> factory = MockIDBFactory::Create();
380 scoped_refptr<IndexedDBBackingStore> mem_store1 = 381 scoped_refptr<IndexedDBBackingStore> mem_store1 =
381 factory->TestOpenBackingStore(origin1, base::FilePath()); 382 factory->TestOpenBackingStore(origin1, base::FilePath());
382 EXPECT_FALSE(mem_store1->HasOneRef()); // mem_store1 and factory 383 EXPECT_FALSE(mem_store1->HasOneRef()); // mem_store1 and factory
383 384
384 scoped_refptr<IndexedDBBackingStore> mem_store2 = 385 scoped_refptr<IndexedDBBackingStore> mem_store2 =
385 factory->TestOpenBackingStore(origin1, base::FilePath()); 386 factory->TestOpenBackingStore(origin1, base::FilePath());
386 EXPECT_EQ(mem_store1.get(), mem_store2.get()); 387 EXPECT_EQ(mem_store1.get(), mem_store2.get());
387 EXPECT_FALSE(mem_store1->HasOneRef()); // mem_store1, 2 and factory 388 EXPECT_FALSE(mem_store1->HasOneRef()); // mem_store1, 2 and factory
388 EXPECT_FALSE(mem_store2->HasOneRef()); // mem_store1, 2 and factory 389 EXPECT_FALSE(mem_store2->HasOneRef()); // mem_store1, 2 and factory
389 390
390 scoped_refptr<IndexedDBBackingStore> mem_store3 = 391 scoped_refptr<IndexedDBBackingStore> mem_store3 =
391 factory->TestOpenBackingStore(origin2, base::FilePath()); 392 factory->TestOpenBackingStore(origin2, base::FilePath());
392 EXPECT_FALSE(mem_store1->HasOneRef()); // mem_store1, 2 and factory 393 EXPECT_FALSE(mem_store1->HasOneRef()); // mem_store1, 2 and factory
393 EXPECT_FALSE(mem_store3->HasOneRef()); // mem_store3 and factory 394 EXPECT_FALSE(mem_store3->HasOneRef()); // mem_store3 and factory
394 395
395 factory = NULL; 396 factory = NULL;
396 EXPECT_FALSE(mem_store1->HasOneRef()); // mem_store1 and 2 397 EXPECT_FALSE(mem_store1->HasOneRef()); // mem_store1 and 2
397 EXPECT_FALSE(mem_store2->HasOneRef()); // mem_store1 and 2 398 EXPECT_FALSE(mem_store2->HasOneRef()); // mem_store1 and 2
398 EXPECT_TRUE(mem_store3->HasOneRef()); 399 EXPECT_TRUE(mem_store3->HasOneRef());
399 400
400 mem_store2 = NULL; 401 mem_store2 = NULL;
401 EXPECT_TRUE(mem_store1->HasOneRef()); 402 EXPECT_TRUE(mem_store1->HasOneRef());
402 } 403 }
403 404
404 } // namespace 405 } // namespace
405 406
406 } // namespace content 407 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698