M76: Replace UnownedPtr with RetainPtr to parser objects in fpdfdoc
This is the original CL, but modified to use const RetainPtrs,
plus the change to retain_ptr.h to allow const RetainPtrs. In that
way, the public headers plus intermediate changes are not required.
Bug: chromium:983867
Change-Id: I975628c5c60e6337afd496ade2371a4c1b69e84a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/58191
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
(cherry picked from commit 9d03368411ccb46b1e39693f9d1723a9b2f34dd7)
(cherry picked from commit ada1063d93b03c7b8dfa9ad109837a71159f12a7)
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/58410
diff --git a/core/fpdfdoc/cpdf_aaction.h b/core/fpdfdoc/cpdf_aaction.h
index edd3539..c3c65e8 100644
--- a/core/fpdfdoc/cpdf_aaction.h
+++ b/core/fpdfdoc/cpdf_aaction.h
@@ -8,6 +8,7 @@
#define CORE_FPDFDOC_CPDF_AACTION_H_
#include "core/fpdfdoc/cpdf_action.h"
+#include "core/fxcrt/retain_ptr.h"
class CPDF_Dictionary;
@@ -50,7 +51,7 @@
static bool IsUserClick(AActionType eType);
private:
- UnownedPtr<const CPDF_Dictionary> const m_pDict;
+ RetainPtr<const CPDF_Dictionary> const m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_AACTION_H_
diff --git a/core/fpdfdoc/cpdf_action.h b/core/fpdfdoc/cpdf_action.h
index f0f8679..f41d917 100644
--- a/core/fpdfdoc/cpdf_action.h
+++ b/core/fpdfdoc/cpdf_action.h
@@ -9,6 +9,7 @@
#include "core/fpdfdoc/cpdf_dest.h"
#include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/retain_ptr.h"
class CPDF_Dictionary;
class CPDF_Document;
@@ -54,7 +55,7 @@
CPDF_Action GetSubAction(size_t iIndex) const;
private:
- UnownedPtr<const CPDF_Dictionary> const m_pDict;
+ RetainPtr<const CPDF_Dictionary> const m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_ACTION_H_
diff --git a/core/fpdfdoc/cpdf_bookmark.h b/core/fpdfdoc/cpdf_bookmark.h
index 47fd071..d38ce0c 100644
--- a/core/fpdfdoc/cpdf_bookmark.h
+++ b/core/fpdfdoc/cpdf_bookmark.h
@@ -10,7 +10,7 @@
#include "core/fpdfdoc/cpdf_action.h"
#include "core/fpdfdoc/cpdf_dest.h"
#include "core/fxcrt/fx_string.h"
-#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxcrt/retain_ptr.h"
class CPDF_Dictionary;
class CPDF_Document;
@@ -29,7 +29,7 @@
CPDF_Action GetAction() const;
private:
- UnownedPtr<const CPDF_Dictionary> m_pDict;
+ RetainPtr<const CPDF_Dictionary> m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_BOOKMARK_H_
diff --git a/core/fpdfdoc/cpdf_dest.h b/core/fpdfdoc/cpdf_dest.h
index e6e673e..298d753 100644
--- a/core/fpdfdoc/cpdf_dest.h
+++ b/core/fpdfdoc/cpdf_dest.h
@@ -9,7 +9,7 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
-#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxcrt/retain_ptr.h"
class CPDF_Document;
class CPDF_Array;
@@ -39,7 +39,7 @@
float* pZoom) const;
private:
- UnownedPtr<const CPDF_Array> const m_pArray;
+ RetainPtr<const CPDF_Array> const m_pArray;
};
#endif // CORE_FPDFDOC_CPDF_DEST_H_
diff --git a/core/fxcrt/retain_ptr.h b/core/fxcrt/retain_ptr.h
index 683ea74..d629bc4 100644
--- a/core/fxcrt/retain_ptr.h
+++ b/core/fxcrt/retain_ptr.h
@@ -115,14 +115,14 @@
Retainable(const Retainable& that) = delete;
Retainable& operator=(const Retainable& that) = delete;
- void Retain() { ++m_nRefCount; }
- void Release() {
+ void Retain() const { ++m_nRefCount; }
+ void Release() const {
ASSERT(m_nRefCount > 0);
if (--m_nRefCount == 0)
delete this;
}
- intptr_t m_nRefCount = 0;
+ mutable intptr_t m_nRefCount = 0;
};
} // namespace fxcrt