summaryrefslogtreecommitdiffstats
path: root/pdf
diff options
context:
space:
mode:
authorraymes <raymes@chromium.org>2015-09-07 18:11:11 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-08 01:11:55 +0000
commitcf7b9bfd81a7f2690c80deb46d35833acb692975 (patch)
tree315def80f8bb60b2d6ac2656b5c12649fae59bac /pdf
parenta165fee74a7abdd037b87b968b4462f816611a53 (diff)
downloadchromium_src-cf7b9bfd81a7f2690c80deb46d35833acb692975.zip
chromium_src-cf7b9bfd81a7f2690c80deb46d35833acb692975.tar.gz
chromium_src-cf7b9bfd81a7f2690c80deb46d35833acb692975.tar.bz2
Fix memory leak of PreviewModeClient in PDF
Previously, in print preview, we would construct a new PreviewModeClient and pass it to the PDFEngine, however the PDFEngine does not maintain ownership of the client passed in. Instead OutOfProcessInstance should maintain ownership which is fixed by this CL. BUG=522286 Review URL: https://codereview.chromium.org/1323943011 Cr-Commit-Position: refs/heads/master@{#347652}
Diffstat (limited to 'pdf')
-rw-r--r--pdf/out_of_process_instance.cc3
-rw-r--r--pdf/out_of_process_instance.h4
2 files changed, 6 insertions, 1 deletions
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc
index 5f60a4b..2e62e8b 100644
--- a/pdf/out_of_process_instance.cc
+++ b/pdf/out_of_process_instance.cc
@@ -782,7 +782,8 @@ void OutOfProcessInstance::DidOpen(int32_t result) {
void OutOfProcessInstance::DidOpenPreview(int32_t result) {
if (result == PP_OK) {
- preview_engine_.reset(PDFEngine::Create(new PreviewModeClient(this)));
+ preview_client_.reset(new PreviewModeClient(this));
+ preview_engine_.reset(PDFEngine::Create(preview_client_.get()));
preview_engine_->HandleDocumentLoad(embed_preview_loader_);
} else {
NOTREACHED();
diff --git a/pdf/out_of_process_instance.h b/pdf/out_of_process_instance.h
index 1215f19..e763134 100644
--- a/pdf/out_of_process_instance.h
+++ b/pdf/out_of_process_instance.h
@@ -257,6 +257,10 @@ class OutOfProcessInstance : public pp::Instance,
scoped_ptr<PDFEngine> engine_;
+ // The PreviewModeClient used for print preview. Will be passed to
+ // |preview_engine_|.
+ scoped_ptr<PreviewModeClient> preview_client_;
+
// This engine is used to render the individual preview page data. This is
// used only in print preview mode. This will use |PreviewModeClient|
// interface which has very limited access to the pp::Instance.