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

Side by Side Diff: ui/file_manager/zip_archiver/cpp/volume_reader_javascript_stream.h

Issue 2807063002: Replace Libarchive with MiniZip. (Closed)
Patch Set: Fix a few nits. Created 3 years, 8 months 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
OLDNEW
1 // Copyright 2014 The Chromium OS Authors. All rights reserved. 1 // Copyright 2014 The Chromium OS 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 VOLUME_READER_JAVSCRIPT_STREAM_H_ 5 #ifndef VOLUME_READER_JAVSCRIPT_STREAM_H_
6 #define VOLUME_READER_JAVSCRIPT_STREAM_H_ 6 #define VOLUME_READER_JAVSCRIPT_STREAM_H_
7 7
8 #include <pthread.h> 8 #include <pthread.h>
9 9
10 #include "archive.h"
11 #include "ppapi/cpp/var_array_buffer.h" 10 #include "ppapi/cpp/var_array_buffer.h"
12 11
13 #include "javascript_requestor_interface.h" 12 #include "javascript_requestor_interface.h"
14 #include "volume_reader.h" 13 #include "volume_reader.h"
15 14
16 // A VolumeReader that reads the content of the volume's archive from 15 // A VolumeReader that reads the content of the volume's archive from
17 // JavaScript. All methods including the constructor and destructor should be 16 // JavaScript. All methods including the constructor and destructor should be
18 // called from the same thread with the exception of SetBufferAndSignal and 17 // called from the same thread with the exception of SetBufferAndSignal and
19 // ReadErrorSignal which MUST be called from another thread. 18 // ReadErrorSignal which MUST be called from another thread.
20 class VolumeReaderJavaScriptStream : public VolumeReader { 19 class VolumeReaderJavaScriptStream : public VolumeReader {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // than VolumeReaderJavaScriptStream::Passphrase. May block for a few cycles 52 // than VolumeReaderJavaScriptStream::Passphrase. May block for a few cycles
54 // in order to synchronize with VolumeReaderJavaScriptStream::Passphrase. 53 // in order to synchronize with VolumeReaderJavaScriptStream::Passphrase.
55 void PassphraseErrorSignal(); 54 void PassphraseErrorSignal();
56 55
57 // See volume_reader.h for description. This method blocks on 56 // See volume_reader.h for description. This method blocks on
58 // available_data_cond_. SetBufferAndSignal should unblock it from another 57 // available_data_cond_. SetBufferAndSignal should unblock it from another
59 // thread. 58 // thread.
60 virtual int64_t Read(int64_t bytes_to_read, const void** destination_buffer); 59 virtual int64_t Read(int64_t bytes_to_read, const void** destination_buffer);
61 60
62 // See volume_reader.h for description. 61 // See volume_reader.h for description.
63 virtual int64_t Skip(int64_t bytes_to_skip);
64
65 // See volume_reader.h for description.
66 virtual int64_t Seek(int64_t offset, int whence); 62 virtual int64_t Seek(int64_t offset, int whence);
67 63
68 // Sets the request Id to be used by the reader. 64 // Sets the request Id to be used by the reader.
69 void SetRequestId(const std::string& request_id); 65 void SetRequestId(const std::string& request_id);
70 66
71 // See volume_reader.h for description. The method blocks on 67 // See volume_reader.h for description. The method blocks on
72 // available_passphrase_cond_. SetPassphraseAndSignal should unblock it from 68 // available_passphrase_cond_. SetPassphraseAndSignal should unblock it from
73 // another thread. 69 // another thread.
74 virtual const char* Passphrase(); 70 virtual const char* Passphrase();
75 71
76 int64_t offset() const { return offset_; } 72 virtual int64_t offset() { return offset_; }
73
74 int64_t archive_size() { return archive_size_; }
77 75
78 private: 76 private:
79 // Request a chunk of length number of bytes from JavaScript starting from 77 // Request a chunk of length number of bytes from JavaScript starting from
80 // offset_ member. Should be run within a lock. 78 // offset_ member. Should be run within a lock.
81 void RequestChunk(int64_t length); 79 void RequestChunk(int64_t length);
82 80
83 std::string request_id_; // The request id for which the reader was 81 std::string request_id_; // The request id for which the reader was
84 // created. 82 // created.
85 const int64_t archive_size_; // The archive size. 83 const int64_t archive_size_; // The archive size.
86 84
87 // A requestor that makes calls to JavaScript to obtain file chunks. 85 // A requestor that makes calls to JavaScript to obtain file chunks.
88 JavaScriptRequestorInterface* requestor_; 86 JavaScriptRequestorInterface* requestor_;
89 87
90 bool available_data_; // Indicates whether any data is available. 88 bool available_data_; // Indicates whether any data is available.
91 bool read_error_; // Marks an error in reading from JavaScript. 89 bool read_error_; // Marks an error in reading from JavaScript.
92 90
93 std::string available_passphrase_; // Stores a passphrase from JavaScript. 91 std::string available_passphrase_; // Stores a passphrase from JavaScript.
94 bool passphrase_error_; // Marks an error in getting the passphrase. 92 bool passphrase_error_; // Marks an error in getting the passphrase.
95 93
(...skipping 17 matching lines...) Expand all
113 111
114 // A pointer to first_arrray_buffer_ or second_array_buffer_. This is used in 112 // A pointer to first_arrray_buffer_ or second_array_buffer_. This is used in
115 // order to avoid an extra copy from the second buffer to the first buffer 113 // order to avoid an extra copy from the second buffer to the first buffer
116 // when data is available for VolumeReaderJavaScriptStream::Read method. 114 // when data is available for VolumeReaderJavaScriptStream::Read method.
117 // It points to the array buffer used for reading ahead when data is received 115 // It points to the array buffer used for reading ahead when data is received
118 // from JavaScript at VolumeReaderJavaScriptStream::SetBufferAndSignal. 116 // from JavaScript at VolumeReaderJavaScriptStream::SetBufferAndSignal.
119 pp::VarArrayBuffer* read_ahead_array_buffer_ptr_; 117 pp::VarArrayBuffer* read_ahead_array_buffer_ptr_;
120 }; 118 };
121 119
122 #endif // VOLUME_READER_JAVSCRIPT_STREAM_H_ 120 #endif // VOLUME_READER_JAVSCRIPT_STREAM_H_
OLDNEW
« no previous file with comments | « ui/file_manager/zip_archiver/cpp/volume_reader.h ('k') | ui/file_manager/zip_archiver/cpp/volume_reader_javascript_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698