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

Unified Diff: content/public/test/test_navigation_observer.cc

Issue 2314833002: Remove some uses of stl_util's STLDeleteContainerPointers. (Closed)
Patch Set: cleanup Created 4 years, 3 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 | « content/public/test/test_navigation_observer.h ('k') | remoting/protocol/jingle_session.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/test_navigation_observer.cc
diff --git a/content/public/test/test_navigation_observer.cc b/content/public/test/test_navigation_observer.cc
index b8a57a20c2a9a50b4c8014b27669c274170424a4..684c66f91e9f5894967aa76c8f236f59b0a76e4a 100644
--- a/content/public/test/test_navigation_observer.cc
+++ b/content/public/test/test_navigation_observer.cc
@@ -6,9 +6,9 @@
#include "base/bind.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "base/stl_util.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/web_contents_observer.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -109,9 +109,6 @@ TestNavigationObserver::TestNavigationObserver(
TestNavigationObserver::~TestNavigationObserver() {
StopWatchingNewWebContents();
-
- base::STLDeleteContainerPointers(web_contents_observers_.begin(),
- web_contents_observers_.end());
}
void TestNavigationObserver::Wait() {
@@ -130,7 +127,7 @@ void TestNavigationObserver::StopWatchingNewWebContents() {
void TestNavigationObserver::RegisterAsObserver(WebContents* web_contents) {
web_contents_observers_.insert(
- new TestWebContentsObserver(this, web_contents));
+ base::MakeUnique<TestWebContentsObserver>(this, web_contents));
}
void TestNavigationObserver::OnWebContentsCreated(WebContents* web_contents) {
@@ -140,8 +137,11 @@ void TestNavigationObserver::OnWebContentsCreated(WebContents* web_contents) {
void TestNavigationObserver::OnWebContentsDestroyed(
TestWebContentsObserver* observer,
WebContents* web_contents) {
- web_contents_observers_.erase(observer);
- delete observer;
+ web_contents_observers_.erase(std::find_if(
+ web_contents_observers_.begin(), web_contents_observers_.end(),
+ [observer](const std::unique_ptr<TestWebContentsObserver>& ptr) {
+ return ptr.get() == observer;
+ }));
}
void TestNavigationObserver::OnNavigationEntryCommitted(
« no previous file with comments | « content/public/test/test_navigation_observer.h ('k') | remoting/protocol/jingle_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698