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

Unified Diff: chrome/browser/media_galleries/chromeos/mtp_device_delegate_impl_chromeos.cc

Issue 2606563002: Remove base::ScopedPtrHashMap from chrome/browser/media_galleries/. (Closed)
Patch Set: Created 4 years 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/media_galleries/chromeos/mtp_device_delegate_impl_chromeos.cc
diff --git a/chrome/browser/media_galleries/chromeos/mtp_device_delegate_impl_chromeos.cc b/chrome/browser/media_galleries/chromeos/mtp_device_delegate_impl_chromeos.cc
index a6d1870f942e85bf2e0ffc8c9be880a685a2439b..ba8cf7586771a560e8e837aafbded6ed3e2defcb 100644
--- a/chrome/browser/media_galleries/chromeos/mtp_device_delegate_impl_chromeos.cc
+++ b/chrome/browser/media_galleries/chromeos/mtp_device_delegate_impl_chromeos.cc
@@ -10,6 +10,7 @@
#include <algorithm>
#include <limits>
+#include <unordered_map>
#include <utility>
#include <vector>
@@ -403,7 +404,7 @@ class MTPDeviceDelegateImplLinux::MTPFileNode {
private:
// Container for holding a node's children.
- typedef base::ScopedPtrHashMap<std::string, std::unique_ptr<MTPFileNode>>
+ typedef std::unordered_map<std::string, std::unique_ptr<MTPFileNode>>
ChildNodes;
const uint32_t file_id_;
@@ -441,7 +442,10 @@ const MTPDeviceDelegateImplLinux::MTPFileNode*
MTPDeviceDelegateImplLinux::MTPFileNode::GetChild(
const std::string& name) const {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- return children_.get(name);
+ auto it = children_.find(name);
+ if (it == children_.end())
+ return nullptr;
+ return it->second.get();
}
void MTPDeviceDelegateImplLinux::MTPFileNode::EnsureChildExists(
@@ -452,30 +456,28 @@ void MTPDeviceDelegateImplLinux::MTPFileNode::EnsureChildExists(
if (child && child->file_id() == id)
return;
- children_.set(name, base::WrapUnique(new MTPFileNode(id, name, this,
- file_id_to_node_map_)));
+ children_[name] =
+ base::WrapUnique(new MTPFileNode(id, name, this, file_id_to_node_map_));
Reilly Grant (use Gerrit) 2016/12/27 16:26:17 base::MakeUnique<MTPFileNode>(id, name, this, file
Avi (use Gerrit) 2016/12/27 21:58:00 Done.
}
void MTPDeviceDelegateImplLinux::MTPFileNode::ClearNonexistentChildren(
const std::set<std::string>& children_to_keep) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
std::set<std::string> children_to_erase;
Reilly Grant (use Gerrit) 2016/12/27 16:26:17 This should be a vector instead of a set.
Avi (use Gerrit) 2016/12/27 21:58:00 Done.
- for (ChildNodes::const_iterator it = children_.begin();
- it != children_.end(); ++it) {
+ for (auto it = children_.begin(); it != children_.end(); ++it) {
if (base::ContainsKey(children_to_keep, it->first))
continue;
children_to_erase.insert(it->first);
}
Reilly Grant (use Gerrit) 2016/12/27 16:26:17 for (const auto& it : children_) { if (base::Con
Avi (use Gerrit) 2016/12/27 21:58:00 push_back. Done.
- for (std::set<std::string>::iterator it = children_to_erase.begin();
- it != children_to_erase.end(); ++it) {
- children_.take_and_erase(*it);
+ for (auto it = children_to_erase.begin(); it != children_to_erase.end();
+ ++it) {
+ children_.erase(*it);
}
Reilly Grant (use Gerrit) 2016/12/27 16:26:17 for (const auto& child : children_to_erase) chil
Avi (use Gerrit) 2016/12/27 21:58:00 Done.
}
bool MTPDeviceDelegateImplLinux::MTPFileNode::DeleteChild(uint32_t file_id) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- for (ChildNodes::iterator it = children_.begin();
- it != children_.end(); ++it) {
+ for (auto it = children_.begin(); it != children_.end(); ++it) {
if (it->second->file_id() == file_id) {
DCHECK(!it->second->HasChildren());
children_.erase(it);
« 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