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

Side by Side Diff: core/fxcrt/extension.h

Issue 2450183003: Fix some FX_BOOL / int noise in fxcrt. (Closed)
Patch Set: moar 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 unified diff | Download patch
« no previous file with comments | « core/fpdfapi/parser/cpdf_parser_unittest.cpp ('k') | core/fxcrt/fx_basic_buffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_FXCRT_EXTENSION_H_ 7 #ifndef CORE_FXCRT_EXTENSION_H_
8 #define CORE_FXCRT_EXTENSION_H_ 8 #define CORE_FXCRT_EXTENSION_H_
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <memory> 11 #include <memory>
12 12
13 #include "core/fxcrt/fx_basic.h" 13 #include "core/fxcrt/fx_basic.h"
14 #include "core/fxcrt/fx_safe_types.h" 14 #include "core/fxcrt/fx_safe_types.h"
15 15
16 class IFXCRT_FileAccess { 16 class IFXCRT_FileAccess {
17 public: 17 public:
18 static IFXCRT_FileAccess* Create(); 18 static IFXCRT_FileAccess* Create();
19 virtual ~IFXCRT_FileAccess() {} 19 virtual ~IFXCRT_FileAccess() {}
20 20
21 virtual FX_BOOL Open(const CFX_ByteStringC& fileName, uint32_t dwMode) = 0; 21 virtual bool Open(const CFX_ByteStringC& fileName, uint32_t dwMode) = 0;
22 virtual FX_BOOL Open(const CFX_WideStringC& fileName, uint32_t dwMode) = 0; 22 virtual bool Open(const CFX_WideStringC& fileName, uint32_t dwMode) = 0;
23 virtual void Close() = 0; 23 virtual void Close() = 0;
24 virtual FX_FILESIZE GetSize() const = 0; 24 virtual FX_FILESIZE GetSize() const = 0;
25 virtual FX_FILESIZE GetPosition() const = 0; 25 virtual FX_FILESIZE GetPosition() const = 0;
26 virtual FX_FILESIZE SetPosition(FX_FILESIZE pos) = 0; 26 virtual FX_FILESIZE SetPosition(FX_FILESIZE pos) = 0;
27 virtual size_t Read(void* pBuffer, size_t szBuffer) = 0; 27 virtual size_t Read(void* pBuffer, size_t szBuffer) = 0;
28 virtual size_t Write(const void* pBuffer, size_t szBuffer) = 0; 28 virtual size_t Write(const void* pBuffer, size_t szBuffer) = 0;
29 virtual size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) = 0; 29 virtual size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) = 0;
30 virtual size_t WritePos(const void* pBuffer, 30 virtual size_t WritePos(const void* pBuffer,
31 size_t szBuffer, 31 size_t szBuffer,
32 FX_FILESIZE pos) = 0; 32 FX_FILESIZE pos) = 0;
33 virtual FX_BOOL Flush() = 0; 33 virtual bool Flush() = 0;
34 virtual FX_BOOL Truncate(FX_FILESIZE szFile) = 0; 34 virtual bool Truncate(FX_FILESIZE szFile) = 0;
35 }; 35 };
36 36
37 #ifdef PDF_ENABLE_XFA 37 #ifdef PDF_ENABLE_XFA
38 class CFX_CRTFileAccess : public IFX_FileAccess { 38 class CFX_CRTFileAccess : public IFX_FileAccess {
39 public: 39 public:
40 CFX_CRTFileAccess(); 40 CFX_CRTFileAccess();
41 ~CFX_CRTFileAccess() override; 41 ~CFX_CRTFileAccess() override;
42 42
43 // IFX_FileAccess 43 // IFX_FileAccess
44 void Release() override; 44 void Release() override;
(...skipping 11 matching lines...) Expand all
56 56
57 class CFX_CRTFileStream final : public IFX_SeekableStream { 57 class CFX_CRTFileStream final : public IFX_SeekableStream {
58 public: 58 public:
59 explicit CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA); 59 explicit CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA);
60 ~CFX_CRTFileStream() override; 60 ~CFX_CRTFileStream() override;
61 61
62 // IFX_SeekableStream: 62 // IFX_SeekableStream:
63 IFX_SeekableStream* Retain() override; 63 IFX_SeekableStream* Retain() override;
64 void Release() override; 64 void Release() override;
65 FX_FILESIZE GetSize() override; 65 FX_FILESIZE GetSize() override;
66 FX_BOOL IsEOF() override; 66 bool IsEOF() override;
67 FX_FILESIZE GetPosition() override; 67 FX_FILESIZE GetPosition() override;
68 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; 68 bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
69 size_t ReadBlock(void* buffer, size_t size) override; 69 size_t ReadBlock(void* buffer, size_t size) override;
70 FX_BOOL WriteBlock(const void* buffer, 70 bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
71 FX_FILESIZE offset, 71 bool Flush() override;
72 size_t size) override;
73 FX_BOOL Flush() override;
74 72
75 protected: 73 protected:
76 std::unique_ptr<IFXCRT_FileAccess> m_pFile; 74 std::unique_ptr<IFXCRT_FileAccess> m_pFile;
77 uint32_t m_dwCount; 75 uint32_t m_dwCount;
78 }; 76 };
79 77
80 #define FX_MEMSTREAM_BlockSize (64 * 1024) 78 #define FX_MEMSTREAM_BlockSize (64 * 1024)
81 #define FX_MEMSTREAM_Consecutive 0x01 79 #define FX_MEMSTREAM_Consecutive 0x01
82 #define FX_MEMSTREAM_TakeOver 0x02 80 #define FX_MEMSTREAM_TakeOver 0x02
81
83 class CFX_MemoryStream final : public IFX_MemoryStream { 82 class CFX_MemoryStream final : public IFX_MemoryStream {
84 public: 83 public:
85 explicit CFX_MemoryStream(FX_BOOL bConsecutive); 84 explicit CFX_MemoryStream(FX_BOOL bConsecutive);
86 CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver); 85 CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver);
87 ~CFX_MemoryStream() override; 86 ~CFX_MemoryStream() override;
88 87
89 // IFX_MemoryStream 88 // IFX_MemoryStream
90 IFX_SeekableStream* Retain() override; 89 IFX_SeekableStream* Retain() override;
91 void Release() override; 90 void Release() override;
92 FX_FILESIZE GetSize() override; 91 FX_FILESIZE GetSize() override;
93 FX_BOOL IsEOF() override; 92 bool IsEOF() override;
94 FX_FILESIZE GetPosition() override; 93 FX_FILESIZE GetPosition() override;
95 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; 94 bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
96 size_t ReadBlock(void* buffer, size_t size) override; 95 size_t ReadBlock(void* buffer, size_t size) override;
97 FX_BOOL WriteBlock(const void* buffer, 96 bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
98 FX_FILESIZE offset, 97 bool Flush() override;
99 size_t size) override; 98 bool IsConsecutive() const override;
100 FX_BOOL Flush() override;
101 FX_BOOL IsConsecutive() const override;
102 void EstimateSize(size_t nInitSize, size_t nGrowSize) override; 99 void EstimateSize(size_t nInitSize, size_t nGrowSize) override;
103 uint8_t* GetBuffer() const override; 100 uint8_t* GetBuffer() const override;
104 void AttachBuffer(uint8_t* pBuffer, 101 void AttachBuffer(uint8_t* pBuffer,
105 size_t nSize, 102 size_t nSize,
106 FX_BOOL bTakeOver = FALSE) override; 103 bool bTakeOver = FALSE) override;
107 void DetachBuffer() override; 104 void DetachBuffer() override;
108 105
109 protected: 106 protected:
110 CFX_ArrayTemplate<uint8_t*> m_Blocks; 107 CFX_ArrayTemplate<uint8_t*> m_Blocks;
111 uint32_t m_dwCount; 108 uint32_t m_dwCount;
112 size_t m_nTotalSize; 109 size_t m_nTotalSize;
113 size_t m_nCurSize; 110 size_t m_nCurSize;
114 size_t m_nCurPos; 111 size_t m_nCurPos;
115 size_t m_nGrowSize; 112 size_t m_nGrowSize;
116 uint32_t m_dwFlags; 113 uint32_t m_dwFlags;
(...skipping 18 matching lines...) Expand all
135 uint32_t mt[MT_N]; 132 uint32_t mt[MT_N];
136 }; 133 };
137 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 134 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
138 FX_BOOL FX_GenerateCryptoRandom(uint32_t* pBuffer, int32_t iCount); 135 FX_BOOL FX_GenerateCryptoRandom(uint32_t* pBuffer, int32_t iCount);
139 #endif 136 #endif
140 #ifdef __cplusplus 137 #ifdef __cplusplus
141 } 138 }
142 #endif 139 #endif
143 140
144 #endif // CORE_FXCRT_EXTENSION_H_ 141 #endif // CORE_FXCRT_EXTENSION_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_parser_unittest.cpp ('k') | core/fxcrt/fx_basic_buffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698