From 47aff85a5f80cc3cd3a7c55869ab777c407bbf11 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 12 Jul 2018 19:05:10 +0000 Subject: Use pdfium::Optional in CJS_Return. Change-Id: Idfe70f86fbaf341ba6b197689a65ac722e671f39 Reviewed-on: https://pdfium-review.googlesource.com/37674 Reviewed-by: dsinclair Commit-Queue: Lei Zhang --- fxjs/cjs_return.cpp | 7 +++---- fxjs/cjs_return.h | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/fxjs/cjs_return.cpp b/fxjs/cjs_return.cpp index 53ac5c0a28..49ad54ab07 100644 --- a/fxjs/cjs_return.cpp +++ b/fxjs/cjs_return.cpp @@ -6,12 +6,11 @@ #include "fxjs/cjs_return.h" -CJS_Return::CJS_Return() : is_error_(false) {} +CJS_Return::CJS_Return() {} -CJS_Return::CJS_Return(v8::Local ret) - : is_error_(false), return_(ret) {} +CJS_Return::CJS_Return(v8::Local ret) : return_(ret) {} -CJS_Return::CJS_Return(const WideString& err) : is_error_(true), error_(err) {} +CJS_Return::CJS_Return(const WideString& err) : error_(err) {} CJS_Return::CJS_Return(JSMessage id) : CJS_Return(JSGetStringFromID(id)) {} diff --git a/fxjs/cjs_return.h b/fxjs/cjs_return.h index df3c8519bd..b165f3f11c 100644 --- a/fxjs/cjs_return.h +++ b/fxjs/cjs_return.h @@ -9,6 +9,7 @@ #include "fxjs/cfxjs_engine.h" #include "fxjs/js_resources.h" +#include "third_party/base/optional.h" class CJS_Return { public: @@ -19,15 +20,14 @@ class CJS_Return { CJS_Return(const CJS_Return&); ~CJS_Return(); - bool HasError() const { return is_error_; } - WideString Error() const { return error_; } + bool HasError() const { return error_.has_value(); } + WideString Error() const { return error_.value(); } bool HasReturn() const { return !return_.IsEmpty(); } v8::Local Return() const { return return_; } private: - bool is_error_ = false; - WideString error_; + Optional error_; v8::Local return_; }; -- cgit v1.2.3