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

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

Issue 322203004: Speed up IDB by trimming down the BlobChangeMaps. Check to see if we need each (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « content/browser/indexed_db/indexed_db_backing_store.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.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 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 return s; 1877 return s;
1878 DCHECK_GE(version, 0); 1878 DCHECK_GE(version, 0);
1879 const std::string object_store_data_key = 1879 const std::string object_store_data_key =
1880 ObjectStoreDataKey::Encode(database_id, object_store_id, key); 1880 ObjectStoreDataKey::Encode(database_id, object_store_id, key);
1881 1881
1882 std::string v; 1882 std::string v;
1883 EncodeVarInt(version, &v); 1883 EncodeVarInt(version, &v);
1884 v.append(value.bits); 1884 v.append(value.bits);
1885 1885
1886 leveldb_transaction->Put(object_store_data_key, &v); 1886 leveldb_transaction->Put(object_store_data_key, &v);
1887 transaction->PutBlobInfo(database_id, 1887 s = transaction->PutBlobInfoIfNeeded(database_id,
1888 object_store_id, 1888 object_store_id,
1889 object_store_data_key, 1889 object_store_data_key,
1890 &value.blob_info, 1890 &value.blob_info,
1891 handles); 1891 handles);
1892 if (!s.ok())
1893 return s;
1892 DCHECK(!handles->size()); 1894 DCHECK(!handles->size());
1893 1895
1894 const std::string exists_entry_key = 1896 const std::string exists_entry_key =
1895 ExistsEntryKey::Encode(database_id, object_store_id, key); 1897 ExistsEntryKey::Encode(database_id, object_store_id, key);
1896 std::string version_encoded; 1898 std::string version_encoded;
1897 EncodeInt(version, &version_encoded); 1899 EncodeInt(version, &version_encoded);
1898 leveldb_transaction->Put(exists_entry_key, &version_encoded); 1900 leveldb_transaction->Put(exists_entry_key, &version_encoded);
1899 1901
1900 std::string key_encoded; 1902 std::string key_encoded;
1901 EncodeIDBKey(key, &key_encoded); 1903 EncodeIDBKey(key, &key_encoded);
(...skipping 28 matching lines...) Expand all
1930 int64 object_store_id, 1932 int64 object_store_id,
1931 const RecordIdentifier& record_identifier) { 1933 const RecordIdentifier& record_identifier) {
1932 IDB_TRACE("IndexedDBBackingStore::DeleteRecord"); 1934 IDB_TRACE("IndexedDBBackingStore::DeleteRecord");
1933 if (!KeyPrefix::ValidIds(database_id, object_store_id)) 1935 if (!KeyPrefix::ValidIds(database_id, object_store_id))
1934 return InvalidDBKeyStatus(); 1936 return InvalidDBKeyStatus();
1935 LevelDBTransaction* leveldb_transaction = transaction->transaction(); 1937 LevelDBTransaction* leveldb_transaction = transaction->transaction();
1936 1938
1937 const std::string object_store_data_key = ObjectStoreDataKey::Encode( 1939 const std::string object_store_data_key = ObjectStoreDataKey::Encode(
1938 database_id, object_store_id, record_identifier.primary_key()); 1940 database_id, object_store_id, record_identifier.primary_key());
1939 leveldb_transaction->Remove(object_store_data_key); 1941 leveldb_transaction->Remove(object_store_data_key);
1940 transaction->PutBlobInfo( 1942 leveldb::Status s = transaction->PutBlobInfoIfNeeded(
1941 database_id, object_store_id, object_store_data_key, NULL, NULL); 1943 database_id, object_store_id, object_store_data_key, NULL, NULL);
1944 if (!s.ok())
1945 return s;
1942 1946
1943 const std::string exists_entry_key = ExistsEntryKey::Encode( 1947 const std::string exists_entry_key = ExistsEntryKey::Encode(
1944 database_id, object_store_id, record_identifier.primary_key()); 1948 database_id, object_store_id, record_identifier.primary_key());
1945 leveldb_transaction->Remove(exists_entry_key); 1949 leveldb_transaction->Remove(exists_entry_key);
1946 return leveldb::Status::OK(); 1950 return leveldb::Status::OK();
1947 } 1951 }
1948 1952
1949 leveldb::Status IndexedDBBackingStore::DeleteRange( 1953 leveldb::Status IndexedDBBackingStore::DeleteRange(
1950 IndexedDBBackingStore::Transaction* transaction, 1954 IndexedDBBackingStore::Transaction* transaction,
1951 int64 database_id, 1955 int64 database_id,
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after
4138 scoped_ptr<IndexedDBBackingStore::BlobChangeRecord> record( 4142 scoped_ptr<IndexedDBBackingStore::BlobChangeRecord> record(
4139 new BlobChangeRecord(key_, object_store_id_)); 4143 new BlobChangeRecord(key_, object_store_id_));
4140 record->blob_info_ = blob_info_; 4144 record->blob_info_ = blob_info_;
4141 4145
4142 ScopedVector<webkit_blob::BlobDataHandle>::const_iterator iter; 4146 ScopedVector<webkit_blob::BlobDataHandle>::const_iterator iter;
4143 for (iter = handles_.begin(); iter != handles_.end(); ++iter) 4147 for (iter = handles_.begin(); iter != handles_.end(); ++iter)
4144 record->handles_.push_back(new webkit_blob::BlobDataHandle(**iter)); 4148 record->handles_.push_back(new webkit_blob::BlobDataHandle(**iter));
4145 return record.Pass(); 4149 return record.Pass();
4146 } 4150 }
4147 4151
4152 leveldb::Status IndexedDBBackingStore::Transaction::PutBlobInfoIfNeeded(
4153 int64 database_id,
4154 int64 object_store_id,
4155 const std::string& object_store_data_key,
4156 std::vector<IndexedDBBlobInfo>* blob_info,
4157 ScopedVector<webkit_blob::BlobDataHandle>* handles) {
4158 if (!blob_info || blob_info->empty()) {
4159 blob_change_map_.erase(object_store_data_key);
4160 incognito_blob_map_.erase(object_store_data_key);
4161
4162 BlobEntryKey blob_entry_key;
4163 StringPiece leveldb_key_piece(object_store_data_key);
4164 if (!BlobEntryKey::FromObjectStoreDataKey(&leveldb_key_piece,
4165 &blob_entry_key)) {
4166 NOTREACHED();
4167 return InternalInconsistencyStatus();
4168 }
4169 scoped_ptr<LevelDBIterator> it = transaction()->CreateIterator();
jsbell 2014/06/10 22:16:32 Why an iterator instead of just a Get?
ericu 2014/06/10 22:30:48 Copypasta. Fixed.
4170 std::string encoded_key = blob_entry_key.Encode();
4171 leveldb::Status s = it->Seek(encoded_key);
4172 if (!s.ok())
4173 return s;
4174 if (!it->IsValid() || CompareKeys(it->Key(), encoded_key) != 0)
4175 return leveldb::Status::OK();
4176 }
4177 PutBlobInfo(
4178 database_id, object_store_id, object_store_data_key, blob_info, handles);
4179 return leveldb::Status::OK();
4180 }
4181
4148 // This is storing an info, even if empty, even if the previous key had no blob 4182 // This is storing an info, even if empty, even if the previous key had no blob
4149 // info that we know of. It duplicates a bunch of information stored in the 4183 // info that we know of. It duplicates a bunch of information stored in the
4150 // leveldb transaction, but only w.r.t. the user keys altered--we don't keep the 4184 // leveldb transaction, but only w.r.t. the user keys altered--we don't keep the
4151 // changes to exists or index keys here. 4185 // changes to exists or index keys here.
4152 void IndexedDBBackingStore::Transaction::PutBlobInfo( 4186 void IndexedDBBackingStore::Transaction::PutBlobInfo(
4153 int64 database_id, 4187 int64 database_id,
4154 int64 object_store_id, 4188 int64 object_store_id,
4155 const std::string& object_store_data_key, 4189 const std::string& object_store_data_key,
4156 std::vector<IndexedDBBlobInfo>* blob_info, 4190 std::vector<IndexedDBBlobInfo>* blob_info,
4157 ScopedVector<webkit_blob::BlobDataHandle>* handles) { 4191 ScopedVector<webkit_blob::BlobDataHandle>* handles) {
(...skipping 20 matching lines...) Expand all
4178 const GURL& url, 4212 const GURL& url,
4179 int64_t key) 4213 int64_t key)
4180 : is_file_(false), url_(url), key_(key) {} 4214 : is_file_(false), url_(url), key_(key) {}
4181 4215
4182 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor( 4216 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor(
4183 const FilePath& file_path, 4217 const FilePath& file_path,
4184 int64_t key) 4218 int64_t key)
4185 : is_file_(true), file_path_(file_path), key_(key) {} 4219 : is_file_(true), file_path_(file_path), key_(key) {}
4186 4220
4187 } // namespace content 4221 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_backing_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698