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 #ifndef PUBLIC_FPDF_DATAAVAIL_H_ | 7 #ifndef PUBLIC_FPDF_DATAAVAIL_H_ |
| 8 #define PUBLIC_FPDF_DATAAVAIL_H_ | 8 #define PUBLIC_FPDF_DATAAVAIL_H_ |
| 9 | 9 |
| 10 #include <stddef.h> // For size_t. | 10 #include <stddef.h> |
| 11 | 11 |
| 12 #include "fpdfview.h" | 12 #include "fpdfview.h" |
| 13 | 13 |
| 14 #define PDF_LINEARIZATION_UNKNOWN -1 | 14 #define PDF_LINEARIZATION_UNKNOWN -1 |
| 15 #define PDF_NOT_LINEARIZED 0 | 15 #define PDF_NOT_LINEARIZED 0 |
| 16 #define PDF_LINEARIZED 1 | 16 #define PDF_LINEARIZED 1 |
| 17 | 17 |
| 18 #define PDF_DATA_ERROR -1 | 18 #define PDF_DATA_ERROR -1 |
| 19 #define PDF_DATA_NOTAVAIL 0 | 19 #define PDF_DATA_NOTAVAIL 0 |
| 20 #define PDF_DATA_AVAIL 1 | 20 #define PDF_DATA_AVAIL 1 |
| 21 | 21 |
| 22 #define PDF_FORM_ERROR -1 | 22 #define PDF_FORM_ERROR -1 |
| 23 #define PDF_FORM_NOTAVAIL 0 | 23 #define PDF_FORM_NOTAVAIL 0 |
| 24 #define PDF_FORM_AVAIL 1 | 24 #define PDF_FORM_AVAIL 1 |
| 25 #define PDF_FORM_NOTEXIST 2 | 25 #define PDF_FORM_NOTEXIST 2 |
| 26 | 26 |
| 27 #ifdef __cplusplus | 27 #ifdef __cplusplus |
| 28 extern "C" { | 28 extern "C" { |
| 29 #endif | 29 #endif // __cplusplus |
| 30 | 30 |
| 31 /** | 31 // Interface for checking whether the section of the file is available. |
| 32 * Interface: FX_FILEAVAIL | |
| 33 * Interface for checking whether the section of the file is available. | |
| 34 */ | |
| 35 typedef struct _FX_FILEAVAIL { | 32 typedef struct _FX_FILEAVAIL { |
| 36 /** | 33 // Version number of the interface. Must be 1. |
| 37 * Version number of the interface. Currently must be 1. | |
| 38 */ | |
| 39 int version; | 34 int version; |
| 40 | 35 |
| 41 /** | 36 // Reports if the specified data section is available. A section is |
| 42 * Method: IsDataAvail | 37 // available if all bytes in the section are available. |
| 43 * Report whether the specified data section is available. A section is | 38 // |
| 44 * available only if all bytes in the section is available. | 39 // Interface Version: 1 |
| 45 * Interface Version: | 40 // Implementation Required: Yes |
| 46 * 1 | 41 // |
| 47 * Implementation Required: | 42 // |pThis| - pointer to the interface structure. |
|
Tom Sepez
2016/03/22 15:51:35
nit: I don't think we need the vertical bars in a
dsinclair
2016/03/22 16:02:50
Ack.
| |
| 48 * Yes | 43 // |offset| - the offset of the data section in the file. |
| 49 * Parameters: | 44 // |size| - the size of the data section |
| 50 * pThis - Pointer to the interface structure itself. | 45 // |
| 51 * offset - The offset of the data section in the file. | 46 // Returns true if the specified data section at |offset| of |size| |
| 52 * size - The size of the data section | 47 // is available. |
| 53 * Return Value: | |
| 54 * true means the specified data section is available. | |
| 55 * Comments: | |
| 56 * Called by Foxit SDK to check whether the data section is ready. | |
| 57 */ | |
| 58 FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, | 48 FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, |
| 59 size_t offset, | 49 size_t offset, |
| 60 size_t size); | 50 size_t size); |
| 61 } FX_FILEAVAIL; | 51 } FX_FILEAVAIL; |
| 62 | |
| 63 typedef void* FPDF_AVAIL; | 52 typedef void* FPDF_AVAIL; |
| 64 | 53 |
| 65 /** | 54 // Create a document availability provider. |
| 66 * Function: FPDFAvail_Create | 55 // |
| 67 * Create a document availability provider. | 56 // |file_avail| - pointer to file availability interface. |
| 68 * | 57 // |file| - pointer to a file access interface |
| 69 * Parameters: | 58 // |
| 70 * file_avail - Pointer to file availability interface to check | 59 // Returns a handle to the document availability provider. NULL otherwise. |
| 71 * availability of file data. | 60 // |
| 72 * file - Pointer to a file access interface for reading data | 61 // |FPDFAvail_Destroy| must be called when done with the availability provider. |
| 73 * from file. | |
| 74 * Return value: | |
| 75 * A handle to the document availability provider. NULL for error. | |
| 76 * Comments: | |
| 77 * Application must call FPDFAvail_Destroy when done with the | |
| 78 * availability provider. | |
| 79 */ | |
| 80 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, | 62 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, |
| 81 FPDF_FILEACCESS* file); | 63 FPDF_FILEACCESS* file); |
| 82 | 64 |
| 83 /** | 65 // Destroy the |avail| document availability provider. |
| 84 * Function: FPDFAvail_Destroy | 66 // |
| 85 * Destroy a document availibity provider. | 67 // |avail| - handle to document availability provider to be destroyed. |
|
Tom Sepez
2016/03/22 15:51:34
I like the "as returned by" part, which clearly in
dsinclair
2016/03/22 16:02:50
So, my problem with 'as returned by' is that, what
| |
| 86 * | |
| 87 * Parameters: | |
| 88 * avail - Handle to document availability provider returned by | |
| 89 * FPDFAvail_Create | |
| 90 * Return Value: | |
| 91 * None. | |
| 92 */ | |
| 93 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail); | 68 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail); |
| 94 | 69 |
| 95 /** | 70 // Download hints interface. Used to receive hints for further downloading. |
| 96 * Interface: FX_DOWNLOADHINTS | |
| 97 * Download hints interface. Used to receive hints for further | |
| 98 * downloading. | |
| 99 */ | |
| 100 typedef struct _FX_DOWNLOADHINTS { | 71 typedef struct _FX_DOWNLOADHINTS { |
| 101 /** | 72 // Version number of the interface. Must be 1. |
| 102 * Version number of the interface. Currently must be 1. | |
| 103 */ | |
| 104 int version; | 73 int version; |
| 105 | 74 |
| 106 /** | 75 // Add a section to be downloaded. |
| 107 * Method: AddSegment | 76 // |
| 108 * Add a section to be downloaded. | 77 // Interface Version: 1 |
| 109 * Interface Version: | 78 // Implementation Required: Yes |
| 110 * 1 | 79 // |
| 111 * Implementation Required: | 80 // |pThis| - pointer to the interface structure. |
| 112 * Yes | 81 // |offset| - the offset of the hint reported to be downloaded. |
| 113 * Parameters: | 82 // |size| - the size of the hint reported to be downloaded. |
| 114 * pThis - Pointer to the interface structure itself. | 83 // |
| 115 * offset - The offset of the hint reported to be downloaded. | 84 // The |offset| and |size| of the section may not be unique. Part of the |
| 116 * size - The size of the hint reported to be downloaded. | 85 // section might be already available. The download manager must deal with |
| 117 * Return Value: | 86 // duplicate sections. |
| 118 * None. | |
| 119 * Comments: | |
| 120 * Called by Foxit SDK to report some downloading hints for download | |
| 121 * manager. | |
| 122 * The position and size of section may be not accurate, part of the | |
| 123 * section might be already available. | |
| 124 * The download manager must deal with that to maximize download | |
| 125 * efficiency. | |
| 126 */ | |
| 127 void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis, | 87 void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis, |
| 128 size_t offset, | 88 size_t offset, |
| 129 size_t size); | 89 size_t size); |
| 130 } FX_DOWNLOADHINTS; | 90 } FX_DOWNLOADHINTS; |
| 131 | 91 |
| 132 /** | 92 // Checks if the document is ready for loading, if not, get download hints. |
| 133 * Function: FPDFAvail_IsDocAvail | 93 // |
| 134 * Check whether the document is ready for loading, if not, get | 94 // |avail| - handle to document availability provider. |
| 135 * download hints. | 95 // |hints| - pointer to a download hints interface. |
| 136 * | 96 // |
| 137 * Parameters: | 97 // Return value: |
| 138 * avail - Handle to document availability provider returned by | 98 // * PDF_DATA_ERROR: A common error is returned. Data availability unknown. |
|
Tom Sepez
2016/03/22 15:51:35
nit: not sure why there's a * here.
dsinclair
2016/03/22 16:02:50
Attempting to show a list, * is a markdown list ma
| |
| 139 * FPDFAvail_Create | 99 // * PDF_DATA_NOTAVAIL: Data not yet available. |
| 140 * hints - Pointer to a download hints interface, receiving | 100 // * PDF_DATA_AVAIL: Data available. |
| 141 * generated hints | 101 // |
| 142 * Return value: | 102 // Applications should call this function whenever new data arrives, and process |
| 143 * PDF_DATA_ERROR: A common error is returned. It can't tell | 103 // all the generated download hints, if any, until the function returns |
| 144 * whehter data are availabe or not. | 104 // |PDF_DATA_ERROR| or |PDF_DATA_AVAIL|. |
| 145 * PDF_DATA_NOTAVAIL: Data are not yet available. | 105 // |
| 146 * PDF_DATA_AVAIL: Data are available. | 106 // Once all data is available, call |FPDFAvail_GetDocument| to get a document |
| 147 * Comments: | 107 // handle. |
| 148 * Applications should call this function whenever new data arrived, | |
| 149 * and process all the generated download hints if any, until the | |
| 150 * function returns PDF_DATA_ERROR or PDF_DATA_AVAIL. Then | |
| 151 * applications can call FPDFAvail_GetDocument() to get a document | |
| 152 * handle. | |
| 153 */ | |
| 154 DLLEXPORT int STDCALL | 108 DLLEXPORT int STDCALL |
| 155 FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints); | 109 FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints); |
| 156 | 110 |
| 157 /** | 111 /** |
| 158 * Function: FPDFAvail_GetDocument | 112 * Function: FPDFAvail_GetDocument |
| 159 * Get document from the availability provider. | 113 * Get document from the availability provider. |
| 160 * | 114 * |
| 161 * Parameters: | 115 * Parameters: |
| 162 * avail - Handle to document availability provider returned by | 116 * avail - Handle to document availability provider returned by |
| 163 * FPDFAvail_Create | 117 * FPDFAvail_Create |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 * tell whether a PDF file is a linearized file or not. | 220 * tell whether a PDF file is a linearized file or not. |
| 267 * | 221 * |
| 268 */ | 222 */ |
| 269 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail); | 223 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail); |
| 270 | 224 |
| 271 #ifdef __cplusplus | 225 #ifdef __cplusplus |
| 272 } | 226 } |
| 273 #endif | 227 #endif |
| 274 | 228 |
| 275 #endif // PUBLIC_FPDF_DATAAVAIL_H_ | 229 #endif // PUBLIC_FPDF_DATAAVAIL_H_ |
| OLD | NEW |