summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-09-21 15:25:32 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-21 19:41:49 +0000
commit65ecca4bc9c8e043b355c459486870ac1518095d (patch)
tree2cca0a32a7873f2743e9d927010533019e4c85b9
parent3418f710f923785a0fd05f7c556d09bc9a8d3447 (diff)
downloadpdfium-65ecca4bc9c8e043b355c459486870ac1518095d.tar.xz
Move CFX_Observable to Observable
This CL renames CFX_Observable to Observable and moves into the fxcrt namespace. The test suite names were updated to ObservedPtr from fxcrt. Bug: pdfium:898 Change-Id: Ia507482bc0a1d6d8bbf12c0c55c4a88f6c8910e2 Reviewed-on: https://pdfium-review.googlesource.com/14615 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--BUILD.gn4
-rw-r--r--core/fxcrt/observable.h (renamed from core/fxcrt/cfx_observable.h)22
-rw-r--r--core/fxcrt/observable_unittest.cpp (renamed from core/fxcrt/cfx_observable_unittest.cpp)28
-rw-r--r--fpdfsdk/cpdfsdk_annot.h4
-rw-r--r--fpdfsdk/cpdfsdk_formfillenvironment.h4
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.h4
-rw-r--r--fpdfsdk/javascript/Field.h2
-rw-r--r--fpdfsdk/javascript/cjs_runtime.h4
-rw-r--r--fpdfsdk/pwl/cpwl_wnd.cpp2
-rw-r--r--fpdfsdk/pwl/cpwl_wnd.h6
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.h6
-rw-r--r--xfa/fgas/font/cfgas_pdffontmgr.h4
12 files changed, 48 insertions, 42 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 54dae88c93..9a08d047fd 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -821,7 +821,6 @@ static_library("fxcrt") {
"core/fxcrt/cfx_fixedbufgrow.h",
"core/fxcrt/cfx_memorystream.cpp",
"core/fxcrt/cfx_memorystream.h",
- "core/fxcrt/cfx_observable.h",
"core/fxcrt/cfx_retain_ptr.h",
"core/fxcrt/cfx_shared_copy_on_write.h",
"core/fxcrt/cfx_string_data_template.h",
@@ -857,6 +856,7 @@ static_library("fxcrt") {
"core/fxcrt/ifx_fileaccess.h",
"core/fxcrt/ifx_pauseindicator.h",
"core/fxcrt/maybe_owned.h",
+ "core/fxcrt/observable.h",
"core/fxcrt/string_view_template.h",
"core/fxcrt/widestring.cpp",
"core/fxcrt/widestring.h",
@@ -1920,7 +1920,6 @@ test("pdfium_unittests") {
"core/fxcodec/jbig2/JBig2_BitStream_unittest.cpp",
"core/fxcodec/jbig2/JBig2_Image_unittest.cpp",
"core/fxcrt/bytestring_unittest.cpp",
- "core/fxcrt/cfx_observable_unittest.cpp",
"core/fxcrt/cfx_retain_ptr_unittest.cpp",
"core/fxcrt/cfx_shared_copy_on_write_unittest.cpp",
"core/fxcrt/cfx_string_pool_template_unittest.cpp",
@@ -1934,6 +1933,7 @@ test("pdfium_unittests") {
"core/fxcrt/fx_string_unittest.cpp",
"core/fxcrt/fx_system_unittest.cpp",
"core/fxcrt/maybe_owned_unittest.cpp",
+ "core/fxcrt/observable_unittest.cpp",
"core/fxcrt/widestring_unittest.cpp",
"core/fxge/dib/cstretchengine_unittest.cpp",
"fpdfsdk/fpdfdoc_unittest.cpp",
diff --git a/core/fxcrt/cfx_observable.h b/core/fxcrt/observable.h
index 8dc0907cae..659f8ad5b9 100644
--- a/core/fxcrt/cfx_observable.h
+++ b/core/fxcrt/observable.h
@@ -2,16 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CORE_FXCRT_CFX_OBSERVABLE_H_
-#define CORE_FXCRT_CFX_OBSERVABLE_H_
+#ifndef CORE_FXCRT_OBSERVABLE_H_
+#define CORE_FXCRT_OBSERVABLE_H_
#include <set>
#include "core/fxcrt/fx_system.h"
#include "third_party/base/stl_util.h"
+namespace fxcrt {
+
template <class T>
-class CFX_Observable {
+class Observable {
public:
class ObservedPtr {
public:
@@ -53,9 +55,9 @@ class CFX_Observable {
T* m_pObservable;
};
- CFX_Observable() {}
- CFX_Observable(const CFX_Observable& that) = delete;
- ~CFX_Observable() { NotifyObservedPtrs(); }
+ Observable() {}
+ Observable(const Observable& that) = delete;
+ ~Observable() { NotifyObservedPtrs(); }
void AddObservedPtr(ObservedPtr* pObservedPtr) {
ASSERT(!pdfium::ContainsKey(m_ObservedPtrs, pObservedPtr));
m_ObservedPtrs.insert(pObservedPtr);
@@ -69,7 +71,7 @@ class CFX_Observable {
pObservedPtr->OnDestroy();
m_ObservedPtrs.clear();
}
- CFX_Observable& operator=(const CFX_Observable& that) = delete;
+ Observable& operator=(const Observable& that) = delete;
protected:
size_t ActiveObservedPtrsForTesting() const { return m_ObservedPtrs.size(); }
@@ -78,4 +80,8 @@ class CFX_Observable {
std::set<ObservedPtr*> m_ObservedPtrs;
};
-#endif // CORE_FXCRT_CFX_OBSERVABLE_H_
+} // namespace fxcrt
+
+using fxcrt::Observable;
+
+#endif // CORE_FXCRT_OBSERVABLE_H_
diff --git a/core/fxcrt/cfx_observable_unittest.cpp b/core/fxcrt/observable_unittest.cpp
index f7c78c1112..8edc58f613 100644
--- a/core/fxcrt/cfx_observable_unittest.cpp
+++ b/core/fxcrt/observable_unittest.cpp
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/fxcrt/cfx_observable.h"
+#include "core/fxcrt/observable.h"
#include <utility>
#include <vector>
@@ -11,7 +11,7 @@
namespace {
-class PseudoObservable : public CFX_Observable<PseudoObservable> {
+class PseudoObservable : public Observable<PseudoObservable> {
public:
PseudoObservable() {}
int SomeMethod() { return 42; }
@@ -20,12 +20,12 @@ class PseudoObservable : public CFX_Observable<PseudoObservable> {
} // namespace
-TEST(fxcrt, ObservePtrNull) {
+TEST(ObservePtr, Null) {
PseudoObservable::ObservedPtr ptr;
EXPECT_EQ(nullptr, ptr.Get());
}
-TEST(fxcrt, ObservePtrLivesLonger) {
+TEST(ObservePtr, LivesLonger) {
PseudoObservable* pObs = new PseudoObservable;
PseudoObservable::ObservedPtr ptr(pObs);
EXPECT_NE(nullptr, ptr.Get());
@@ -34,7 +34,7 @@ TEST(fxcrt, ObservePtrLivesLonger) {
EXPECT_EQ(nullptr, ptr.Get());
}
-TEST(fxcrt, ObservePtrLivesShorter) {
+TEST(ObservePtr, LivesShorter) {
PseudoObservable obs;
{
PseudoObservable::ObservedPtr ptr(&obs);
@@ -44,7 +44,7 @@ TEST(fxcrt, ObservePtrLivesShorter) {
EXPECT_EQ(0u, obs.ActiveObservedPtrs());
}
-TEST(fxcrt, ObserveCopyConstruct) {
+TEST(ObservePtr, CopyConstruct) {
PseudoObservable obs;
{
PseudoObservable::ObservedPtr ptr(&obs);
@@ -60,7 +60,7 @@ TEST(fxcrt, ObserveCopyConstruct) {
EXPECT_EQ(0u, obs.ActiveObservedPtrs());
}
-TEST(fxcrt, ObserveCopyAssign) {
+TEST(ObservePtr, CopyAssign) {
PseudoObservable obs;
{
PseudoObservable::ObservedPtr ptr(&obs);
@@ -77,7 +77,7 @@ TEST(fxcrt, ObserveCopyAssign) {
EXPECT_EQ(0u, obs.ActiveObservedPtrs());
}
-TEST(fxcrt, ObserveVector) {
+TEST(ObservePtr, Vector) {
PseudoObservable obs;
{
std::vector<PseudoObservable::ObservedPtr> vec1;
@@ -101,7 +101,7 @@ TEST(fxcrt, ObserveVector) {
EXPECT_EQ(0u, obs.ActiveObservedPtrs());
}
-TEST(fxcrt, ObserveVectorAutoClear) {
+TEST(ObservePtr, VectorAutoClear) {
std::vector<PseudoObservable::ObservedPtr> vec1;
{
PseudoObservable obs;
@@ -115,7 +115,7 @@ TEST(fxcrt, ObserveVectorAutoClear) {
EXPECT_EQ(nullptr, vec1[1].Get());
}
-TEST(fxcrt, ObservePtrResetNull) {
+TEST(ObservePtr, ResetNull) {
PseudoObservable obs;
PseudoObservable::ObservedPtr ptr(&obs);
EXPECT_EQ(1u, obs.ActiveObservedPtrs());
@@ -123,7 +123,7 @@ TEST(fxcrt, ObservePtrResetNull) {
EXPECT_EQ(0u, obs.ActiveObservedPtrs());
}
-TEST(fxcrt, ObservePtrReset) {
+TEST(ObservePtr, Reset) {
PseudoObservable obs1;
PseudoObservable obs2;
PseudoObservable::ObservedPtr ptr(&obs1);
@@ -134,7 +134,7 @@ TEST(fxcrt, ObservePtrReset) {
EXPECT_EQ(1u, obs2.ActiveObservedPtrs());
}
-TEST(fxcrt, ObservePtrEquals) {
+TEST(ObservePtr, Equals) {
PseudoObservable obj1;
PseudoObservable obj2;
PseudoObservable::ObservedPtr null_ptr1;
@@ -155,7 +155,7 @@ TEST(fxcrt, ObservePtrEquals) {
EXPECT_FALSE(obj1_ptr1 == obj2_ptr1);
}
-TEST(fxcrt, ObservePtrNotEquals) {
+TEST(ObservePtr, NotEquals) {
PseudoObservable obj1;
PseudoObservable obj2;
PseudoObservable::ObservedPtr null_ptr1;
@@ -174,7 +174,7 @@ TEST(fxcrt, ObservePtrNotEquals) {
EXPECT_TRUE(obj1_ptr1 != obj2_ptr1);
}
-TEST(fxcrt, ObservePtrBool) {
+TEST(ObservePtr, Bool) {
PseudoObservable obj1;
PseudoObservable::ObservedPtr null_ptr;
PseudoObservable::ObservedPtr obj1_ptr(&obj1);
diff --git a/fpdfsdk/cpdfsdk_annot.h b/fpdfsdk/cpdfsdk_annot.h
index 47049556cc..325b4298ef 100644
--- a/fpdfsdk/cpdfsdk_annot.h
+++ b/fpdfsdk/cpdfsdk_annot.h
@@ -10,8 +10,8 @@
#include "core/fpdfdoc/cpdf_aaction.h"
#include "core/fpdfdoc/cpdf_annot.h"
#include "core/fpdfdoc/cpdf_defaultappearance.h"
-#include "core/fxcrt/cfx_observable.h"
#include "core/fxcrt/cfx_unowned_ptr.h"
+#include "core/fxcrt/observable.h"
#include "fpdfsdk/cfx_systemhandler.h"
#include "fpdfsdk/fsdk_common.h"
#include "fpdfsdk/fsdk_define.h"
@@ -22,7 +22,7 @@ class CPDF_Page;
class CPDF_RenderOptions;
class CPDFSDK_PageView;
-class CPDFSDK_Annot : public CFX_Observable<CPDFSDK_Annot> {
+class CPDFSDK_Annot : public Observable<CPDFSDK_Annot> {
public:
explicit CPDFSDK_Annot(CPDFSDK_PageView* pPageView);
virtual ~CPDFSDK_Annot();
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h
index 9e3c92561b..ea7b3c7e38 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.h
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.h
@@ -14,7 +14,7 @@
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfdoc/cpdf_occontext.h"
-#include "core/fxcrt/cfx_observable.h"
+#include "core/fxcrt/observable.h"
#include "fpdfsdk/cfx_systemhandler.h"
#include "fpdfsdk/cpdfsdk_annot.h"
#include "fpdfsdk/fsdk_define.h"
@@ -41,7 +41,7 @@ class IJS_Runtime;
// lingering lifetime issues via the memory tools.
class CPDFSDK_FormFillEnvironment
- : public CFX_Observable<CPDFSDK_FormFillEnvironment> {
+ : public Observable<CPDFSDK_FormFillEnvironment> {
public:
CPDFSDK_FormFillEnvironment(UnderlyingDocumentType* pDoc,
FPDF_FORMFILLINFO* pFFinfo);
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
index a0f90ab37b..0dbc51e54b 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
@@ -10,9 +10,9 @@
#include <memory>
#include <vector>
-#include "core/fxcrt/cfx_observable.h"
#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/observable.h"
#include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h"
#include "fpdfsdk/fpdfxfa/cpdfxfa_page.h"
#include "xfa/fxfa/cxfa_ffdoc.h"
@@ -104,7 +104,7 @@ class CPDFXFA_Context : public IXFA_AppProvider {
XFA_DocType m_iDocType;
std::unique_ptr<CPDF_Document> m_pPDFDoc;
std::unique_ptr<CXFA_FFDoc> m_pXFADoc;
- CFX_Observable<CPDFSDK_FormFillEnvironment>::ObservedPtr m_pFormFillEnv;
+ Observable<CPDFSDK_FormFillEnvironment>::ObservedPtr m_pFormFillEnv;
CFX_UnownedPtr<CXFA_FFDocView> m_pXFADocView;
std::unique_ptr<CXFA_FFApp> m_pXFAApp;
std::unique_ptr<CJS_Runtime> m_pRuntime;
diff --git a/fpdfsdk/javascript/Field.h b/fpdfsdk/javascript/Field.h
index 2ca1da4491..69e27d0639 100644
--- a/fpdfsdk/javascript/Field.h
+++ b/fpdfsdk/javascript/Field.h
@@ -10,7 +10,7 @@
#include <string>
#include <vector>
-#include "core/fxcrt/cfx_observable.h"
+#include "core/fxcrt/observable.h"
#include "core/fxge/cfx_color.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/javascript/JS_Define.h"
diff --git a/fpdfsdk/javascript/cjs_runtime.h b/fpdfsdk/javascript/cjs_runtime.h
index 39919957f8..0d6951f8c0 100644
--- a/fpdfsdk/javascript/cjs_runtime.h
+++ b/fpdfsdk/javascript/cjs_runtime.h
@@ -13,7 +13,7 @@
#include <utility>
#include <vector>
-#include "core/fxcrt/cfx_observable.h"
+#include "core/fxcrt/observable.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/ijs_runtime.h"
@@ -23,7 +23,7 @@ class CJS_EventContext;
class CJS_Runtime : public IJS_Runtime,
public CFXJS_Engine,
- public CFX_Observable<CJS_Runtime> {
+ public Observable<CJS_Runtime> {
public:
using FieldEvent = std::pair<WideString, JS_EVENT_T>;
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index 4e4abd2017..9abe03c3fb 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -46,7 +46,7 @@ CPWL_Wnd::CreateParams::CreateParams(const CreateParams& other) = default;
CPWL_Wnd::CreateParams::~CreateParams() = default;
-class CPWL_MsgControl : public CFX_Observable<CPWL_MsgControl> {
+class CPWL_MsgControl : public Observable<CPWL_MsgControl> {
friend class CPWL_Wnd;
public:
diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h
index 17ed06450a..ecef1e2e10 100644
--- a/fpdfsdk/pwl/cpwl_wnd.h
+++ b/fpdfsdk/pwl/cpwl_wnd.h
@@ -11,8 +11,8 @@
#include <vector>
#include "core/fpdfdoc/cpdf_formcontrol.h"
-#include "core/fxcrt/cfx_observable.h"
#include "core/fxcrt/cfx_unowned_ptr.h"
+#include "core/fxcrt/observable.h"
#include "core/fxge/cfx_color.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_widget.h"
@@ -100,14 +100,14 @@ inline bool operator!=(const CFX_Color& c1, const CFX_Color& c2) {
#define PWL_DEFAULT_BLACKCOLOR CFX_Color(COLORTYPE_GRAY, 0)
#define PWL_DEFAULT_WHITECOLOR CFX_Color(COLORTYPE_GRAY, 1)
-class CPWL_Wnd : public CPWL_TimerHandler, public CFX_Observable<CPWL_Wnd> {
+class CPWL_Wnd : public CPWL_TimerHandler, public Observable<CPWL_Wnd> {
public:
class PrivateData {
protected:
~PrivateData() {}
};
- class ProviderIface : public CFX_Observable<ProviderIface> {
+ class ProviderIface : public Observable<ProviderIface> {
public:
virtual ~ProviderIface() {}
diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h
index 946486be2a..642ba6fb67 100644
--- a/xfa/fgas/font/cfgas_fontmgr.h
+++ b/xfa/fgas/font/cfgas_fontmgr.h
@@ -14,10 +14,10 @@
#include <vector>
#include "core/fxcrt/cfx_crtfileaccess.h"
-#include "core/fxcrt/cfx_observable.h"
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/cfx_seekablestreamproxy.h"
#include "core/fxcrt/fx_extension.h"
+#include "core/fxcrt/observable.h"
#include "core/fxge/cfx_fontmapper.h"
#include "core/fxge/fx_freetype.h"
#include "core/fxge/ifx_systemfontinfo.h"
@@ -81,7 +81,7 @@ typedef void (*FX_LPEnumAllFonts)(std::deque<FX_FONTDESCRIPTOR>* fonts,
FX_LPEnumAllFonts FX_GetDefFontEnumerator();
-class CFGAS_FontMgr : public CFX_Observable<CFGAS_FontMgr> {
+class CFGAS_FontMgr : public Observable<CFGAS_FontMgr> {
public:
static std::unique_ptr<CFGAS_FontMgr> Create(FX_LPEnumAllFonts pEnumerator);
@@ -180,7 +180,7 @@ class CFX_FontSourceEnum_File {
std::vector<ByteString> m_FolderPaths;
};
-class CFGAS_FontMgr : public CFX_Observable<CFGAS_FontMgr> {
+class CFGAS_FontMgr : public Observable<CFGAS_FontMgr> {
public:
static std::unique_ptr<CFGAS_FontMgr> Create(
CFX_FontSourceEnum_File* pFontEnum);
diff --git a/xfa/fgas/font/cfgas_pdffontmgr.h b/xfa/fgas/font/cfgas_pdffontmgr.h
index 8a09a95bd1..a31d865cec 100644
--- a/xfa/fgas/font/cfgas_pdffontmgr.h
+++ b/xfa/fgas/font/cfgas_pdffontmgr.h
@@ -11,16 +11,16 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
-#include "core/fxcrt/cfx_observable.h"
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/observable.h"
class CFGAS_FontMgr;
class CFGAS_GEFont;
class CPDF_Document;
class CPDF_Font;
-class CFGAS_PDFFontMgr : public CFX_Observable<CFGAS_PDFFontMgr> {
+class CFGAS_PDFFontMgr : public Observable<CFGAS_PDFFontMgr> {
public:
explicit CFGAS_PDFFontMgr(CPDF_Document* pDoc, CFGAS_FontMgr* pFontMgr);
~CFGAS_PDFFontMgr();