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

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

Issue 405433007: IndexedDB: Fix coding style issues c/o cpplint.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 const base::FilePath& path_base, 857 const base::FilePath& path_base,
858 const GURL& origin_url) { 858 const GURL& origin_url) {
859 const base::FilePath file_path = 859 const base::FilePath file_path =
860 path_base.Append(ComputeFileName(origin_url)); 860 path_base.Append(ComputeFileName(origin_url));
861 DefaultLevelDBFactory leveldb_factory; 861 DefaultLevelDBFactory leveldb_factory;
862 return leveldb_factory.DestroyLevelDB(file_path); 862 return leveldb_factory.DestroyLevelDB(file_path);
863 } 863 }
864 864
865 bool IndexedDBBackingStore::ReadCorruptionInfo(const base::FilePath& path_base, 865 bool IndexedDBBackingStore::ReadCorruptionInfo(const base::FilePath& path_base,
866 const GURL& origin_url, 866 const GURL& origin_url,
867 std::string& message) { 867 std::string* message) {
868 const base::FilePath info_path = 868 const base::FilePath info_path =
869 path_base.Append(ComputeCorruptionFileName(origin_url)); 869 path_base.Append(ComputeCorruptionFileName(origin_url));
870 870
871 if (IsPathTooLong(info_path)) 871 if (IsPathTooLong(info_path))
872 return false; 872 return false;
873 873
874 const int64 max_json_len = 4096; 874 const int64 max_json_len = 4096;
875 int64 file_size(0); 875 int64 file_size(0);
876 if (!GetFileSize(info_path, &file_size) || file_size > max_json_len) 876 if (!GetFileSize(info_path, &file_size) || file_size > max_json_len)
877 return false; 877 return false;
878 if (!file_size) { 878 if (!file_size) {
879 NOTREACHED(); 879 NOTREACHED();
880 return false; 880 return false;
881 } 881 }
882 882
883 base::File file(info_path, base::File::FLAG_OPEN | base::File::FLAG_READ); 883 base::File file(info_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
884 bool success = false; 884 bool success = false;
885 if (file.IsValid()) { 885 if (file.IsValid()) {
886 std::vector<char> bytes(file_size); 886 std::vector<char> bytes(file_size);
887 if (file_size == file.Read(0, &bytes[0], file_size)) { 887 if (file_size == file.Read(0, &bytes[0], file_size)) {
888 std::string input_js(&bytes[0], file_size); 888 std::string input_js(&bytes[0], file_size);
889 base::JSONReader reader; 889 base::JSONReader reader;
890 scoped_ptr<base::Value> val(reader.ReadToValue(input_js)); 890 scoped_ptr<base::Value> val(reader.ReadToValue(input_js));
891 if (val && val->GetType() == base::Value::TYPE_DICTIONARY) { 891 if (val && val->GetType() == base::Value::TYPE_DICTIONARY) {
892 base::DictionaryValue* dict_val = 892 base::DictionaryValue* dict_val =
893 static_cast<base::DictionaryValue*>(val.get()); 893 static_cast<base::DictionaryValue*>(val.get());
894 success = dict_val->GetString("message", &message); 894 success = dict_val->GetString("message", message);
895 } 895 }
896 } 896 }
897 file.Close(); 897 file.Close();
898 } 898 }
899 899
900 base::DeleteFile(info_path, false); 900 base::DeleteFile(info_path, false);
901 901
902 return success; 902 return success;
903 } 903 }
904 904
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 *is_disk_full = true; 983 *is_disk_full = true;
984 } else if (leveldb_env::IsCorruption(*status)) { 984 } else if (leveldb_env::IsCorruption(*status)) {
985 *data_loss = blink::WebIDBDataLossTotal; 985 *data_loss = blink::WebIDBDataLossTotal;
986 *data_loss_message = leveldb_env::GetCorruptionMessage(*status); 986 *data_loss_message = leveldb_env::GetCorruptionMessage(*status);
987 } 987 }
988 } 988 }
989 989
990 bool is_schema_known = false; 990 bool is_schema_known = false;
991 if (db) { 991 if (db) {
992 std::string corruption_message; 992 std::string corruption_message;
993 if (ReadCorruptionInfo(path_base, origin_url, corruption_message)) { 993 if (ReadCorruptionInfo(path_base, origin_url, &corruption_message)) {
994 LOG(ERROR) << "IndexedDB recovering from a corrupted (and deleted) " 994 LOG(ERROR) << "IndexedDB recovering from a corrupted (and deleted) "
995 "database."; 995 "database.";
996 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_FAILED_PRIOR_CORRUPTION, 996 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_FAILED_PRIOR_CORRUPTION,
997 origin_url); 997 origin_url);
998 db.reset(); 998 db.reset();
999 *data_loss = blink::WebIDBDataLossTotal; 999 *data_loss = blink::WebIDBDataLossTotal;
1000 *data_loss_message = 1000 *data_loss_message =
1001 "IndexedDB (database was corrupt): " + corruption_message; 1001 "IndexedDB (database was corrupt): " + corruption_message;
1002 } else if (!IsSchemaKnown(db.get(), &is_schema_known)) { 1002 } else if (!IsSchemaKnown(db.get(), &is_schema_known)) {
1003 LOG(ERROR) << "IndexedDB had IO error checking schema, treating it as " 1003 LOG(ERROR) << "IndexedDB had IO error checking schema, treating it as "
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 1866
1867 *new_version_number = version; 1867 *new_version_number = version;
1868 return s; 1868 return s;
1869 } 1869 }
1870 1870
1871 leveldb::Status IndexedDBBackingStore::PutRecord( 1871 leveldb::Status IndexedDBBackingStore::PutRecord(
1872 IndexedDBBackingStore::Transaction* transaction, 1872 IndexedDBBackingStore::Transaction* transaction,
1873 int64 database_id, 1873 int64 database_id,
1874 int64 object_store_id, 1874 int64 object_store_id,
1875 const IndexedDBKey& key, 1875 const IndexedDBKey& key,
1876 IndexedDBValue& value, 1876 IndexedDBValue* value,
1877 ScopedVector<webkit_blob::BlobDataHandle>* handles, 1877 ScopedVector<webkit_blob::BlobDataHandle>* handles,
1878 RecordIdentifier* record_identifier) { 1878 RecordIdentifier* record_identifier) {
1879 IDB_TRACE("IndexedDBBackingStore::PutRecord"); 1879 IDB_TRACE("IndexedDBBackingStore::PutRecord");
1880 if (!KeyPrefix::ValidIds(database_id, object_store_id)) 1880 if (!KeyPrefix::ValidIds(database_id, object_store_id))
1881 return InvalidDBKeyStatus(); 1881 return InvalidDBKeyStatus();
1882 DCHECK(key.IsValid()); 1882 DCHECK(key.IsValid());
1883 1883
1884 LevelDBTransaction* leveldb_transaction = transaction->transaction(); 1884 LevelDBTransaction* leveldb_transaction = transaction->transaction();
1885 int64 version = -1; 1885 int64 version = -1;
1886 leveldb::Status s = GetNewVersionNumber( 1886 leveldb::Status s = GetNewVersionNumber(
1887 leveldb_transaction, database_id, object_store_id, &version); 1887 leveldb_transaction, database_id, object_store_id, &version);
1888 if (!s.ok()) 1888 if (!s.ok())
1889 return s; 1889 return s;
1890 DCHECK_GE(version, 0); 1890 DCHECK_GE(version, 0);
1891 const std::string object_store_data_key = 1891 const std::string object_store_data_key =
1892 ObjectStoreDataKey::Encode(database_id, object_store_id, key); 1892 ObjectStoreDataKey::Encode(database_id, object_store_id, key);
1893 1893
1894 std::string v; 1894 std::string v;
1895 EncodeVarInt(version, &v); 1895 EncodeVarInt(version, &v);
1896 v.append(value.bits); 1896 v.append(value->bits);
1897 1897
1898 leveldb_transaction->Put(object_store_data_key, &v); 1898 leveldb_transaction->Put(object_store_data_key, &v);
1899 s = transaction->PutBlobInfoIfNeeded(database_id, 1899 s = transaction->PutBlobInfoIfNeeded(database_id,
1900 object_store_id, 1900 object_store_id,
1901 object_store_data_key, 1901 object_store_data_key,
1902 &value.blob_info, 1902 &value->blob_info,
1903 handles); 1903 handles);
1904 if (!s.ok()) 1904 if (!s.ok())
1905 return s; 1905 return s;
1906 DCHECK(!handles->size()); 1906 DCHECK(!handles->size());
1907 1907
1908 const std::string exists_entry_key = 1908 const std::string exists_entry_key =
1909 ExistsEntryKey::Encode(database_id, object_store_id, key); 1909 ExistsEntryKey::Encode(database_id, object_store_id, key);
1910 std::string version_encoded; 1910 std::string version_encoded;
1911 EncodeInt(version, &version_encoded); 1911 EncodeInt(version, &version_encoded);
1912 leveldb_transaction->Put(exists_entry_key, &version_encoded); 1912 leveldb_transaction->Put(exists_entry_key, &version_encoded);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 } 2166 }
2167 2167
2168 class IndexedDBBackingStore::Transaction::ChainedBlobWriterImpl 2168 class IndexedDBBackingStore::Transaction::ChainedBlobWriterImpl
2169 : public IndexedDBBackingStore::Transaction::ChainedBlobWriter { 2169 : public IndexedDBBackingStore::Transaction::ChainedBlobWriter {
2170 public: 2170 public:
2171 typedef IndexedDBBackingStore::Transaction::WriteDescriptorVec 2171 typedef IndexedDBBackingStore::Transaction::WriteDescriptorVec
2172 WriteDescriptorVec; 2172 WriteDescriptorVec;
2173 ChainedBlobWriterImpl( 2173 ChainedBlobWriterImpl(
2174 int64 database_id, 2174 int64 database_id,
2175 IndexedDBBackingStore* backing_store, 2175 IndexedDBBackingStore* backing_store,
2176 WriteDescriptorVec& blobs, 2176 WriteDescriptorVec* blobs,
2177 scoped_refptr<IndexedDBBackingStore::BlobWriteCallback> callback) 2177 scoped_refptr<IndexedDBBackingStore::BlobWriteCallback> callback)
2178 : waiting_for_callback_(false), 2178 : waiting_for_callback_(false),
2179 database_id_(database_id), 2179 database_id_(database_id),
2180 backing_store_(backing_store), 2180 backing_store_(backing_store),
2181 callback_(callback), 2181 callback_(callback),
2182 aborted_(false) { 2182 aborted_(false) {
2183 blobs_.swap(blobs); 2183 blobs_.swap(*blobs);
2184 iter_ = blobs_.begin(); 2184 iter_ = blobs_.begin();
2185 backing_store->task_runner()->PostTask( 2185 backing_store->task_runner()->PostTask(
2186 FROM_HERE, base::Bind(&ChainedBlobWriterImpl::WriteNextFile, this)); 2186 FROM_HERE, base::Bind(&ChainedBlobWriterImpl::WriteNextFile, this));
2187 } 2187 }
2188 2188
2189 virtual void set_delegate(scoped_ptr<FileWriterDelegate> delegate) OVERRIDE { 2189 virtual void set_delegate(scoped_ptr<FileWriterDelegate> delegate) OVERRIDE {
2190 delegate_.reset(delegate.release()); 2190 delegate_.reset(delegate.release());
2191 } 2191 }
2192 2192
2193 virtual void ReportWriteCompletion(bool succeeded, 2193 virtual void ReportWriteCompletion(bool succeeded,
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2802 EncodeVarInt(record_identifier.version(), &data); 2802 EncodeVarInt(record_identifier.version(), &data);
2803 data.append(record_identifier.primary_key()); 2803 data.append(record_identifier.primary_key());
2804 2804
2805 transaction->transaction()->Put(index_data_key, &data); 2805 transaction->transaction()->Put(index_data_key, &data);
2806 return leveldb::Status::OK(); 2806 return leveldb::Status::OK();
2807 } 2807 }
2808 2808
2809 static bool FindGreatestKeyLessThanOrEqual(LevelDBTransaction* transaction, 2809 static bool FindGreatestKeyLessThanOrEqual(LevelDBTransaction* transaction,
2810 const std::string& target, 2810 const std::string& target,
2811 std::string* found_key, 2811 std::string* found_key,
2812 leveldb::Status& s) { 2812 leveldb::Status* s) {
2813 scoped_ptr<LevelDBIterator> it = transaction->CreateIterator(); 2813 scoped_ptr<LevelDBIterator> it = transaction->CreateIterator();
2814 s = it->Seek(target); 2814 *s = it->Seek(target);
2815 if (!s.ok()) 2815 if (!s->ok())
2816 return false; 2816 return false;
2817 2817
2818 if (!it->IsValid()) { 2818 if (!it->IsValid()) {
2819 s = it->SeekToLast(); 2819 *s = it->SeekToLast();
2820 if (!s.ok() || !it->IsValid()) 2820 if (!s->ok() || !it->IsValid())
2821 return false; 2821 return false;
2822 } 2822 }
2823 2823
2824 while (CompareIndexKeys(it->Key(), target) > 0) { 2824 while (CompareIndexKeys(it->Key(), target) > 0) {
2825 s = it->Prev(); 2825 *s = it->Prev();
2826 if (!s.ok() || !it->IsValid()) 2826 if (!s->ok() || !it->IsValid())
2827 return false; 2827 return false;
2828 } 2828 }
2829 2829
2830 do { 2830 do {
2831 *found_key = it->Key().as_string(); 2831 *found_key = it->Key().as_string();
2832 2832
2833 // There can be several index keys that compare equal. We want the last one. 2833 // There can be several index keys that compare equal. We want the last one.
2834 s = it->Next(); 2834 *s = it->Next();
2835 } while (s.ok() && it->IsValid() && !CompareIndexKeys(it->Key(), target)); 2835 } while (s->ok() && it->IsValid() && !CompareIndexKeys(it->Key(), target));
2836 2836
2837 return true; 2837 return true;
2838 } 2838 }
2839 2839
2840 static leveldb::Status VersionExists(LevelDBTransaction* transaction, 2840 static leveldb::Status VersionExists(LevelDBTransaction* transaction,
2841 int64 database_id, 2841 int64 database_id,
2842 int64 object_store_id, 2842 int64 object_store_id,
2843 int64 version, 2843 int64 version,
2844 const std::string& encoded_primary_key, 2844 const std::string& encoded_primary_key,
2845 bool* exists) { 2845 bool* exists) {
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
3619 ObjectStoreDataKey::Encode(database_id, object_store_id, MaxIDBKey()); 3619 ObjectStoreDataKey::Encode(database_id, object_store_id, MaxIDBKey());
3620 3620
3621 if (cursor_options->forward) { 3621 if (cursor_options->forward) {
3622 cursor_options->high_open = true; // Not included. 3622 cursor_options->high_open = true; // Not included.
3623 } else { 3623 } else {
3624 // We need a key that exists. 3624 // We need a key that exists.
3625 // TODO(cmumford): Handle this error (crbug.com/363397) 3625 // TODO(cmumford): Handle this error (crbug.com/363397)
3626 if (!FindGreatestKeyLessThanOrEqual(transaction, 3626 if (!FindGreatestKeyLessThanOrEqual(transaction,
3627 cursor_options->high_key, 3627 cursor_options->high_key,
3628 &cursor_options->high_key, 3628 &cursor_options->high_key,
3629 s)) 3629 &s))
3630 return false; 3630 return false;
3631 cursor_options->high_open = false; 3631 cursor_options->high_open = false;
3632 } 3632 }
3633 } else { 3633 } else {
3634 cursor_options->high_key = 3634 cursor_options->high_key =
3635 ObjectStoreDataKey::Encode(database_id, object_store_id, range.upper()); 3635 ObjectStoreDataKey::Encode(database_id, object_store_id, range.upper());
3636 cursor_options->high_open = range.upperOpen(); 3636 cursor_options->high_open = range.upperOpen();
3637 3637
3638 if (!cursor_options->forward) { 3638 if (!cursor_options->forward) {
3639 // For reverse cursors, we need a key that exists. 3639 // For reverse cursors, we need a key that exists.
3640 std::string found_high_key; 3640 std::string found_high_key;
3641 // TODO(cmumford): Handle this error (crbug.com/363397) 3641 // TODO(cmumford): Handle this error (crbug.com/363397)
3642 if (!FindGreatestKeyLessThanOrEqual( 3642 if (!FindGreatestKeyLessThanOrEqual(
3643 transaction, cursor_options->high_key, &found_high_key, s)) 3643 transaction, cursor_options->high_key, &found_high_key, &s))
3644 return false; 3644 return false;
3645 3645
3646 // If the target key should not be included, but we end up with a smaller 3646 // If the target key should not be included, but we end up with a smaller
3647 // key, we should include that. 3647 // key, we should include that.
3648 if (cursor_options->high_open && 3648 if (cursor_options->high_open &&
3649 CompareIndexKeys(found_high_key, cursor_options->high_key) < 0) 3649 CompareIndexKeys(found_high_key, cursor_options->high_key) < 0)
3650 cursor_options->high_open = false; 3650 cursor_options->high_open = false;
3651 3651
3652 cursor_options->high_key = found_high_key; 3652 cursor_options->high_key = found_high_key;
3653 } 3653 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3695 3695
3696 if (!upper_bound) { 3696 if (!upper_bound) {
3697 cursor_options->high_key = 3697 cursor_options->high_key =
3698 IndexDataKey::EncodeMaxKey(database_id, object_store_id, index_id); 3698 IndexDataKey::EncodeMaxKey(database_id, object_store_id, index_id);
3699 cursor_options->high_open = false; // Included. 3699 cursor_options->high_open = false; // Included.
3700 3700
3701 if (!cursor_options->forward) { // We need a key that exists. 3701 if (!cursor_options->forward) { // We need a key that exists.
3702 if (!FindGreatestKeyLessThanOrEqual(transaction, 3702 if (!FindGreatestKeyLessThanOrEqual(transaction,
3703 cursor_options->high_key, 3703 cursor_options->high_key,
3704 &cursor_options->high_key, 3704 &cursor_options->high_key,
3705 s)) 3705 &s))
3706 return false; 3706 return false;
3707 cursor_options->high_open = false; 3707 cursor_options->high_open = false;
3708 } 3708 }
3709 } else { 3709 } else {
3710 cursor_options->high_key = IndexDataKey::Encode( 3710 cursor_options->high_key = IndexDataKey::Encode(
3711 database_id, object_store_id, index_id, range.upper()); 3711 database_id, object_store_id, index_id, range.upper());
3712 cursor_options->high_open = range.upperOpen(); 3712 cursor_options->high_open = range.upperOpen();
3713 3713
3714 std::string found_high_key; 3714 std::string found_high_key;
3715 // Seek to the *last* key in the set of non-unique keys 3715 // Seek to the *last* key in the set of non-unique keys
3716 // TODO(cmumford): Handle this error (crbug.com/363397) 3716 // TODO(cmumford): Handle this error (crbug.com/363397)
3717 if (!FindGreatestKeyLessThanOrEqual( 3717 if (!FindGreatestKeyLessThanOrEqual(
3718 transaction, cursor_options->high_key, &found_high_key, s)) 3718 transaction, cursor_options->high_key, &found_high_key, &s))
3719 return false; 3719 return false;
3720 3720
3721 // If the target key should not be included, but we end up with a smaller 3721 // If the target key should not be included, but we end up with a smaller
3722 // key, we should include that. 3722 // key, we should include that.
3723 if (cursor_options->high_open && 3723 if (cursor_options->high_open &&
3724 CompareIndexKeys(found_high_key, cursor_options->high_key) < 0) 3724 CompareIndexKeys(found_high_key, cursor_options->high_key) < 0)
3725 cursor_options->high_open = false; 3725 cursor_options->high_open = false;
3726 3726
3727 cursor_options->high_key = found_high_key; 3727 cursor_options->high_key = found_high_key;
3728 } 3728 }
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
4032 KeyPrefix::IsValidDatabaseId(database_id_)); 4032 KeyPrefix::IsValidDatabaseId(database_id_));
4033 if (!CollectBlobFilesToRemove()) { 4033 if (!CollectBlobFilesToRemove()) {
4034 INTERNAL_WRITE_ERROR_UNTESTED(TRANSACTION_COMMIT_METHOD); 4034 INTERNAL_WRITE_ERROR_UNTESTED(TRANSACTION_COMMIT_METHOD);
4035 transaction_ = NULL; 4035 transaction_ = NULL;
4036 return InternalInconsistencyStatus(); 4036 return InternalInconsistencyStatus();
4037 } 4037 }
4038 4038
4039 if (new_files_to_write.size()) { 4039 if (new_files_to_write.size()) {
4040 // This kicks off the writes of the new blobs, if any. 4040 // This kicks off the writes of the new blobs, if any.
4041 // This call will zero out new_blob_entries and new_files_to_write. 4041 // This call will zero out new_blob_entries and new_files_to_write.
4042 WriteNewBlobs(new_blob_entries, new_files_to_write, callback); 4042 WriteNewBlobs(&new_blob_entries, &new_files_to_write, callback);
4043 // Remove the add journal, if any; once the blobs are written, and we 4043 // Remove the add journal, if any; once the blobs are written, and we
4044 // commit, this will do the cleanup. 4044 // commit, this will do the cleanup.
4045 ClearBlobJournal(transaction_.get(), BlobJournalKey::Encode()); 4045 ClearBlobJournal(transaction_.get(), BlobJournalKey::Encode());
4046 } else { 4046 } else {
4047 callback->Run(true); 4047 callback->Run(true);
4048 } 4048 }
4049 4049
4050 return leveldb::Status::OK(); 4050 return leveldb::Status::OK();
4051 } 4051 }
4052 4052
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
4106 virtual ~BlobWriteCallbackWrapper() {} 4106 virtual ~BlobWriteCallbackWrapper() {}
4107 friend class base::RefCounted<IndexedDBBackingStore::BlobWriteCallback>; 4107 friend class base::RefCounted<IndexedDBBackingStore::BlobWriteCallback>;
4108 4108
4109 IndexedDBBackingStore::Transaction* transaction_; 4109 IndexedDBBackingStore::Transaction* transaction_;
4110 scoped_refptr<BlobWriteCallback> callback_; 4110 scoped_refptr<BlobWriteCallback> callback_;
4111 4111
4112 DISALLOW_COPY_AND_ASSIGN(BlobWriteCallbackWrapper); 4112 DISALLOW_COPY_AND_ASSIGN(BlobWriteCallbackWrapper);
4113 }; 4113 };
4114 4114
4115 void IndexedDBBackingStore::Transaction::WriteNewBlobs( 4115 void IndexedDBBackingStore::Transaction::WriteNewBlobs(
4116 BlobEntryKeyValuePairVec& new_blob_entries, 4116 BlobEntryKeyValuePairVec* new_blob_entries,
4117 WriteDescriptorVec& new_files_to_write, 4117 WriteDescriptorVec* new_files_to_write,
4118 scoped_refptr<BlobWriteCallback> callback) { 4118 scoped_refptr<BlobWriteCallback> callback) {
4119 DCHECK_GT(new_files_to_write.size(), 0UL); 4119 DCHECK_GT(new_files_to_write->size(), 0UL);
4120 DCHECK_GT(database_id_, 0); 4120 DCHECK_GT(database_id_, 0);
4121 BlobEntryKeyValuePairVec::iterator blob_entry_iter; 4121 BlobEntryKeyValuePairVec::iterator blob_entry_iter;
4122 for (blob_entry_iter = new_blob_entries.begin(); 4122 for (blob_entry_iter = new_blob_entries->begin();
4123 blob_entry_iter != new_blob_entries.end(); 4123 blob_entry_iter != new_blob_entries->end();
4124 ++blob_entry_iter) { 4124 ++blob_entry_iter) {
4125 // Add the new blob-table entry for each blob to the main transaction, or 4125 // Add the new blob-table entry for each blob to the main transaction, or
4126 // remove any entry that may exist if there's no new one. 4126 // remove any entry that may exist if there's no new one.
4127 if (!blob_entry_iter->second.size()) 4127 if (!blob_entry_iter->second.size())
4128 transaction_->Remove(blob_entry_iter->first.Encode()); 4128 transaction_->Remove(blob_entry_iter->first.Encode());
4129 else 4129 else
4130 transaction_->Put(blob_entry_iter->first.Encode(), 4130 transaction_->Put(blob_entry_iter->first.Encode(),
4131 &blob_entry_iter->second); 4131 &blob_entry_iter->second);
4132 } 4132 }
4133 // Creating the writer will start it going asynchronously. 4133 // Creating the writer will start it going asynchronously.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
4258 int64_t size, 4258 int64_t size,
4259 base::Time last_modified) 4259 base::Time last_modified)
4260 : is_file_(true), 4260 : is_file_(true),
4261 file_path_(file_path), 4261 file_path_(file_path),
4262 key_(key), 4262 key_(key),
4263 size_(size), 4263 size_(size),
4264 last_modified_(last_modified) { 4264 last_modified_(last_modified) {
4265 } 4265 }
4266 4266
4267 } // namespace content 4267 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_backing_store.h ('k') | content/browser/indexed_db/indexed_db_backing_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698