Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1637)

Unified Diff: core/fpdfapi/parser/cpdf_indirect_object_holder.h

Issue 2489283003: Make AddIndirectObject() take a unique_ptr. (Closed)
Patch Set: Address review comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfapi/parser/cpdf_document_unittest.cpp ('k') | core/fpdfapi/parser/cpdf_indirect_object_holder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/parser/cpdf_indirect_object_holder.h
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.h b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
index db6f4acbf40eddbb9dd9e19d0a37a02210c8e4a6..428bfa05ecf97eb3b86b3e207168fc70aa7e8d59 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.h
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
@@ -11,6 +11,7 @@
#include <memory>
#include "core/fxcrt/fx_system.h"
+#include "third_party/base/ptr_util.h"
class CPDF_Object;
@@ -26,8 +27,17 @@ class CPDF_IndirectObjectHolder {
CPDF_Object* GetOrParseIndirectObject(uint32_t objnum);
void DeleteIndirectObject(uint32_t objnum);
- // Take ownership of |pObj|.
- uint32_t AddIndirectObject(CPDF_Object* pObj);
+ // Creates and adds a new object owned by the indirect object holder,
+ // and returns an unowned pointer to it.
+ template <typename T, typename... Args>
+ T* NewIndirect(Args... args) {
+ return static_cast<T*>(AddIndirectObject(pdfium::MakeUnique<T>(args...)));
+ }
+
+ // Takes ownership of |pObj|, returns unowned pointer to it.
+ CPDF_Object* AddIndirectObject(std::unique_ptr<CPDF_Object> pObj);
+
+ // Always takes ownership of |pObj|, return true if higher generation number.
bool ReplaceIndirectObjectIfHigherGeneration(
uint32_t objnum,
std::unique_ptr<CPDF_Object> pObj);
« no previous file with comments | « core/fpdfapi/parser/cpdf_document_unittest.cpp ('k') | core/fpdfapi/parser/cpdf_indirect_object_holder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698