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

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
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..e6dc16dbadd05c880738245c899add7443259454 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,7 +120,7 @@ void BackgroundPrintingManager::DeletePreviewContents(
std::set<content::WebContents*> BackgroundPrintingManager::CurrentContentSet() {
std::set<content::WebContents*> result;
- for (WebContentsObserverMap::iterator i = printing_contents_map_.begin();
+ for (auto i = printing_contents_map_.begin();
i != printing_contents_map_.end(); ++i) {
Nico 2016/10/24 18:41:02 nit: foreach?
Avi (use Gerrit) 2016/10/24 19:15:37 Done.
result.insert(i->first);
}

Powered by Google App Engine
This is Rietveld 408576698