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

Unified Diff: chrome/renderer/print_web_view_helper_mac.mm

Issue 7585012: Fix print preview draft page memory leaks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Missed one on Mac. Created 9 years, 4 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/renderer/print_web_view_helper_linux.cc ('k') | chrome/renderer/print_web_view_helper_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/print_web_view_helper_mac.mm
diff --git a/chrome/renderer/print_web_view_helper_mac.mm b/chrome/renderer/print_web_view_helper_mac.mm
index 64761af6b6e9d5868bcb53252185764be1a00b2a..55cccb650a20b756130bb4427995f21867fb4bbf 100644
--- a/chrome/renderer/print_web_view_helper_mac.mm
+++ b/chrome/renderer/print_web_view_helper_mac.mm
@@ -68,13 +68,15 @@ void PrintWebViewHelper::RenderPreviewPage(int page_number) {
printing::Metafile* initial_render_metafile =
print_preview_context_.metafile();
+ scoped_ptr<printing::Metafile> draft_metafile;
#if !defined(USE_SKIA)
if (print_preview_context_.IsModifiable()) {
- initial_render_metafile = new printing::PreviewMetafile();
- if (!initial_render_metafile->Init()) {
+ draft_metafile.reset(new printing::PreviewMetafile);
+ if (!draft_metafile->Init()) {
DidFinishPrinting(FAIL_PREVIEW);
return;
}
+ initial_render_metafile = draft_metafile.get();
}
#endif
@@ -84,13 +86,12 @@ void PrintWebViewHelper::RenderPreviewPage(int page_number) {
print_preview_context_.RenderedPreviewPage(
base::TimeTicks::Now() - begin_time);
- printing::Metafile* draft_metafile = NULL;
if (print_preview_context_.IsModifiable()) {
#if defined(USE_SKIA)
- draft_metafile = reinterpret_cast<printing::PreviewMetafile*>(
- print_preview_context_.metafile())->GetMetafileForCurrentPage();
+ DCHECK(!draft_metafile.get());
+ draft_metafile.reset(reinterpret_cast<printing::PreviewMetafile*>(
+ print_preview_context_.metafile())->GetMetafileForCurrentPage());
#else
- draft_metafile = initial_render_metafile;
draft_metafile->FinishDocument();
// With CG, we rendered into a new metafile so we could get it as a draft
@@ -107,7 +108,7 @@ void PrintWebViewHelper::RenderPreviewPage(int page_number) {
#endif
}
- PreviewPageRendered(page_number, draft_metafile);
+ PreviewPageRendered(page_number, draft_metafile.get());
}
void PrintWebViewHelper::RenderPage(
« no previous file with comments | « chrome/renderer/print_web_view_helper_linux.cc ('k') | chrome/renderer/print_web_view_helper_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698