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

Unified Diff: chrome/browser/printing/background_printing_manager.cc

Issue 2442953002: Remove stl_util's deletion function use from chrome/. (Closed)
Patch Set: fix Created 4 years, 2 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 | « chrome/browser/printing/background_printing_manager.h ('k') | chrome/browser/process_singleton_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/background_printing_manager.cc
diff --git a/chrome/browser/printing/background_printing_manager.cc b/chrome/browser/printing/background_printing_manager.cc
index cc7adae4c6082199bc1eb7b83767adbbe3285f36..af8ed4cd2ccb40e6077ff5da9f9e019cdd1b2563 100644
--- a/chrome/browser/printing/background_printing_manager.cc
+++ b/chrome/browser/printing/background_printing_manager.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/printing/background_printing_manager.h"
#include "base/location.h"
+#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -61,7 +62,6 @@ BackgroundPrintingManager::~BackgroundPrintingManager() {
// preview WebContents trying to print). In such a case it will fail to print,
// but we should at least clean up the observers.
// TODO(thestig): Handle this case better.
- base::STLDeleteValues(&printing_contents_map_);
}
void BackgroundPrintingManager::OwnPrintPreviewDialog(
@@ -70,7 +70,8 @@ void BackgroundPrintingManager::OwnPrintPreviewDialog(
DCHECK(PrintPreviewDialogController::IsPrintPreviewDialog(preview_dialog));
CHECK(!HasPrintPreviewDialog(preview_dialog));
- printing_contents_map_[preview_dialog] = new Observer(this, preview_dialog);
+ printing_contents_map_[preview_dialog] =
+ base::MakeUnique<Observer>(this, preview_dialog);
// Watch for print jobs finishing. Everything else is watched for by the
// Observer. TODO(avi, cait): finish the job of removing this last
@@ -99,8 +100,7 @@ void BackgroundPrintingManager::Observe(
void BackgroundPrintingManager::DeletePreviewContents(
WebContents* preview_contents) {
- WebContentsObserverMap::iterator i =
- printing_contents_map_.find(preview_contents);
+ auto i = printing_contents_map_.find(preview_contents);
if (i == printing_contents_map_.end()) {
// Everyone is racing to be the first to delete the |preview_contents|. If
// this case is hit, someone else won the race, so there is no need to
@@ -111,9 +111,7 @@ void BackgroundPrintingManager::DeletePreviewContents(
// Stop all observation ...
registrar_.Remove(this, chrome::NOTIFICATION_PRINT_JOB_RELEASED,
content::Source<WebContents>(preview_contents));
- Observer* observer = i->second;
printing_contents_map_.erase(i);
- delete observer;
// ... and mortally wound the contents. (Deletion immediately is not a good
// idea in case this was called from RenderViewGone.)
@@ -122,10 +120,9 @@ void BackgroundPrintingManager::DeletePreviewContents(
std::set<content::WebContents*> BackgroundPrintingManager::CurrentContentSet() {
std::set<content::WebContents*> result;
- for (WebContentsObserverMap::iterator i = printing_contents_map_.begin();
- i != printing_contents_map_.end(); ++i) {
- result.insert(i->first);
- }
+ for (const auto& entry : printing_contents_map_)
+ result.insert(entry.first);
+
return result;
}
« no previous file with comments | « chrome/browser/printing/background_printing_manager.h ('k') | chrome/browser/process_singleton_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698