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

Unified Diff: chrome/browser/chromeos/disks/mock_disk_mount_manager.cc

Issue 10829095: Valgrind/Heapchecker: Fix leak from r149099. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 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/chromeos/disks/mock_disk_mount_manager.cc
===================================================================
--- chrome/browser/chromeos/disks/mock_disk_mount_manager.cc (revision 149119)
+++ chrome/browser/chromeos/disks/mock_disk_mount_manager.cc (working copy)
@@ -4,6 +4,8 @@
#include "chrome/browser/chromeos/disks/mock_disk_mount_manager.h"
+#include <utility>
+
#include "base/message_loop.h"
#include "base/stl_util.h"
#include "base/string_util.h"
@@ -173,8 +175,13 @@
true, // has_media
false, // on_boot_device
false); // is_hidden
- disks_.insert(std::pair<std::string, DiskMountManager::Disk*>(
- std::string(mount_info.source_path), disk));
+ DiskMountManager::DiskMap::iterator it = disks_.find(mount_info.source_path);
+ if (it == disks_.end()) {
+ disks_.insert(std::make_pair(std::string(mount_info.source_path), disk));
+ } else {
+ delete it->second;
+ it->second = disk;
+ }
}
void MockDiskMountManager::RemoveDiskEntryForMountDevice(
@@ -186,9 +193,9 @@
}
}
-void MockDiskMountManager::NotifyDiskChanged(DiskMountManagerEventType event,
- const DiskMountManager::Disk* disk)
-{
+void MockDiskMountManager::NotifyDiskChanged(
+ DiskMountManagerEventType event,
+ const DiskMountManager::Disk* disk) {
// Make sure we run on UI thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
« 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