| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium 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 #ifndef PDF_DOCUMENT_LOADER_H_ | 5 #ifndef PDF_DOCUMENT_LOADER_H_ |
| 6 #define PDF_DOCUMENT_LOADER_H_ | 6 #define PDF_DOCUMENT_LOADER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "pdf/chunk_stream.h" | 13 #include "pdf/chunk_stream.h" |
| 14 #include "pdf/file_writer.h" |
| 14 #include "ppapi/cpp/url_loader.h" | 15 #include "ppapi/cpp/url_loader.h" |
| 15 #include "ppapi/utility/completion_callback_factory.h" | 16 #include "ppapi/utility/completion_callback_factory.h" |
| 16 | 17 |
| 17 #define kDefaultRequestSize 32768u | 18 #define kDefaultRequestSize 32768u |
| 18 | 19 |
| 20 namespace pp { |
| 21 class Buffer_Dev; |
| 22 } |
| 23 |
| 19 namespace chrome_pdf { | 24 namespace chrome_pdf { |
| 20 | 25 |
| 21 class DocumentLoader { | 26 class DocumentLoader { |
| 22 public: | 27 public: |
| 23 class Client { | 28 class Client { |
| 24 public: | 29 public: |
| 25 // Gets the pp::Instance object. | 30 // Gets the pp::Instance object. |
| 26 virtual pp::Instance* GetPluginInstance() = 0; | 31 virtual pp::Instance* GetPluginInstance() = 0; |
| 27 // Creates new URLLoader based on client settings. | 32 // Creates new URLLoader based on client settings. |
| 28 virtual pp::URLLoader CreateURLLoader() = 0; | 33 virtual pp::URLLoader CreateURLLoader() = 0; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 50 | 55 |
| 51 // Data availability interface. Return true data avaialble. | 56 // Data availability interface. Return true data avaialble. |
| 52 bool IsDataAvailable(uint32 position, uint32 size) const; | 57 bool IsDataAvailable(uint32 position, uint32 size) const; |
| 53 | 58 |
| 54 // Data availability interface. Return true data avaialble. | 59 // Data availability interface. Return true data avaialble. |
| 55 void RequestData(uint32 position, uint32 size); | 60 void RequestData(uint32 position, uint32 size); |
| 56 | 61 |
| 57 bool IsDocumentComplete() const; | 62 bool IsDocumentComplete() const; |
| 58 uint32 document_size() const { return document_size_; } | 63 uint32 document_size() const { return document_size_; } |
| 59 | 64 |
| 65 void GetCompleteDocument( |
| 66 pp::CompletionCallbackWithOutput<pp::FileRef> callback); |
| 67 |
| 60 // Return number of bytes available. | 68 // Return number of bytes available. |
| 61 uint32 GetAvailableData() const; | 69 uint32 GetAvailableData() const; |
| 62 | 70 |
| 63 // Clear pending requests from the queue. | 71 // Clear pending requests from the queue. |
| 64 void ClearPendingRequests(); | 72 void ClearPendingRequests(); |
| 65 | 73 |
| 66 bool is_partial_document() { return partial_document_; } | 74 bool is_partial_document() { return partial_document_; } |
| 67 | 75 |
| 68 private: | 76 private: |
| 69 // Called by the completion callback of the document's URLLoader. | 77 // Called by the completion callback of the document's URLLoader. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 char buffer_[kDefaultRequestSize]; | 118 char buffer_[kDefaultRequestSize]; |
| 111 uint32 current_pos_; | 119 uint32 current_pos_; |
| 112 uint32 current_chunk_size_; | 120 uint32 current_chunk_size_; |
| 113 uint32 current_chunk_read_; | 121 uint32 current_chunk_read_; |
| 114 uint32 document_size_; | 122 uint32 document_size_; |
| 115 bool header_request_; | 123 bool header_request_; |
| 116 bool is_multipart_; | 124 bool is_multipart_; |
| 117 std::string multipart_boundary_; | 125 std::string multipart_boundary_; |
| 118 uint32 requests_count_; | 126 uint32 requests_count_; |
| 119 std::list<std::vector<unsigned char> > chunk_buffer_; | 127 std::list<std::vector<unsigned char> > chunk_buffer_; |
| 128 scoped_ptr<FileWriter> file_writer_; |
| 120 }; | 129 }; |
| 121 | 130 |
| 122 } // namespace chrome_pdf | 131 } // namespace chrome_pdf |
| 123 | 132 |
| 124 #endif // PDF_DOCUMENT_LOADER_H_ | 133 #endif // PDF_DOCUMENT_LOADER_H_ |
| OLD | NEW |