summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_nodeowner.h
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-02-13 20:55:03 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-13 20:55:03 +0000
commit80bf582f00adeefae67ae432b74c3b0609e7845e (patch)
tree18c88bc620fcded6fc39cdfe3a5b0ae04643424d /xfa/fxfa/parser/cxfa_nodeowner.h
parent566d0b9486f024f253d1c331866b04529c9a22b3 (diff)
downloadpdfium-80bf582f00adeefae67ae432b74c3b0609e7845e.tar.xz
Cleanup CXFA_Node ownership
Currently a CXFA_Node can be owned by the CXFA_Document root pointer, the CXFA_Document Purge list or as a child of another CXFA_Node. This makes it hard to know who currently owns what. This CL moves all ownership of nodes into a CXFA_NodeOwner class which CXFA_Document subclasses. The node owner always owns all nodes and is responsible for cleaning them up upon destruction. The destruction order is not guarenteed to be in tree order as nodes can be inserted and moved around the tree. Change-Id: I6b202b8e844999ba835093dcdd1a808938b6d9a8 Reviewed-on: https://pdfium-review.googlesource.com/26434 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_nodeowner.h')
-rw-r--r--xfa/fxfa/parser/cxfa_nodeowner.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_nodeowner.h b/xfa/fxfa/parser/cxfa_nodeowner.h
new file mode 100644
index 0000000000..2aaabe4118
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_nodeowner.h
@@ -0,0 +1,28 @@
+// Copyright 2018 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_NODEOWNER_H_
+#define XFA_FXFA_PARSER_CXFA_NODEOWNER_H_
+
+#include <memory>
+#include <set>
+
+class CXFA_Node;
+
+class CXFA_NodeOwner {
+ public:
+ virtual ~CXFA_NodeOwner();
+
+ CXFA_Node* AddOwnedNode(std::unique_ptr<CXFA_Node> node);
+ void FreeOwnedNode(CXFA_Node* node);
+
+ protected:
+ CXFA_NodeOwner();
+
+ std::set<std::unique_ptr<CXFA_Node>> nodes_;
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_NODEOWNER_H_