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

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

Issue 2545653003: Make more concrete stream classes private to .cpp files (Closed)
Patch Set: Created 4 years 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 | « no previous file | core/fxcrt/fx_extension.cpp » ('j') | core/fxcrt/fx_extension.cpp » ('J')
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>
(...skipping 16 matching lines...) Expand all
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 bool Flush() = 0; 33 virtual bool Flush() = 0;
34 virtual bool Truncate(FX_FILESIZE szFile) = 0; 34 virtual bool Truncate(FX_FILESIZE szFile) = 0;
35 }; 35 };
36 36
37 #ifdef PDF_ENABLE_XFA
38 class CFX_CRTFileAccess : public IFX_FileAccess {
39 public:
40 CFX_CRTFileAccess();
41 ~CFX_CRTFileAccess() override;
42
43 // IFX_FileAccess
44 void Release() override;
45 IFX_FileAccess* Retain() override;
46 void GetPath(CFX_WideString& wsPath) override;
47 IFX_SeekableStream* CreateFileStream(uint32_t dwModes) override;
48
49 bool Init(const CFX_WideStringC& wsPath);
50
51 protected:
52 CFX_WideString m_path;
53 uint32_t m_RefCount;
54 };
55 #endif // PDF_ENABLE_XFA
56
57 class CFX_CRTFileStream final : public IFX_SeekableStream {
58 public:
59 explicit CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA);
60 ~CFX_CRTFileStream() override;
61
62 // IFX_SeekableStream:
63 IFX_SeekableStream* Retain() override;
64 void Release() override;
65 FX_FILESIZE GetSize() override;
66 bool IsEOF() override;
67 FX_FILESIZE GetPosition() override;
68 bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
69 size_t ReadBlock(void* buffer, size_t size) override;
70 bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
71 bool Flush() override;
72
73 protected:
74 std::unique_ptr<IFXCRT_FileAccess> m_pFile;
75 uint32_t m_dwCount;
76 };
77
78 #define FX_MEMSTREAM_BlockSize (64 * 1024)
79 #define FX_MEMSTREAM_Consecutive 0x01
80 #define FX_MEMSTREAM_TakeOver 0x02
81
82 class CFX_MemoryStream final : public IFX_MemoryStream {
83 public:
84 explicit CFX_MemoryStream(bool bConsecutive);
85 CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, bool bTakeOver);
86 ~CFX_MemoryStream() override;
87
88 // IFX_MemoryStream
89 IFX_SeekableStream* Retain() override;
90 void Release() override;
91 FX_FILESIZE GetSize() override;
92 bool IsEOF() override;
93 FX_FILESIZE GetPosition() override;
94 bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
95 size_t ReadBlock(void* buffer, size_t size) override;
96 bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
97 bool Flush() override;
98 bool IsConsecutive() const override;
99 void EstimateSize(size_t nInitSize, size_t nGrowSize) override;
100 uint8_t* GetBuffer() const override;
101 void AttachBuffer(uint8_t* pBuffer,
102 size_t nSize,
103 bool bTakeOver = false) override;
104 void DetachBuffer() override;
105
106 protected:
107 CFX_ArrayTemplate<uint8_t*> m_Blocks;
108 uint32_t m_dwCount;
109 size_t m_nTotalSize;
110 size_t m_nCurSize;
111 size_t m_nCurPos;
112 size_t m_nGrowSize;
113 uint32_t m_dwFlags;
114 bool ExpandBlocks(size_t size);
115 };
116
117 #ifdef __cplusplus 37 #ifdef __cplusplus
118 extern "C" { 38 extern "C" {
119 #endif 39 #endif
120 #define MT_N 848 40 #define MT_N 848
121 #define MT_M 456 41 #define MT_M 456
122 #define MT_Matrix_A 0x9908b0df 42 #define MT_Matrix_A 0x9908b0df
123 #define MT_Upper_Mask 0x80000000 43 #define MT_Upper_Mask 0x80000000
124 #define MT_Lower_Mask 0x7fffffff 44 #define MT_Lower_Mask 0x7fffffff
125 struct FX_MTRANDOMCONTEXT { 45 struct FX_MTRANDOMCONTEXT {
126 FX_MTRANDOMCONTEXT() { 46 FX_MTRANDOMCONTEXT() {
127 mti = MT_N + 1; 47 mti = MT_N + 1;
128 bHaveSeed = false; 48 bHaveSeed = false;
129 } 49 }
130 uint32_t mti; 50 uint32_t mti;
131 bool bHaveSeed; 51 bool bHaveSeed;
132 uint32_t mt[MT_N]; 52 uint32_t mt[MT_N];
133 }; 53 };
134 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 54 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
135 bool FX_GenerateCryptoRandom(uint32_t* pBuffer, int32_t iCount); 55 bool FX_GenerateCryptoRandom(uint32_t* pBuffer, int32_t iCount);
136 #endif 56 #endif
137 #ifdef __cplusplus 57 #ifdef __cplusplus
138 } 58 }
139 #endif 59 #endif
140 60
141 #endif // CORE_FXCRT_EXTENSION_H_ 61 #endif // CORE_FXCRT_EXTENSION_H_
OLDNEW
« no previous file with comments | « no previous file | core/fxcrt/fx_extension.cpp » ('j') | core/fxcrt/fx_extension.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698