Chromium Code Reviews| Index: content/browser/indexed_db/indexed_db_backing_store.cc |
| diff --git a/content/browser/indexed_db/indexed_db_backing_store.cc b/content/browser/indexed_db/indexed_db_backing_store.cc |
| index 56543bf966aeb1ce14bb64b316c16d43c00a959d..c0d44908309fca7130529fe4f558f37088955509 100644 |
| --- a/content/browser/indexed_db/indexed_db_backing_store.cc |
| +++ b/content/browser/indexed_db/indexed_db_backing_store.cc |
| @@ -14,6 +14,7 @@ |
| #include "base/json/json_writer.h" |
| #include "base/logging.h" |
| #include "base/macros.h" |
| +#include "base/memory/ptr_util.h" |
| #include "base/metrics/histogram.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/stringprintf.h" |
| @@ -770,8 +771,7 @@ IndexedDBBackingStore::~IndexedDBBackingStore() { |
| for (const auto& pid : child_process_ids_granted_) |
| policy->RevokeAllPermissionsForFile(pid, blob_path_); |
| } |
| - base::STLDeleteContainerPairSecondPointers(incognito_blob_map_.begin(), |
| - incognito_blob_map_.end()); |
| + incognito_blob_map_.clear(); |
| // db_'s destructor uses comparator_. The order of destruction is important. |
| db_.reset(); |
| comparator_.reset(); |
| @@ -2707,11 +2707,11 @@ leveldb::Status IndexedDBBackingStore::Transaction::GetBlobInfoForRecord( |
| BlobChangeRecord* change_record = NULL; |
| auto blob_iter = blob_change_map_.find(object_store_data_key); |
| if (blob_iter != blob_change_map_.end()) { |
| - change_record = blob_iter->second; |
| + change_record = blob_iter->second.get(); |
| } else { |
| blob_iter = incognito_blob_map_.find(object_store_data_key); |
| if (blob_iter != incognito_blob_map_.end()) |
| - change_record = blob_iter->second; |
| + change_record = blob_iter->second.get(); |
| } |
| if (change_record) { |
| // Either we haven't written the blob to disk yet or we're in incognito |
| @@ -4006,10 +4006,8 @@ IndexedDBBackingStore::Transaction::Transaction( |
| } |
| IndexedDBBackingStore::Transaction::~Transaction() { |
| - base::STLDeleteContainerPairSecondPointers(blob_change_map_.begin(), |
| - blob_change_map_.end()); |
| - base::STLDeleteContainerPairSecondPointers(incognito_blob_map_.begin(), |
| - incognito_blob_map_.end()); |
| + blob_change_map_.clear(); |
| + incognito_blob_map_.clear(); |
| DCHECK(!committing_); |
| } |
| @@ -4022,7 +4020,7 @@ void IndexedDBBackingStore::Transaction::Begin() { |
| // If incognito, this snapshots blobs just as the above transaction_ |
| // constructor snapshots the leveldb. |
| for (const auto& iter : backing_store_->incognito_blob_map_) |
| - incognito_blob_map_[iter.first] = iter.second->Clone().release(); |
| + incognito_blob_map_[iter.first] = iter.second->Clone(); |
| } |
| static GURL GetURLFromUUID(const string& uuid) { |
| @@ -4247,12 +4245,10 @@ leveldb::Status IndexedDBBackingStore::Transaction::CommitPhaseTwo() { |
| for (auto& iter : blob_change_map_) { |
| auto target_record = target_map.find(iter.first); |
| if (target_record != target_map.end()) { |
| - delete target_record->second; |
| target_map.erase(target_record); |
| } |
| if (iter.second) { |
| - target_map[iter.first] = iter.second; |
| - iter.second = NULL; |
| + target_map[iter.first] = std::move(iter.second); |
| } |
|
ncarter (slow)
2016/08/15 21:51:33
It seems like this can be further simplified (mayb
Avi (use Gerrit)
2016/08/15 23:46:49
Yes, I'm convinced your rewrite is correct; going
|
| } |
| } |
| @@ -4432,9 +4428,9 @@ void IndexedDBBackingStore::Transaction::PutBlobInfo( |
| BlobChangeRecord* record = NULL; |
| if (it == blob_change_map_.end()) { |
| record = new BlobChangeRecord(object_store_data_key, object_store_id); |
| - blob_change_map_[object_store_data_key] = record; |
| + blob_change_map_[object_store_data_key] = base::WrapUnique(record); |
| } else { |
| - record = it->second; |
| + record = it->second.get(); |
| } |
| DCHECK_EQ(record->object_store_id(), object_store_id); |
| record->SetBlobInfo(blob_info); |