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

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

Issue 232343004: Pass blob info through from the IPC to the backing store on put. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge out Created 6 years, 8 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/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" 10 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 IndexedDBValue m_value2; 44 IndexedDBValue m_value2;
45 45
46 private: 46 private:
47 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStoreTest); 47 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStoreTest);
48 }; 48 };
49 49
50 TEST_F(IndexedDBBackingStoreTest, PutGetConsistency) { 50 TEST_F(IndexedDBBackingStoreTest, PutGetConsistency) {
51 { 51 {
52 IndexedDBBackingStore::Transaction transaction1(backing_store_); 52 IndexedDBBackingStore::Transaction transaction1(backing_store_);
53 transaction1.Begin(); 53 transaction1.Begin();
54 ScopedVector<webkit_blob::BlobDataHandle> handles;
54 IndexedDBBackingStore::RecordIdentifier record; 55 IndexedDBBackingStore::RecordIdentifier record;
55 leveldb::Status s = backing_store_->PutRecord( 56 leveldb::Status s = backing_store_->PutRecord(
56 &transaction1, 1, 1, m_key1, m_value1, &record); 57 &transaction1, 1, 1, m_key1, m_value1, &handles, &record);
57 EXPECT_TRUE(s.ok()); 58 EXPECT_TRUE(s.ok());
58 transaction1.Commit(); 59 transaction1.Commit();
59 } 60 }
60 61
61 { 62 {
62 IndexedDBBackingStore::Transaction transaction2(backing_store_); 63 IndexedDBBackingStore::Transaction transaction2(backing_store_);
63 transaction2.Begin(); 64 transaction2.Begin();
64 IndexedDBValue result_value; 65 IndexedDBValue result_value;
65 leveldb::Status s = 66 leveldb::Status s =
66 backing_store_->GetRecord(&transaction2, 1, 1, m_key1, &result_value); 67 backing_store_->GetRecord(&transaction2, 1, 1, m_key1, &result_value);
(...skipping 12 matching lines...) Expand all
79 const int64 high_index_id = 1ULL << 29; 80 const int64 high_index_id = 1ULL << 29;
80 81
81 const int64 invalid_high_index_id = 1ULL << 37; 82 const int64 invalid_high_index_id = 1ULL << 37;
82 83
83 const IndexedDBKey& index_key = m_key2; 84 const IndexedDBKey& index_key = m_key2;
84 std::string index_key_raw; 85 std::string index_key_raw;
85 EncodeIDBKey(index_key, &index_key_raw); 86 EncodeIDBKey(index_key, &index_key_raw);
86 { 87 {
87 IndexedDBBackingStore::Transaction transaction1(backing_store_); 88 IndexedDBBackingStore::Transaction transaction1(backing_store_);
88 transaction1.Begin(); 89 transaction1.Begin();
90 ScopedVector<webkit_blob::BlobDataHandle> handles;
89 IndexedDBBackingStore::RecordIdentifier record; 91 IndexedDBBackingStore::RecordIdentifier record;
90 leveldb::Status s = backing_store_->PutRecord(&transaction1, 92 leveldb::Status s = backing_store_->PutRecord(&transaction1,
91 high_database_id, 93 high_database_id,
92 high_object_store_id, 94 high_object_store_id,
93 m_key1, 95 m_key1,
94 m_value1, 96 m_value1,
97 &handles,
95 &record); 98 &record);
96 EXPECT_TRUE(s.ok()); 99 EXPECT_TRUE(s.ok());
97 100
98 s = backing_store_->PutIndexDataForRecord(&transaction1, 101 s = backing_store_->PutIndexDataForRecord(&transaction1,
99 high_database_id, 102 high_database_id,
100 high_object_store_id, 103 high_object_store_id,
101 invalid_high_index_id, 104 invalid_high_index_id,
102 index_key, 105 index_key,
103 record); 106 record);
104 EXPECT_FALSE(s.ok()); 107 EXPECT_FALSE(s.ok());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 const int64 database_id = 1; 159 const int64 database_id = 1;
157 const int64 object_store_id = 1; 160 const int64 object_store_id = 1;
158 const int64 index_id = kMinimumIndexId; 161 const int64 index_id = kMinimumIndexId;
159 const int64 invalid_low_index_id = 19; // index_ids must be > kMinimumIndexId 162 const int64 invalid_low_index_id = 19; // index_ids must be > kMinimumIndexId
160 163
161 IndexedDBValue result_value; 164 IndexedDBValue result_value;
162 165
163 IndexedDBBackingStore::Transaction transaction1(backing_store_); 166 IndexedDBBackingStore::Transaction transaction1(backing_store_);
164 transaction1.Begin(); 167 transaction1.Begin();
165 168
169 ScopedVector<webkit_blob::BlobDataHandle> handles;
166 IndexedDBBackingStore::RecordIdentifier record; 170 IndexedDBBackingStore::RecordIdentifier record;
167 leveldb::Status s = backing_store_->PutRecord(&transaction1, 171 leveldb::Status s = backing_store_->PutRecord(&transaction1,
168 database_id, 172 database_id,
169 KeyPrefix::kInvalidId, 173 KeyPrefix::kInvalidId,
170 m_key1, 174 m_key1,
171 m_value1, 175 m_value1,
176 &handles,
172 &record); 177 &record);
173 EXPECT_FALSE(s.ok()); 178 EXPECT_FALSE(s.ok());
174 s = backing_store_->PutRecord( 179 s = backing_store_->PutRecord(
175 &transaction1, database_id, 0, m_key1, m_value1, &record); 180 &transaction1, database_id, 0, m_key1, m_value1, &handles, &record);
176 EXPECT_FALSE(s.ok()); 181 EXPECT_FALSE(s.ok());
177 s = backing_store_->PutRecord(&transaction1, 182 s = backing_store_->PutRecord(&transaction1,
178 KeyPrefix::kInvalidId, 183 KeyPrefix::kInvalidId,
179 object_store_id, 184 object_store_id,
180 m_key1, 185 m_key1,
181 m_value1, 186 m_value1,
187 &handles,
182 &record); 188 &record);
183 EXPECT_FALSE(s.ok()); 189 EXPECT_FALSE(s.ok());
184 s = backing_store_->PutRecord( 190 s = backing_store_->PutRecord(
185 &transaction1, 0, object_store_id, m_key1, m_value1, &record); 191 &transaction1, 0, object_store_id, m_key1, m_value1, &handles, &record);
186 EXPECT_FALSE(s.ok()); 192 EXPECT_FALSE(s.ok());
187 193
188 s = backing_store_->GetRecord( 194 s = backing_store_->GetRecord(
189 &transaction1, database_id, KeyPrefix::kInvalidId, m_key1, &result_value); 195 &transaction1, database_id, KeyPrefix::kInvalidId, m_key1, &result_value);
190 EXPECT_FALSE(s.ok()); 196 EXPECT_FALSE(s.ok());
191 s = backing_store_->GetRecord( 197 s = backing_store_->GetRecord(
192 &transaction1, database_id, 0, m_key1, &result_value); 198 &transaction1, database_id, 0, m_key1, &result_value);
193 EXPECT_FALSE(s.ok()); 199 EXPECT_FALSE(s.ok());
194 s = backing_store_->GetRecord(&transaction1, 200 s = backing_store_->GetRecord(&transaction1,
195 KeyPrefix::kInvalidId, 201 KeyPrefix::kInvalidId,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 EXPECT_EQ(index_name, index.name); 319 EXPECT_EQ(index_name, index.name);
314 EXPECT_EQ(index_key_path, index.key_path); 320 EXPECT_EQ(index_key_path, index.key_path);
315 EXPECT_EQ(unique, index.unique); 321 EXPECT_EQ(unique, index.unique);
316 EXPECT_EQ(multi_entry, index.multi_entry); 322 EXPECT_EQ(multi_entry, index.multi_entry);
317 } 323 }
318 } 324 }
319 325
320 } // namespace 326 } // namespace
321 327
322 } // namespace content 328 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_backing_store.cc ('k') | content/browser/indexed_db/indexed_db_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698