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

Unified Diff: ash/wm/resize_shadow_controller.cc

Issue 2472183003: Remove linked_ptr from ash (Closed)
Patch Set: Created 4 years, 1 month 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
Index: ash/wm/resize_shadow_controller.cc
diff --git a/ash/wm/resize_shadow_controller.cc b/ash/wm/resize_shadow_controller.cc
index c0d29ce136caf6f47027772d33183853d56a1fc7..71ebaac9032daa36d57d7d3a8d34e53ea04c98cf 100644
--- a/ash/wm/resize_shadow_controller.cc
+++ b/ash/wm/resize_shadow_controller.cc
@@ -14,10 +14,8 @@ namespace ash {
ResizeShadowController::ResizeShadowController() {}
ResizeShadowController::~ResizeShadowController() {
- for (WindowShadowMap::const_iterator it = window_shadows_.begin();
- it != window_shadows_.end(); ++it) {
- it->first->RemoveObserver(this);
- }
+ for (const auto& shadow : window_shadows_)
+ shadow.first->RemoveObserver(this);
}
void ResizeShadowController::ShowShadow(aura::Window* window, int hit_test) {
@@ -52,20 +50,22 @@ void ResizeShadowController::OnWindowDestroyed(aura::Window* window) {
}
ResizeShadow* ResizeShadowController::CreateShadow(aura::Window* window) {
- linked_ptr<ResizeShadow> shadow(new ResizeShadow());
- window_shadows_.insert(std::make_pair(window, shadow));
+ std::unique_ptr<ResizeShadow> shadow(new ResizeShadow());
oshima 2016/11/04 18:31:43 optional: or auto..MakeUnique.
limasdf 2016/11/05 06:08:17 any advantage in using it? to use it we need to ad
limasdf 2016/11/05 06:12:57 Ah, I got it. using auto..MakeUnique calls 'new' o
// Attach the layers to this window.
shadow->Init(window);
// Ensure initial bounds are correct.
shadow->Layout(window->bounds());
// Watch for bounds changes.
window->AddObserver(this);
- return shadow.get();
+
+ ResizeShadow* raw_shadow = shadow.get();
+ window_shadows_.insert(std::make_pair(window, std::move(shadow)));
+ return raw_shadow;
}
ResizeShadow* ResizeShadowController::GetShadowForWindow(aura::Window* window) {
- WindowShadowMap::const_iterator it = window_shadows_.find(window);
- return it != window_shadows_.end() ? it->second.get() : NULL;
+ auto it = window_shadows_.find(window);
+ return it != window_shadows_.end() ? it->second.get() : nullptr;
}
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698