summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-09-21 14:52:41 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-21 19:22:00 +0000
commitde44d154f6c61af75f149e965a7f483f0b30dd98 (patch)
treecb33c824a73bb017d4403fba898b1d8c4e0c1566
parentb89669975f6156fce4ced5c8998125a845f8e7dc (diff)
downloadpdfium-de44d154f6c61af75f149e965a7f483f0b30dd98.tar.xz
Move CFX_MaybeOwned to fxcrt::MaybeOwned
This CL moves CFX_MaybeOwned into the fxcrt namespace and removes the CFX_ prefix. The test names for maybe owned were updated to be in the MaybeOned test suite instead of the fxcrt suite. Bug: pdfium:898 Change-Id: I0c07057d66c8610e7b19133094b4507fff725e76 Reviewed-on: https://pdfium-review.googlesource.com/14470 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--BUILD.gn4
-rw-r--r--core/fpdfapi/edit/cpdf_flateencoder.h6
-rw-r--r--core/fpdfapi/page/cpdf_colorspace.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_image.h6
-rw-r--r--core/fpdfapi/parser/cpdf_object_avail.h4
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp2
-rw-r--r--core/fpdfdoc/cpdf_annot.h4
-rw-r--r--core/fxcodec/jbig2/JBig2_TrdProc.cpp26
-rw-r--r--core/fxcrt/maybe_owned.h (renamed from core/fxcrt/cfx_maybe_owned.h)38
-rw-r--r--core/fxcrt/maybe_owned_unittest.cpp (renamed from core/fxcrt/cfx_maybe_owned_unittest.cpp)50
-rw-r--r--core/fxge/dib/cfx_dibitmap.h4
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp2
-rw-r--r--core/fxge/win32/fx_win32_device.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp2
15 files changed, 82 insertions, 74 deletions
diff --git a/BUILD.gn b/BUILD.gn
index f95da713b1..d740ad6045 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -819,7 +819,6 @@ static_library("fxcrt") {
"core/fxcrt/cfx_fileaccess_windows.cpp",
"core/fxcrt/cfx_fileaccess_windows.h",
"core/fxcrt/cfx_fixedbufgrow.h",
- "core/fxcrt/cfx_maybe_owned.h",
"core/fxcrt/cfx_memorystream.cpp",
"core/fxcrt/cfx_memorystream.h",
"core/fxcrt/cfx_observable.h",
@@ -857,6 +856,7 @@ static_library("fxcrt") {
"core/fxcrt/fx_unicode.h",
"core/fxcrt/ifx_fileaccess.h",
"core/fxcrt/ifx_pauseindicator.h",
+ "core/fxcrt/maybe_owned.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_maybe_owned_unittest.cpp",
"core/fxcrt/cfx_observable_unittest.cpp",
"core/fxcrt/cfx_retain_ptr_unittest.cpp",
"core/fxcrt/cfx_shared_copy_on_write_unittest.cpp",
@@ -1934,6 +1933,7 @@ test("pdfium_unittests") {
"core/fxcrt/fx_random_unittest.cpp",
"core/fxcrt/fx_string_unittest.cpp",
"core/fxcrt/fx_system_unittest.cpp",
+ "core/fxcrt/maybe_owned_unittest.cpp",
"core/fxcrt/widestring_unittest.cpp",
"core/fxge/dib/cstretchengine_unittest.cpp",
"fpdfsdk/fpdfdoc_unittest.cpp",
diff --git a/core/fpdfapi/edit/cpdf_flateencoder.h b/core/fpdfapi/edit/cpdf_flateencoder.h
index ee946582ef..3698414fd2 100644
--- a/core/fpdfapi/edit/cpdf_flateencoder.h
+++ b/core/fpdfapi/edit/cpdf_flateencoder.h
@@ -9,9 +9,9 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
-#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_memory.h"
+#include "core/fxcrt/maybe_owned.h"
class CPDF_Stream;
@@ -29,8 +29,8 @@ class CPDF_FlateEncoder {
private:
uint32_t m_dwSize;
- CFX_MaybeOwned<uint8_t, FxFreeDeleter> m_pData;
- CFX_MaybeOwned<CPDF_Dictionary> m_pDict;
+ MaybeOwned<uint8_t, FxFreeDeleter> m_pData;
+ MaybeOwned<CPDF_Dictionary> m_pDict;
CFX_RetainPtr<CPDF_StreamAcc> m_pAcc;
};
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp
index 3e2b885ee5..5455d4dbba 100644
--- a/core/fpdfapi/page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/page/cpdf_colorspace.cpp
@@ -31,8 +31,8 @@
#include "core/fxcodec/codec/ccodec_iccmodule.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/cfx_fixedbufgrow.h"
-#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/fx_memory.h"
+#include "core/fxcrt/maybe_owned.h"
#include "third_party/base/stl_util.h"
namespace {
@@ -176,7 +176,7 @@ class CPDF_ICCBasedCS : public CPDF_ColorSpace {
bool IsValidComponents(int32_t nComps) const;
void PopulateRanges(CPDF_Dictionary* pDict);
- CFX_MaybeOwned<CPDF_ColorSpace> m_pAlterCS;
+ MaybeOwned<CPDF_ColorSpace> m_pAlterCS;
CFX_RetainPtr<CPDF_IccProfile> m_pProfile;
uint8_t* m_pCache;
float* m_pRanges;
diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h
index ed32d4b36a..ddfd95ccf3 100644
--- a/core/fpdfapi/page/cpdf_image.h
+++ b/core/fpdfapi/page/cpdf_image.h
@@ -10,10 +10,10 @@
#include <memory>
#include "core/fpdfapi/parser/cpdf_stream.h"
-#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/maybe_owned.h"
class CFX_DIBSource;
class CFX_DIBitmap;
@@ -80,8 +80,8 @@ class CPDF_Image : public CFX_Retainable {
bool m_bIsMask = false;
bool m_bInterpolate = false;
CFX_UnownedPtr<CPDF_Document> const m_pDocument;
- CFX_MaybeOwned<CPDF_Stream> m_pStream;
- CFX_MaybeOwned<CPDF_Dictionary> m_pDict;
+ MaybeOwned<CPDF_Stream> m_pStream;
+ MaybeOwned<CPDF_Dictionary> m_pDict;
CFX_UnownedPtr<CPDF_Dictionary> m_pOC;
};
diff --git a/core/fpdfapi/parser/cpdf_object_avail.h b/core/fpdfapi/parser/cpdf_object_avail.h
index 233d180c94..bd46cdba5c 100644
--- a/core/fpdfapi/parser/cpdf_object_avail.h
+++ b/core/fpdfapi/parser/cpdf_object_avail.h
@@ -10,8 +10,8 @@
#include <stack>
#include "core/fpdfapi/parser/cpdf_data_avail.h"
-#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/cfx_unowned_ptr.h"
+#include "core/fxcrt/maybe_owned.h"
class CPDF_Object;
class CPDF_Reference;
@@ -44,7 +44,7 @@ class CPDF_ObjectAvail {
CFX_UnownedPtr<CPDF_ReadValidator> validator_;
CFX_UnownedPtr<CPDF_IndirectObjectHolder> holder_;
- CFX_MaybeOwned<const CPDF_Object> root_;
+ MaybeOwned<const CPDF_Object> root_;
std::set<uint32_t> parsed_objnums_;
std::stack<uint32_t> non_parsed_objects_;
};
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index 75a381c8fc..e9f1752d57 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -25,8 +25,8 @@
#include "core/fpdfapi/render/cpdf_renderstatus.h"
#include "core/fpdfapi/render/cpdf_transferfunc.h"
#include "core/fpdfdoc/cpdf_occontext.h"
-#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "core/fxcrt/maybe_owned.h"
#include "core/fxge/cfx_defaultrenderdevice.h"
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/dib/cfx_dibitmap.h"
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 26eed112c5..ef07852e38 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -47,8 +47,8 @@
#include "core/fpdfdoc/cpdf_occontext.h"
#include "core/fxcrt/autorestorer.h"
#include "core/fxcrt/cfx_fixedbufgrow.h"
-#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "core/fxcrt/maybe_owned.h"
#include "core/fxge/cfx_defaultrenderdevice.h"
#include "core/fxge/cfx_graphstatedata.h"
#include "core/fxge/cfx_pathdata.h"
diff --git a/core/fpdfdoc/cpdf_annot.h b/core/fpdfdoc/cpdf_annot.h
index cf1b304670..cb579bbd3d 100644
--- a/core/fpdfdoc/cpdf_annot.h
+++ b/core/fpdfdoc/cpdf_annot.h
@@ -10,10 +10,10 @@
#include <map>
#include <memory>
-#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/maybe_owned.h"
class CFX_RenderDevice;
class CPDF_Dictionary;
@@ -110,7 +110,7 @@ class CPDF_Annot {
CFX_FloatRect RectForDrawing() const;
- CFX_MaybeOwned<CPDF_Dictionary> m_pAnnotDict;
+ MaybeOwned<CPDF_Dictionary> m_pAnnotDict;
CFX_UnownedPtr<CPDF_Document> const m_pDocument;
CPDF_Annot::Subtype m_nSubtype;
std::map<CPDF_Stream*, std::unique_ptr<CPDF_Form>> m_APMap;
diff --git a/core/fxcodec/jbig2/JBig2_TrdProc.cpp b/core/fxcodec/jbig2/JBig2_TrdProc.cpp
index 3fc43c067e..d513637a9d 100644
--- a/core/fxcodec/jbig2/JBig2_TrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_TrdProc.cpp
@@ -12,7 +12,7 @@
#include "core/fxcodec/jbig2/JBig2_ArithIntDecoder.h"
#include "core/fxcodec/jbig2/JBig2_GrrdProc.h"
#include "core/fxcodec/jbig2/JBig2_HuffmanDecoder.h"
-#include "core/fxcrt/cfx_maybe_owned.h"
+#include "core/fxcrt/maybe_owned.h"
#include "third_party/base/ptr_util.h"
CJBig2_TRDProc::CJBig2_TRDProc() {}
@@ -101,7 +101,7 @@ std::unique_ptr<CJBig2_Image> CJBig2_TRDProc::decode_Huffman(
if (SBREFINE != 0 && pStream->read1Bit(&RI) != 0)
return nullptr;
- CFX_MaybeOwned<CJBig2_Image> IBI;
+ MaybeOwned<CJBig2_Image> IBI;
if (RI == 0) {
IBI = SBSYMS[IDI];
} else {
@@ -214,16 +214,16 @@ std::unique_ptr<CJBig2_Image> CJBig2_TRDProc::decode_Arith(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* grContext,
JBig2IntDecoderState* pIDS) {
- CFX_MaybeOwned<CJBig2_ArithIntDecoder> pIADT;
- CFX_MaybeOwned<CJBig2_ArithIntDecoder> pIAFS;
- CFX_MaybeOwned<CJBig2_ArithIntDecoder> pIADS;
- CFX_MaybeOwned<CJBig2_ArithIntDecoder> pIAIT;
- CFX_MaybeOwned<CJBig2_ArithIntDecoder> pIARI;
- CFX_MaybeOwned<CJBig2_ArithIntDecoder> pIARDW;
- CFX_MaybeOwned<CJBig2_ArithIntDecoder> pIARDH;
- CFX_MaybeOwned<CJBig2_ArithIntDecoder> pIARDX;
- CFX_MaybeOwned<CJBig2_ArithIntDecoder> pIARDY;
- CFX_MaybeOwned<CJBig2_ArithIaidDecoder> pIAID;
+ MaybeOwned<CJBig2_ArithIntDecoder> pIADT;
+ MaybeOwned<CJBig2_ArithIntDecoder> pIAFS;
+ MaybeOwned<CJBig2_ArithIntDecoder> pIADS;
+ MaybeOwned<CJBig2_ArithIntDecoder> pIAIT;
+ MaybeOwned<CJBig2_ArithIntDecoder> pIARI;
+ MaybeOwned<CJBig2_ArithIntDecoder> pIARDW;
+ MaybeOwned<CJBig2_ArithIntDecoder> pIARDH;
+ MaybeOwned<CJBig2_ArithIntDecoder> pIARDX;
+ MaybeOwned<CJBig2_ArithIntDecoder> pIARDY;
+ MaybeOwned<CJBig2_ArithIaidDecoder> pIAID;
if (pIDS) {
pIADT = pIDS->IADT;
pIAFS = pIDS->IAFS;
@@ -299,7 +299,7 @@ std::unique_ptr<CJBig2_Image> CJBig2_TRDProc::decode_Arith(
else
pIARI->decode(pArithDecoder, &RI);
- CFX_MaybeOwned<CJBig2_Image> pIBI;
+ MaybeOwned<CJBig2_Image> pIBI;
if (RI == 0) {
pIBI = SBSYMS[IDI];
} else {
diff --git a/core/fxcrt/cfx_maybe_owned.h b/core/fxcrt/maybe_owned.h
index 8b08d9be37..11dd68642d 100644
--- a/core/fxcrt/cfx_maybe_owned.h
+++ b/core/fxcrt/maybe_owned.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CORE_FXCRT_CFX_MAYBE_OWNED_H_
-#define CORE_FXCRT_CFX_MAYBE_OWNED_H_
+#ifndef CORE_FXCRT_MAYBE_OWNED_H_
+#define CORE_FXCRT_MAYBE_OWNED_H_
#include <algorithm>
#include <memory>
@@ -12,20 +12,22 @@
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_system.h"
+namespace fxcrt {
+
// A template that can hold either owned or unowned references, and cleans up
// appropriately. Possibly the most pernicious anti-pattern imaginable, but
// it crops up throughout the codebase due to a desire to avoid copying-in
// objects or data.
template <typename T, typename D = std::default_delete<T>>
-class CFX_MaybeOwned {
+class MaybeOwned {
public:
- CFX_MaybeOwned() : m_pObj(nullptr) {}
- explicit CFX_MaybeOwned(T* ptr) : m_pObj(ptr) {}
- explicit CFX_MaybeOwned(std::unique_ptr<T, D> ptr)
+ MaybeOwned() : m_pObj(nullptr) {}
+ explicit MaybeOwned(T* ptr) : m_pObj(ptr) {}
+ explicit MaybeOwned(std::unique_ptr<T, D> ptr)
: m_pOwnedObj(std::move(ptr)), m_pObj(m_pOwnedObj.get()) {}
- CFX_MaybeOwned(const CFX_MaybeOwned& that) = delete;
- CFX_MaybeOwned(CFX_MaybeOwned&& that) noexcept
+ MaybeOwned(const MaybeOwned& that) = delete;
+ MaybeOwned(MaybeOwned&& that) noexcept
: m_pOwnedObj(that.m_pOwnedObj.release()), m_pObj(that.m_pObj) {
that.m_pObj = nullptr;
}
@@ -46,31 +48,29 @@ class CFX_MaybeOwned {
return std::move(m_pOwnedObj);
}
- CFX_MaybeOwned& operator=(const CFX_MaybeOwned& that) = delete;
- CFX_MaybeOwned& operator=(CFX_MaybeOwned&& that) {
+ MaybeOwned& operator=(const MaybeOwned& that) = delete;
+ MaybeOwned& operator=(MaybeOwned&& that) {
m_pOwnedObj = std::move(that.m_pOwnedObj);
m_pObj = that.m_pObj;
that.m_pObj = nullptr;
return *this;
}
- CFX_MaybeOwned& operator=(T* ptr) {
+ MaybeOwned& operator=(T* ptr) {
Reset(ptr);
return *this;
}
- CFX_MaybeOwned& operator=(std::unique_ptr<T, D> ptr) {
+ MaybeOwned& operator=(std::unique_ptr<T, D> ptr) {
Reset(std::move(ptr));
return *this;
}
- bool operator==(const CFX_MaybeOwned& that) const {
- return Get() == that.Get();
- }
+ bool operator==(const MaybeOwned& that) const { return Get() == that.Get(); }
bool operator==(const std::unique_ptr<T, D>& ptr) const {
return Get() == ptr.get();
}
bool operator==(T* ptr) const { return Get() == ptr; }
- bool operator!=(const CFX_MaybeOwned& that) const { return !(*this == that); }
+ bool operator!=(const MaybeOwned& that) const { return !(*this == that); }
bool operator!=(const std::unique_ptr<T, D> ptr) const {
return !(*this == ptr);
}
@@ -85,4 +85,8 @@ class CFX_MaybeOwned {
T* m_pObj;
};
-#endif // CORE_FXCRT_CFX_MAYBE_OWNED_H_
+} // namespace fxcrt
+
+using fxcrt::MaybeOwned;
+
+#endif // CORE_FXCRT_MAYBE_OWNED_H_
diff --git a/core/fxcrt/cfx_maybe_owned_unittest.cpp b/core/fxcrt/maybe_owned_unittest.cpp
index a716182ce5..686fa6ffd2 100644
--- a/core/fxcrt/cfx_maybe_owned_unittest.cpp
+++ b/core/fxcrt/maybe_owned_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_maybe_owned.h"
+#include "core/fxcrt/maybe_owned.h"
#include <memory>
#include <utility>
@@ -11,6 +11,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/base/ptr_util.h"
+namespace fxcrt {
+
namespace {
class PseudoDeletable {
@@ -27,29 +29,29 @@ class PseudoDeletable {
} // namespace
-TEST(fxcrt, MaybeOwnedNull) {
- CFX_MaybeOwned<PseudoDeletable> ptr1;
+TEST(MaybeOwned, Null) {
+ MaybeOwned<PseudoDeletable> ptr1;
EXPECT_FALSE(ptr1.IsOwned());
EXPECT_FALSE(ptr1);
EXPECT_EQ(nullptr, ptr1.Get());
- CFX_MaybeOwned<PseudoDeletable> ptr2;
+ MaybeOwned<PseudoDeletable> ptr2;
EXPECT_TRUE(ptr1 == ptr2);
EXPECT_FALSE(ptr1 != ptr2);
}
-TEST(fxcrt, MaybeOwnedNotOwned) {
+TEST(MaybeOwned, NotOwned) {
int delete_count = 0;
PseudoDeletable thing1(100, &delete_count);
{
- CFX_MaybeOwned<PseudoDeletable> ptr(&thing1);
+ MaybeOwned<PseudoDeletable> ptr(&thing1);
EXPECT_FALSE(ptr.IsOwned());
EXPECT_EQ(ptr.Get(), &thing1);
EXPECT_EQ(100, ptr->GetID());
EXPECT_TRUE(ptr == &thing1);
EXPECT_FALSE(ptr != &thing1);
- CFX_MaybeOwned<PseudoDeletable> empty;
+ MaybeOwned<PseudoDeletable> empty;
EXPECT_FALSE(ptr == empty);
EXPECT_TRUE(ptr != empty);
}
@@ -58,7 +60,7 @@ TEST(fxcrt, MaybeOwnedNotOwned) {
delete_count = 0;
PseudoDeletable thing2(200, &delete_count);
{
- CFX_MaybeOwned<PseudoDeletable> ptr(&thing1);
+ MaybeOwned<PseudoDeletable> ptr(&thing1);
ptr = &thing2;
EXPECT_FALSE(ptr.IsOwned());
EXPECT_EQ(ptr.Get(), &thing2);
@@ -69,7 +71,7 @@ TEST(fxcrt, MaybeOwnedNotOwned) {
delete_count = 0;
int owned_delete_count = 0;
{
- CFX_MaybeOwned<PseudoDeletable> ptr(&thing1);
+ MaybeOwned<PseudoDeletable> ptr(&thing1);
EXPECT_EQ(100, ptr->GetID());
ptr = pdfium::MakeUnique<PseudoDeletable>(300, &owned_delete_count);
EXPECT_TRUE(ptr.IsOwned());
@@ -79,15 +81,15 @@ TEST(fxcrt, MaybeOwnedNotOwned) {
EXPECT_EQ(1, owned_delete_count);
}
-TEST(fxcrt, MaybeOwnedOwned) {
+TEST(MaybeOwned, Owned) {
int delete_count = 0;
{
- CFX_MaybeOwned<PseudoDeletable> ptr(
+ MaybeOwned<PseudoDeletable> ptr(
pdfium::MakeUnique<PseudoDeletable>(100, &delete_count));
EXPECT_TRUE(ptr.IsOwned());
EXPECT_EQ(100, ptr->GetID());
- CFX_MaybeOwned<PseudoDeletable> empty;
+ MaybeOwned<PseudoDeletable> empty;
EXPECT_FALSE(ptr == empty);
EXPECT_TRUE(ptr != empty);
}
@@ -95,7 +97,7 @@ TEST(fxcrt, MaybeOwnedOwned) {
delete_count = 0;
{
- CFX_MaybeOwned<PseudoDeletable> ptr(
+ MaybeOwned<PseudoDeletable> ptr(
pdfium::MakeUnique<PseudoDeletable>(200, &delete_count));
ptr = pdfium::MakeUnique<PseudoDeletable>(300, &delete_count);
EXPECT_TRUE(ptr.IsOwned());
@@ -108,7 +110,7 @@ TEST(fxcrt, MaybeOwnedOwned) {
int unowned_delete_count = 0;
PseudoDeletable thing2(400, &unowned_delete_count);
{
- CFX_MaybeOwned<PseudoDeletable> ptr(
+ MaybeOwned<PseudoDeletable> ptr(
pdfium::MakeUnique<PseudoDeletable>(500, &delete_count));
ptr = &thing2;
EXPECT_FALSE(ptr.IsOwned());
@@ -120,12 +122,12 @@ TEST(fxcrt, MaybeOwnedOwned) {
EXPECT_EQ(0, unowned_delete_count);
}
-TEST(fxcrt, MaybeOwnedRelease) {
+TEST(MaybeOwned, Release) {
int delete_count = 0;
{
std::unique_ptr<PseudoDeletable> stolen;
{
- CFX_MaybeOwned<PseudoDeletable> ptr(
+ MaybeOwned<PseudoDeletable> ptr(
pdfium::MakeUnique<PseudoDeletable>(100, &delete_count));
EXPECT_TRUE(ptr.IsOwned());
stolen = ptr.Release();
@@ -138,18 +140,18 @@ TEST(fxcrt, MaybeOwnedRelease) {
EXPECT_EQ(1, delete_count);
}
-TEST(fxcrt, MaybeOwnedMove) {
+TEST(MaybeOwned, Move) {
int delete_count = 0;
PseudoDeletable thing1(100, &delete_count);
{
- CFX_MaybeOwned<PseudoDeletable> ptr1(&thing1);
- CFX_MaybeOwned<PseudoDeletable> ptr2(
+ MaybeOwned<PseudoDeletable> ptr1(&thing1);
+ MaybeOwned<PseudoDeletable> ptr2(
pdfium::MakeUnique<PseudoDeletable>(200, &delete_count));
EXPECT_FALSE(ptr1.IsOwned());
EXPECT_TRUE(ptr2.IsOwned());
- CFX_MaybeOwned<PseudoDeletable> ptr3(std::move(ptr1));
- CFX_MaybeOwned<PseudoDeletable> ptr4(std::move(ptr2));
+ MaybeOwned<PseudoDeletable> ptr3(std::move(ptr1));
+ MaybeOwned<PseudoDeletable> ptr4(std::move(ptr2));
EXPECT_FALSE(ptr1.IsOwned());
EXPECT_FALSE(ptr2.IsOwned());
EXPECT_FALSE(ptr3.IsOwned());
@@ -160,8 +162,8 @@ TEST(fxcrt, MaybeOwnedMove) {
EXPECT_EQ(100, ptr3->GetID());
EXPECT_EQ(200, ptr4->GetID());
- CFX_MaybeOwned<PseudoDeletable> ptr5;
- CFX_MaybeOwned<PseudoDeletable> ptr6;
+ MaybeOwned<PseudoDeletable> ptr5;
+ MaybeOwned<PseudoDeletable> ptr6;
ptr5 = std::move(ptr3);
ptr6 = std::move(ptr4);
EXPECT_FALSE(ptr3.IsOwned());
@@ -176,3 +178,5 @@ TEST(fxcrt, MaybeOwnedMove) {
}
EXPECT_EQ(1, delete_count);
}
+
+} // namespace fxcrt
diff --git a/core/fxge/dib/cfx_dibitmap.h b/core/fxge/dib/cfx_dibitmap.h
index fb676691ef..79eeaeb273 100644
--- a/core/fxge/dib/cfx_dibitmap.h
+++ b/core/fxge/dib/cfx_dibitmap.h
@@ -7,9 +7,9 @@
#ifndef CORE_FXGE_DIB_CFX_DIBITMAP_H_
#define CORE_FXGE_DIB_CFX_DIBITMAP_H_
-#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
+#include "core/fxcrt/maybe_owned.h"
#include "core/fxge/dib/cfx_dibsource.h"
#include "third_party/base/stl_util.h"
@@ -116,7 +116,7 @@ class CFX_DIBitmap : public CFX_DIBSource {
enum class Format { kCleared, kPreMultiplied, kUnPreMultiplied };
#endif
- CFX_MaybeOwned<uint8_t, FxFreeDeleter> m_pBuffer;
+ MaybeOwned<uint8_t, FxFreeDeleter> m_pBuffer;
#if defined _SKIA_SUPPORT_PATHS_
Format m_nFormat;
#endif
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index 651088602e..7e21b25411 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -15,7 +15,7 @@
#include "core/fxcodec/codec/ccodec_flatemodule.h"
#include "core/fxcodec/codec/ccodec_jpegmodule.h"
#include "core/fxcodec/fx_codec.h"
-#include "core/fxcrt/cfx_maybe_owned.h"
+#include "core/fxcrt/maybe_owned.h"
#include "core/fxge/cfx_facecache.h"
#include "core/fxge/cfx_fontcache.h"
#include "core/fxge/cfx_gemodule.h"
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index ca5195fb5a..ac13266444 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -10,10 +10,10 @@
#include <memory>
#include <vector>
-#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/maybe_owned.h"
#include "core/fxge/cfx_folderfontinfo.h"
#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/cfx_windowsrenderdevice.h"
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 07d089b6c4..0935f56b90 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -14,8 +14,8 @@
#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
#include "core/fxcodec/codec/ccodec_progressivedecoder.h"
#include "core/fxcodec/fx_codec.h"
-#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/cfx_memorystream.h"
+#include "core/fxcrt/maybe_owned.h"
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/dib/cfx_imagerenderer.h"