Remove base::ScopedPtrHashMap from ozone.

BUG=579229

Review-Url: https://codereview.chromium.org/2603863002
Cr-Commit-Position: refs/heads/master@{#441049}
diff --git a/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc b/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc
index 0a4cf0b..e445f1a 100644
--- a/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc
+++ b/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc
@@ -11,6 +11,7 @@
 #include <string.h>
 
 #include <algorithm>
+#include <unordered_map>
 
 #include "base/containers/hash_tables.h"
 #include "base/files/file_enumerator.h"
@@ -609,12 +610,6 @@
 namespace ui {
 namespace internal {
 
-// Mapping table from a property name to its corresponding GesturesProp
-// object pointer.
-typedef base::hash_map<std::string, GesturesProp*> PropertiesMap;
-typedef base::ScopedPtrHashMap<std::string, std::unique_ptr<GesturesProp>>
-    ScopedPropertiesMap;
-
 // Struct holding properties of a device.
 //
 // Note that we can't define it in GesturePropertyProvider as a nested class
@@ -625,12 +620,12 @@
   GestureDevicePropertyData() {}
 
   // Properties owned and being used by the device.
-  ScopedPropertiesMap properties;
+  std::unordered_map<std::string, std::unique_ptr<GesturesProp>> properties;
 
   // Unowned default properties (owned by the configuration file). Their values
   // will be applied when a property of the same name is created. These are
   // usually only a small portion of all properties in use.
-  PropertiesMap default_properties;
+  base::hash_map<std::string, GesturesProp*> default_properties;
 };
 
 // Base class for device match criterias in conf files.
@@ -875,8 +870,7 @@
     const EventDeviceType type,
     std::vector<DeviceId>* device_ids) {
   bool exists = false;
-  DeviceMap::const_iterator it = device_map_.begin();
-  for (; it != device_map_.end(); ++it) {
+  for (auto it = device_map_.begin(); it != device_map_.end(); ++it) {
     if (IsDeviceIdOfType(it->first, type)) {
       exists = true;
       if (device_ids)
@@ -888,7 +882,7 @@
 
 bool GesturePropertyProvider::IsDeviceIdOfType(const DeviceId device_id,
                                                const EventDeviceType type) {
-  DeviceMap::const_iterator it = device_map_.find(device_id);
+  auto it = device_map_.find(device_id);
   if (it == device_map_.end())
     return false;
   return IsDeviceOfType(it->second, type,
@@ -903,15 +897,15 @@
 
 std::vector<std::string> GesturePropertyProvider::GetPropertyNamesById(
     const DeviceId device_id) {
-  internal::GestureDevicePropertyData* device_data =
-      device_data_map_.get(device_id);
-  if (!device_data)
+  auto it = device_data_map_.find(device_id);
+  if (it == device_data_map_.end())
     return std::vector<std::string>();
 
+  internal::GestureDevicePropertyData* device_data = it->second.get();
+
   // Dump all property names of the device.
   std::vector<std::string> names;
-  for (internal::ScopedPropertiesMap::const_iterator it =
-           device_data->properties.begin();
+  for (auto it = device_data->properties.begin();
        it != device_data->properties.end(); ++it)
     names.push_back(it->first);
   return names;
@@ -919,7 +913,7 @@
 
 std::string GesturePropertyProvider::GetDeviceNameById(
     const DeviceId device_id) {
-  DeviceMap::const_iterator it = device_map_.find(device_id);
+  auto it = device_map_.find(device_id);
   if (it == device_map_.end())
     return std::string();
   return std::string(it->second->info.name);
@@ -927,14 +921,14 @@
 
 void GesturePropertyProvider::RegisterDevice(const DeviceId id,
                                              const DevicePtr device) {
-  DeviceMap::const_iterator it = device_map_.find(id);
+  auto it = device_map_.find(id);
   if (it != device_map_.end())
     return;
 
   // Setup data-structures.
   device_map_[id] = device;
-  device_data_map_.set(id, std::unique_ptr<internal::GestureDevicePropertyData>(
-                               new internal::GestureDevicePropertyData));
+  device_data_map_[id] =
+      base::MakeUnique<internal::GestureDevicePropertyData>();
 
   // Gather default property values for the device from the parsed conf files.
   SetupDefaultProperties(id, device);
@@ -942,7 +936,7 @@
 }
 
 void GesturePropertyProvider::UnregisterDevice(const DeviceId id) {
-  DeviceMap::const_iterator it = device_map_.find(id);
+  auto it = device_map_.find(id);
   if (it == device_map_.end())
     return;
   device_data_map_.erase(id);
@@ -956,41 +950,43 @@
   // The look-up should never fail because ideally a property can only be
   // created with GesturesPropCreate* functions from the gesture lib side.
   // Therefore, we simply return on failure.
-  internal::GestureDevicePropertyData* device_data =
-      device_data_map_.get(device_id);
-  if (device_data)
-    device_data->properties.set(name, std::move(property));
+  auto it = device_data_map_.find(device_id);
+  if (it != device_data_map_.end())
+    it->second->properties[name] = std::move(property);
 }
 
 void GesturePropertyProvider::DeleteProperty(const DeviceId device_id,
                                              const std::string& name) {
-  internal::GestureDevicePropertyData* device_data =
-      device_data_map_.get(device_id);
-  if (device_data)
-    device_data->properties.erase(name);
+  auto it = device_data_map_.find(device_id);
+  if (it != device_data_map_.end())
+    it->second->properties.erase(name);
 }
 
 GesturesProp* GesturePropertyProvider::FindProperty(const DeviceId device_id,
                                                     const std::string& name) {
-  internal::GestureDevicePropertyData* device_data =
-      device_data_map_.get(device_id);
-  if (!device_data)
-    return NULL;
-  return device_data->properties.get(name);
+  auto it = device_data_map_.find(device_id);
+  if (it == device_data_map_.end())
+    return nullptr;
+
+  auto it2 = it->second->properties.find(name);
+  if (it2 == it->second->properties.end())
+    return nullptr;
+
+  return it2->second.get();
 }
 
 GesturesProp* GesturePropertyProvider::GetDefaultProperty(
     const DeviceId device_id,
     const std::string& name) {
-  internal::GestureDevicePropertyData* device_data =
-      device_data_map_.get(device_id);
-  if (!device_data)
-    return NULL;
-  internal::PropertiesMap::const_iterator ib =
-      device_data->default_properties.find(name);
-  if (ib == device_data->default_properties.end())
-    return NULL;
-  return ib->second;
+  auto it = device_data_map_.find(device_id);
+  if (it == device_data_map_.end())
+    return nullptr;
+
+  auto it2 = it->second->default_properties.find(name);
+  if (it2 == it->second->default_properties.end())
+    return nullptr;
+
+  return it2->second;
 }
 
 void GesturePropertyProvider::LoadDeviceConfigurations() {
@@ -1007,9 +1003,7 @@
   DVLOG(2) << files.size() << " conf files were found";
 
   // Parse conf files one-by-one.
-  for (std::set<base::FilePath>::iterator file_iter = files.begin();
-       file_iter != files.end();
-       ++file_iter) {
+  for (auto file_iter = files.begin(); file_iter != files.end(); ++file_iter) {
     DVLOG(2) << "Parsing conf file: " << (*file_iter).value();
     std::string content;
     if (!base::ReadFileToString(*file_iter, &content)) {
@@ -1279,8 +1273,7 @@
            << device_id << ", " << device->info.name << ")";
 
   // Go through all parsed sections.
-  internal::PropertiesMap& property_map =
-      device_data_map_.get(device_id)->default_properties;
+  auto& property_map = device_data_map_[device_id]->default_properties;
   for (const auto& configuration : configurations_) {
     if (configuration->Match(device)) {
       DVLOG(2) << "Conf section \"" << configuration->identifier
diff --git a/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h b/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h
index d23223d..9ae1956f 100644
--- a/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h
+++ b/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h
@@ -14,9 +14,9 @@
 #include <memory>
 #include <ostream>
 #include <string>
+#include <unordered_map>
 #include <vector>
 
-#include "base/containers/scoped_ptr_hash_map.h"
 #include "base/macros.h"
 #include "base/memory/scoped_vector.h"
 #include "ui/events/ozone/evdev/event_device_info.h"
@@ -112,14 +112,6 @@
   // Mapping table from a device id to its device pointer.
   typedef std::map<DeviceId, DevicePtr> DeviceMap;
 
-  // Mapping table from a device id to its property data.
-  // GestureDevicePropertyData contains both properties in use and default
-  // properties whose values will be applied upon the device attachment.
-  typedef base::ScopedPtrHashMap<
-      DeviceId,
-      std::unique_ptr<internal::GestureDevicePropertyData>>
-      ScopedDeviceDataMap;
-
   // Register a device. Setup data-structures and the device's default
   // properties.
   void RegisterDevice(const DeviceId id, const DevicePtr device);
@@ -166,9 +158,12 @@
   // Map from device ids to device pointers.
   DeviceMap device_map_;
 
-  // GestureDevicePropertyData indexed by their respective device ids. Owns the
-  // objects.
-  ScopedDeviceDataMap device_data_map_;
+  // Mapping table from a device id to its property data.
+  // GestureDevicePropertyData contains both properties in use and default
+  // properties whose values will be applied upon the device attachment.
+  std::unordered_map<DeviceId,
+                     std::unique_ptr<internal::GestureDevicePropertyData>>
+      device_data_map_;
 
   // A vector of parsed sections in configuration files. Owns MatchCriterias,
   // GesturesProps and ConfigurationSections in it.
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_controller.cc b/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
index c45ed811..4ea1e2a02 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
@@ -10,6 +10,7 @@
 #include <utility>
 
 #include "base/logging.h"
+#include "base/memory/ptr_util.h"
 #include "base/trace_event/trace_event.h"
 #include "third_party/skia/include/core/SkCanvas.h"
 #include "ui/gfx/geometry/point.h"
@@ -114,17 +115,18 @@
   }
 
   for (const auto& planes : owned_hardware_planes_)
-    planes.first->plane_manager()->BeginFrame(planes.second);
+    planes.first->plane_manager()->BeginFrame(planes.second.get());
 
   bool status = true;
   for (const auto& controller : crtc_controllers_) {
     status &= controller->SchedulePageFlip(
-        owned_hardware_planes_.get(controller->drm().get()), pending_planes,
+        owned_hardware_planes_[controller->drm().get()].get(), pending_planes,
         test_only, page_flip_request);
   }
 
   for (const auto& planes : owned_hardware_planes_) {
-    if (!planes.first->plane_manager()->Commit(planes.second, test_only)) {
+    if (!planes.first->plane_manager()->Commit(planes.second.get(),
+                                               test_only)) {
       status = false;
     }
   }
@@ -178,15 +180,14 @@
 void HardwareDisplayController::AddCrtc(
     std::unique_ptr<CrtcController> controller) {
   scoped_refptr<DrmDevice> drm = controller->drm();
-  owned_hardware_planes_.add(drm.get(),
-                             std::unique_ptr<HardwareDisplayPlaneList>(
-                                 new HardwareDisplayPlaneList()));
+  owned_hardware_planes_[drm.get()] =
+      base::MakeUnique<HardwareDisplayPlaneList>();
 
   // Check if this controller owns any planes and ensure we keep track of them.
   const std::vector<std::unique_ptr<HardwareDisplayPlane>>& all_planes =
       drm->plane_manager()->planes();
   HardwareDisplayPlaneList* crtc_plane_list =
-      owned_hardware_planes_.get(drm.get());
+      owned_hardware_planes_[drm.get()].get();
   uint32_t crtc = controller->crtc();
   for (const auto& plane : all_planes) {
     if (plane->in_use() && (plane->owning_crtc() == crtc))
@@ -217,7 +218,7 @@
       if (found) {
         std::vector<HardwareDisplayPlane*> all_planes;
         HardwareDisplayPlaneList* plane_list =
-            owned_hardware_planes_.get(drm.get());
+            owned_hardware_planes_[drm.get()].get();
         all_planes.swap(plane_list->old_plane_list);
         for (auto* plane : all_planes) {
           if (plane->owning_crtc() != crtc)
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_controller.h b/ui/ozone/platform/drm/gpu/hardware_display_controller.h
index 3738cf2..bfb34739 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_controller.h
+++ b/ui/ozone/platform/drm/gpu/hardware_display_controller.h
@@ -12,10 +12,10 @@
 #include <deque>
 #include <map>
 #include <memory>
+#include <unordered_map>
 #include <vector>
 
 #include "base/callback.h"
-#include "base/containers/scoped_ptr_hash_map.h"
 #include "base/macros.h"
 #include "base/memory/scoped_vector.h"
 #include "ui/gfx/swap_result.h"
@@ -160,7 +160,7 @@
                               bool test_only,
                               const PageFlipCallback& callback);
 
-  base::ScopedPtrHashMap<DrmDevice*, std::unique_ptr<HardwareDisplayPlaneList>>
+  std::unordered_map<DrmDevice*, std::unique_ptr<HardwareDisplayPlaneList>>
       owned_hardware_planes_;
 
   // Stores the CRTC configuration. This is used to identify monitors and
diff --git a/ui/ozone/platform/drm/gpu/screen_manager.cc b/ui/ozone/platform/drm/gpu/screen_manager.cc
index 18f36fe..8d4bdd7 100644
--- a/ui/ozone/platform/drm/gpu/screen_manager.cc
+++ b/ui/ozone/platform/drm/gpu/screen_manager.cc
@@ -219,14 +219,15 @@
 void ScreenManager::AddWindow(gfx::AcceleratedWidget widget,
                               std::unique_ptr<DrmWindow> window) {
   std::pair<WidgetToWindowMap::iterator, bool> result =
-      window_map_.add(widget, std::move(window));
+      window_map_.insert(std::make_pair(widget, std::move(window)));
   DCHECK(result.second) << "Window already added.";
   UpdateControllerToWindowMapping();
 }
 
 std::unique_ptr<DrmWindow> ScreenManager::RemoveWindow(
     gfx::AcceleratedWidget widget) {
-  std::unique_ptr<DrmWindow> window = window_map_.take_and_erase(widget);
+  std::unique_ptr<DrmWindow> window = std::move(window_map_[widget]);
+  window_map_.erase(widget);
   DCHECK(window) << "Attempting to remove non-existing window for " << widget;
   UpdateControllerToWindowMapping();
   return window;
@@ -235,7 +236,7 @@
 DrmWindow* ScreenManager::GetWindow(gfx::AcceleratedWidget widget) {
   WidgetToWindowMap::iterator it = window_map_.find(widget);
   if (it != window_map_.end())
-    return it->second;
+    return it->second.get();
 
   return nullptr;
 }
@@ -311,8 +312,8 @@
   }
 
   // Apply the new mapping to all windows.
-  for (auto pair : window_map_) {
-    auto it = window_to_controller_map.find(pair.second);
+  for (auto& pair : window_map_) {
+    auto it = window_to_controller_map.find(pair.second.get());
     HardwareDisplayController* controller = nullptr;
     if (it != window_to_controller_map.end())
       controller = it->second;
@@ -386,9 +387,9 @@
 }
 
 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const {
-  for (auto pair : window_map_) {
+  for (auto& pair : window_map_) {
     if (pair.second->bounds() == bounds)
-      return pair.second;
+      return pair.second.get();
   }
 
   return nullptr;
diff --git a/ui/ozone/platform/drm/gpu/screen_manager.h b/ui/ozone/platform/drm/gpu/screen_manager.h
index 3c799c6..7785b94 100644
--- a/ui/ozone/platform/drm/gpu/screen_manager.h
+++ b/ui/ozone/platform/drm/gpu/screen_manager.h
@@ -7,7 +7,8 @@
 
 #include <stdint.h>
 
-#include "base/containers/scoped_ptr_hash_map.h"
+#include <unordered_map>
+
 #include "base/macros.h"
 #include "base/memory/scoped_vector.h"
 #include "base/observer_list.h"
@@ -80,11 +81,10 @@
   void UpdateControllerToWindowMapping();
 
  private:
-  typedef std::vector<std::unique_ptr<HardwareDisplayController>>
-      HardwareDisplayControllers;
-  typedef base::ScopedPtrHashMap<gfx::AcceleratedWidget,
-                                 std::unique_ptr<DrmWindow>>
-      WidgetToWindowMap;
+  using HardwareDisplayControllers =
+      std::vector<std::unique_ptr<HardwareDisplayController>>;
+  using WidgetToWindowMap =
+      std::unordered_map<gfx::AcceleratedWidget, std::unique_ptr<DrmWindow>>;
 
   // Returns an iterator into |controllers_| for the controller identified by
   // (|crtc|, |connector|).