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

Unified Diff: chrome/browser/extensions/api/dial/dial_registry.cc

Issue 2436403003: [DIAL] Make a copy of device id before erasing device from map. (Closed)
Patch Set: fmt Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/dial/dial_registry.cc
diff --git a/chrome/browser/extensions/api/dial/dial_registry.cc b/chrome/browser/extensions/api/dial/dial_registry.cc
index 3c092bdeee1742acf17179c8ba6810ee9ae31797..f3cbe46ef07475adb6df57c9d42e37b5493ab561 100644
--- a/chrome/browser/extensions/api/dial/dial_registry.cc
+++ b/chrome/browser/extensions/api/dial/dial_registry.cc
@@ -160,8 +160,11 @@ bool DialRegistry::PruneExpiredDevices() {
auto* device = it->second;
if (IsDeviceExpired(*device)) {
VLOG(2) << "Device " << device->label() << " expired, removing";
- const size_t num_erased_by_id =
- device_by_id_map_.erase(device->device_id());
+
+ // Make a copy of the device ID here since |device| will be destroyed
+ // during erase().
+ std::string device_id = device->device_id();
miu 2016/10/22 18:37:19 nit: Probably not a big deal for performance, but
+ const size_t num_erased_by_id = device_by_id_map_.erase(device_id);
Wez 2016/10/22 00:55:39 As discussed offline... wow, really surprised that
DCHECK_EQ(1U, num_erased_by_id);
device_by_label_map_.erase(it++);
pruned_device = true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698