Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "public/fpdfview.h" | 7 #include "public/fpdfview.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 } | 239 } |
| 240 | 240 |
| 241 bool CFPDF_FileStream::Flush() { | 241 bool CFPDF_FileStream::Flush() { |
| 242 if (!m_pFS || !m_pFS->Flush) | 242 if (!m_pFS || !m_pFS->Flush) |
| 243 return true; | 243 return true; |
| 244 | 244 |
| 245 return m_pFS->Flush(m_pFS->clientData) == 0; | 245 return m_pFS->Flush(m_pFS->clientData) == 0; |
| 246 } | 246 } |
| 247 #endif // PDF_ENABLE_XFA | 247 #endif // PDF_ENABLE_XFA |
| 248 | 248 |
| 249 class CPDF_CustomAccess final : public IFX_SeekableReadStream { | |
|
npm
2016/12/01 21:21:49
Can this go inside namespace?
Tom Sepez
2016/12/01 21:33:45
Done.
| |
| 250 public: | |
| 251 explicit CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess); | |
| 252 ~CPDF_CustomAccess() override {} | |
| 253 | |
| 254 // IFX_SeekableReadStream | |
| 255 FX_FILESIZE GetSize() override; | |
| 256 void Release() override; | |
| 257 bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; | |
| 258 | |
| 259 private: | |
| 260 FPDF_FILEACCESS m_FileAccess; | |
| 261 }; | |
| 262 | |
| 263 IFX_SeekableReadStream* MakeSeekableReadStream(FPDF_FILEACCESS* pFileAccess) { | |
| 264 return new CPDF_CustomAccess(pFileAccess); | |
| 265 } | |
| 266 | |
| 249 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) | 267 CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) |
| 250 : m_FileAccess(*pFileAccess) {} | 268 : m_FileAccess(*pFileAccess) {} |
| 251 | 269 |
| 252 FX_FILESIZE CPDF_CustomAccess::GetSize() { | 270 FX_FILESIZE CPDF_CustomAccess::GetSize() { |
| 253 return m_FileAccess.m_FileLen; | 271 return m_FileAccess.m_FileLen; |
| 254 } | 272 } |
| 255 | 273 |
| 256 void CPDF_CustomAccess::Release() { | 274 void CPDF_CustomAccess::Release() { |
| 257 delete this; | 275 delete this; |
| 258 } | 276 } |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1177 if (!buffer) { | 1195 if (!buffer) { |
| 1178 *buflen = len; | 1196 *buflen = len; |
| 1179 } else if (len <= *buflen) { | 1197 } else if (len <= *buflen) { |
| 1180 memcpy(buffer, utf16Name.c_str(), len); | 1198 memcpy(buffer, utf16Name.c_str(), len); |
| 1181 *buflen = len; | 1199 *buflen = len; |
| 1182 } else { | 1200 } else { |
| 1183 *buflen = -1; | 1201 *buflen = -1; |
| 1184 } | 1202 } |
| 1185 return (FPDF_DEST)pDestObj; | 1203 return (FPDF_DEST)pDestObj; |
| 1186 } | 1204 } |
| OLD | NEW |