Index: core/fpdfapi/parser/cpdf_parser_unittest.cpp |
diff --git a/core/fpdfapi/parser/cpdf_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_parser_unittest.cpp |
index 61496a156212f7b5c2ab3c35cf1300f4acdad349..3518f7d16bf54a41084d6eba8606ab82d10fc205 100644 |
--- a/core/fpdfapi/parser/cpdf_parser_unittest.cpp |
+++ b/core/fpdfapi/parser/cpdf_parser_unittest.cpp |
@@ -7,6 +7,7 @@ |
#include "core/fpdfapi/parser/cpdf_parser.h" |
#include "core/fpdfapi/parser/cpdf_syntax_parser.h" |
+#include "core/fxcrt/cfx_retain_ptr.h" |
#include "core/fxcrt/fx_ext.h" |
#include "core/fxcrt/fx_stream.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -15,11 +16,12 @@ |
// Provide a way to read test data from a buffer instead of a file. |
class CFX_TestBufferRead : public IFX_SeekableReadStream { |
public: |
- CFX_TestBufferRead(const unsigned char* buffer_in, size_t buf_size) |
- : buffer_(buffer_in), total_size_(buf_size) {} |
- |
- // IFX_ReadStream: |
- void Release() override { delete this; } |
+ static CFX_RetainPtr<CFX_TestBufferRead> Create( |
+ const unsigned char* buffer_in, |
+ size_t buf_size) { |
+ return CFX_RetainPtr<CFX_TestBufferRead>( |
+ new CFX_TestBufferRead(buffer_in, buf_size)); |
+ } |
// IFX_SeekableReadStream: |
bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { |
@@ -33,6 +35,9 @@ class CFX_TestBufferRead : public IFX_SeekableReadStream { |
FX_FILESIZE GetSize() override { return (FX_FILESIZE)total_size_; }; |
protected: |
+ CFX_TestBufferRead(const unsigned char* buffer_in, size_t buf_size) |
+ : buffer_(buffer_in), total_size_(buf_size) {} |
+ |
const unsigned char* buffer_; |
size_t total_size_; |
}; |
@@ -45,7 +50,7 @@ class CPDF_TestParser : public CPDF_Parser { |
// Setup reading from a file and initial states. |
bool InitTestFromFile(const FX_CHAR* path) { |
- IFX_SeekableReadStream* pFileAccess = |
+ CFX_RetainPtr<IFX_SeekableReadStream> pFileAccess = |
IFX_SeekableReadStream::CreateFromFilename(path); |
if (!pFileAccess) |
return false; |
@@ -57,7 +62,8 @@ class CPDF_TestParser : public CPDF_Parser { |
// Setup reading from a buffer and initial states. |
bool InitTestFromBuffer(const unsigned char* buffer, size_t len) { |
- CFX_TestBufferRead* buffer_reader = new CFX_TestBufferRead(buffer, len); |
+ CFX_RetainPtr<CFX_TestBufferRead> buffer_reader = |
+ CFX_TestBufferRead::Create(buffer, len); |
// For the test file, the header is set at the beginning. |
m_pSyntax->InitParser(buffer_reader, 0); |