summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-08-03 11:06:49 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-03 11:06:49 -0700
commit2d5b020304e8a9aa8afeb632c61daa7ece87e36d (patch)
tree4d7f04d4800577fa597b4ca1f1b4d31b87194ef0 /fpdfsdk/javascript
parentca27127240fbca2184f1c576b15b5212d5b314e6 (diff)
downloadpdfium-2d5b020304e8a9aa8afeb632c61daa7ece87e36d.tar.xz
Use smart pointers for class owned pointers
For all classes under /fpdfsdk, use smart pointer to replace raw pointer type for class owned member variables so that memory management will be easier. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2173253002
Diffstat (limited to 'fpdfsdk/javascript')
-rw-r--r--fpdfsdk/javascript/cjs_context.cpp10
-rw-r--r--fpdfsdk/javascript/cjs_context.h8
2 files changed, 9 insertions, 9 deletions
diff --git a/fpdfsdk/javascript/cjs_context.cpp b/fpdfsdk/javascript/cjs_context.cpp
index 406339d7af..06abf7f48d 100644
--- a/fpdfsdk/javascript/cjs_context.cpp
+++ b/fpdfsdk/javascript/cjs_context.cpp
@@ -11,13 +11,11 @@
#include "fpdfsdk/javascript/resource.h"
CJS_Context::CJS_Context(CJS_Runtime* pRuntime)
- : m_pRuntime(pRuntime), m_bBusy(FALSE) {
- m_pEventHandler = new CJS_EventHandler(this);
-}
+ : m_pRuntime(pRuntime),
+ m_pEventHandler(new CJS_EventHandler(this)),
+ m_bBusy(FALSE) {}
-CJS_Context::~CJS_Context() {
- delete m_pEventHandler;
-}
+CJS_Context::~CJS_Context() {}
CPDFSDK_Document* CJS_Context::GetReaderDocument() {
return m_pRuntime->GetReaderDocument();
diff --git a/fpdfsdk/javascript/cjs_context.h b/fpdfsdk/javascript/cjs_context.h
index cccdbc7669..49ba42c6d1 100644
--- a/fpdfsdk/javascript/cjs_context.h
+++ b/fpdfsdk/javascript/cjs_context.h
@@ -7,6 +7,8 @@
#ifndef FPDFSDK_JAVASCRIPT_CJS_CONTEXT_H_
#define FPDFSDK_JAVASCRIPT_CJS_CONTEXT_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
#include "fpdfsdk/javascript/ijs_context.h"
@@ -121,14 +123,14 @@ class CJS_Context : public IJS_Context {
void OnExternal_Exec() override;
CJS_Runtime* GetJSRuntime() const { return m_pRuntime; }
- CJS_EventHandler* GetEventHandler() const { return m_pEventHandler; }
+ CJS_EventHandler* GetEventHandler() const { return m_pEventHandler.get(); }
CPDFDoc_Environment* GetReaderApp();
CPDFSDK_Document* GetReaderDocument();
private:
- CJS_Runtime* m_pRuntime;
- CJS_EventHandler* m_pEventHandler;
+ CJS_Runtime* const m_pRuntime;
+ std::unique_ptr<CJS_EventHandler> m_pEventHandler;
FX_BOOL m_bBusy;
};