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

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

Issue 810403004: [Storage] Blob Storage Refactoring pt 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: memory leak fixed Created 5 years, 11 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 (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/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 *new_version_number = version; 1883 *new_version_number = version;
1884 return s; 1884 return s;
1885 } 1885 }
1886 1886
1887 leveldb::Status IndexedDBBackingStore::PutRecord( 1887 leveldb::Status IndexedDBBackingStore::PutRecord(
1888 IndexedDBBackingStore::Transaction* transaction, 1888 IndexedDBBackingStore::Transaction* transaction,
1889 int64 database_id, 1889 int64 database_id,
1890 int64 object_store_id, 1890 int64 object_store_id,
1891 const IndexedDBKey& key, 1891 const IndexedDBKey& key,
1892 IndexedDBValue* value, 1892 IndexedDBValue* value,
1893 ScopedVector<storage::BlobDataHandle>* handles, 1893 ScopedVector<storage::BlobDataSnapshotHandle>* handles,
1894 RecordIdentifier* record_identifier) { 1894 RecordIdentifier* record_identifier) {
1895 IDB_TRACE("IndexedDBBackingStore::PutRecord"); 1895 IDB_TRACE("IndexedDBBackingStore::PutRecord");
1896 if (!KeyPrefix::ValidIds(database_id, object_store_id)) 1896 if (!KeyPrefix::ValidIds(database_id, object_store_id))
1897 return InvalidDBKeyStatus(); 1897 return InvalidDBKeyStatus();
1898 DCHECK(key.IsValid()); 1898 DCHECK(key.IsValid());
1899 1899
1900 LevelDBTransaction* leveldb_transaction = transaction->transaction(); 1900 LevelDBTransaction* leveldb_transaction = transaction->transaction();
1901 int64 version = -1; 1901 int64 version = -1;
1902 leveldb::Status s = GetNewVersionNumber( 1902 leveldb::Status s = GetNewVersionNumber(
1903 leveldb_transaction, database_id, object_store_id, &version); 1903 leveldb_transaction, database_id, object_store_id, &version);
(...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after
4181 } 4181 }
4182 4182
4183 void IndexedDBBackingStore::BlobChangeRecord::SetBlobInfo( 4183 void IndexedDBBackingStore::BlobChangeRecord::SetBlobInfo(
4184 std::vector<IndexedDBBlobInfo>* blob_info) { 4184 std::vector<IndexedDBBlobInfo>* blob_info) {
4185 blob_info_.clear(); 4185 blob_info_.clear();
4186 if (blob_info) 4186 if (blob_info)
4187 blob_info_.swap(*blob_info); 4187 blob_info_.swap(*blob_info);
4188 } 4188 }
4189 4189
4190 void IndexedDBBackingStore::BlobChangeRecord::SetHandles( 4190 void IndexedDBBackingStore::BlobChangeRecord::SetHandles(
4191 ScopedVector<storage::BlobDataHandle>* handles) { 4191 ScopedVector<storage::BlobDataSnapshotHandle>* handles) {
4192 handles_.clear(); 4192 handles_.clear();
4193 if (handles) 4193 if (handles)
4194 handles_.swap(*handles); 4194 handles_.swap(*handles);
4195 } 4195 }
4196 4196
4197 scoped_ptr<IndexedDBBackingStore::BlobChangeRecord> 4197 scoped_ptr<IndexedDBBackingStore::BlobChangeRecord>
4198 IndexedDBBackingStore::BlobChangeRecord::Clone() const { 4198 IndexedDBBackingStore::BlobChangeRecord::Clone() const {
4199 scoped_ptr<IndexedDBBackingStore::BlobChangeRecord> record( 4199 scoped_ptr<IndexedDBBackingStore::BlobChangeRecord> record(
4200 new BlobChangeRecord(key_, object_store_id_)); 4200 new BlobChangeRecord(key_, object_store_id_));
4201 record->blob_info_ = blob_info_; 4201 record->blob_info_ = blob_info_;
4202 4202
4203 for (const auto* handle : handles_) 4203 for (const auto* handle : handles_)
4204 record->handles_.push_back(new storage::BlobDataHandle(*handle)); 4204 record->handles_.push_back(new storage::BlobDataSnapshotHandle(*handle));
4205 return record.Pass(); 4205 return record.Pass();
4206 } 4206 }
4207 4207
4208 leveldb::Status IndexedDBBackingStore::Transaction::PutBlobInfoIfNeeded( 4208 leveldb::Status IndexedDBBackingStore::Transaction::PutBlobInfoIfNeeded(
4209 int64 database_id, 4209 int64 database_id,
4210 int64 object_store_id, 4210 int64 object_store_id,
4211 const std::string& object_store_data_key, 4211 const std::string& object_store_data_key,
4212 std::vector<IndexedDBBlobInfo>* blob_info, 4212 std::vector<IndexedDBBlobInfo>* blob_info,
4213 ScopedVector<storage::BlobDataHandle>* handles) { 4213 ScopedVector<storage::BlobDataSnapshotHandle>* handles) {
4214 if (!blob_info || blob_info->empty()) { 4214 if (!blob_info || blob_info->empty()) {
4215 blob_change_map_.erase(object_store_data_key); 4215 blob_change_map_.erase(object_store_data_key);
4216 incognito_blob_map_.erase(object_store_data_key); 4216 incognito_blob_map_.erase(object_store_data_key);
4217 4217
4218 BlobEntryKey blob_entry_key; 4218 BlobEntryKey blob_entry_key;
4219 StringPiece leveldb_key_piece(object_store_data_key); 4219 StringPiece leveldb_key_piece(object_store_data_key);
4220 if (!BlobEntryKey::FromObjectStoreDataKey(&leveldb_key_piece, 4220 if (!BlobEntryKey::FromObjectStoreDataKey(&leveldb_key_piece,
4221 &blob_entry_key)) { 4221 &blob_entry_key)) {
4222 NOTREACHED(); 4222 NOTREACHED();
4223 return InternalInconsistencyStatus(); 4223 return InternalInconsistencyStatus();
(...skipping 14 matching lines...) Expand all
4238 4238
4239 // This is storing an info, even if empty, even if the previous key had no blob 4239 // This is storing an info, even if empty, even if the previous key had no blob
4240 // info that we know of. It duplicates a bunch of information stored in the 4240 // info that we know of. It duplicates a bunch of information stored in the
4241 // leveldb transaction, but only w.r.t. the user keys altered--we don't keep the 4241 // leveldb transaction, but only w.r.t. the user keys altered--we don't keep the
4242 // changes to exists or index keys here. 4242 // changes to exists or index keys here.
4243 void IndexedDBBackingStore::Transaction::PutBlobInfo( 4243 void IndexedDBBackingStore::Transaction::PutBlobInfo(
4244 int64 database_id, 4244 int64 database_id,
4245 int64 object_store_id, 4245 int64 object_store_id,
4246 const std::string& object_store_data_key, 4246 const std::string& object_store_data_key,
4247 std::vector<IndexedDBBlobInfo>* blob_info, 4247 std::vector<IndexedDBBlobInfo>* blob_info,
4248 ScopedVector<storage::BlobDataHandle>* handles) { 4248 ScopedVector<storage::BlobDataSnapshotHandle>* handles) {
4249 DCHECK_GT(object_store_data_key.size(), 0UL); 4249 DCHECK_GT(object_store_data_key.size(), 0UL);
4250 if (database_id_ < 0) 4250 if (database_id_ < 0)
4251 database_id_ = database_id; 4251 database_id_ = database_id;
4252 DCHECK_EQ(database_id_, database_id); 4252 DCHECK_EQ(database_id_, database_id);
4253 4253
4254 BlobChangeMap::iterator it = blob_change_map_.find(object_store_data_key); 4254 BlobChangeMap::iterator it = blob_change_map_.find(object_store_data_key);
4255 BlobChangeRecord* record = NULL; 4255 BlobChangeRecord* record = NULL;
4256 if (it == blob_change_map_.end()) { 4256 if (it == blob_change_map_.end()) {
4257 record = new BlobChangeRecord(object_store_data_key, object_store_id); 4257 record = new BlobChangeRecord(object_store_data_key, object_store_id);
4258 blob_change_map_[object_store_data_key] = record; 4258 blob_change_map_[object_store_data_key] = record;
(...skipping 24 matching lines...) Expand all
4283 int64_t size, 4283 int64_t size,
4284 base::Time last_modified) 4284 base::Time last_modified)
4285 : is_file_(true), 4285 : is_file_(true),
4286 file_path_(file_path), 4286 file_path_(file_path),
4287 key_(key), 4287 key_(key),
4288 size_(size), 4288 size_(size),
4289 last_modified_(last_modified) { 4289 last_modified_(last_modified) {
4290 } 4290 }
4291 4291
4292 } // namespace content 4292 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698