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

Side by Side Diff: storage/browser/blob/blob_reader.h

Issue 1234813004: [BlobAsync] Asynchronous Blob Construction Final Patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blob-protocol-change
Patch Set: comments Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 STORAGE_BROWSER_BLOB_BLOB_READER_H_ 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_READER_H_
6 #define STORAGE_BROWSER_BLOB_BLOB_READER_H_ 6 #define STORAGE_BROWSER_BLOB_BLOB_READER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 BlobReader(const BlobDataHandle* blob_handle, 116 BlobReader(const BlobDataHandle* blob_handle,
117 scoped_ptr<FileStreamReaderProvider> file_stream_provider, 117 scoped_ptr<FileStreamReaderProvider> file_stream_provider,
118 base::SequencedTaskRunner* file_task_runner); 118 base::SequencedTaskRunner* file_task_runner);
119 119
120 bool total_size_calculated() const { return total_size_calculated_; } 120 bool total_size_calculated() const { return total_size_calculated_; }
121 121
122 private: 122 private:
123 Status ReportError(int net_error); 123 Status ReportError(int net_error);
124 void InvalidateCallbacksAndDone(int net_error, net::CompletionCallback done); 124 void InvalidateCallbacksAndDone(int net_error, net::CompletionCallback done);
125 125
126 void AsyncCalculateSize(const net::CompletionCallback& done,
127 bool async_succeeded);
128 Status CalculateSizeImpl(const net::CompletionCallback& done);
126 bool AddItemLength(size_t index, uint64_t length); 129 bool AddItemLength(size_t index, uint64_t length);
127 bool ResolveFileItemLength(const BlobDataItem& item, 130 bool ResolveFileItemLength(const BlobDataItem& item,
128 int64_t total_length, 131 int64_t total_length,
129 uint64_t* output_length); 132 uint64_t* output_length);
130 void DidGetFileItemLength(size_t index, int64_t result); 133 void DidGetFileItemLength(size_t index, int64_t result);
131 void DidCountSize(); 134 void DidCountSize();
132 135
133 // For reading the blob. 136 // For reading the blob.
134 // Returns if we're done, PENDING_IO if we're waiting on async. 137 // Returns if we're done, PENDING_IO if we're waiting on async.
135 Status ReadLoop(int* bytes_read); 138 Status ReadLoop(int* bytes_read);
(...skipping 16 matching lines...) Expand all
152 // Returns a FileStreamReader for a blob item at |index|. 155 // Returns a FileStreamReader for a blob item at |index|.
153 // If the item at |index| is not of file this returns NULL. 156 // If the item at |index| is not of file this returns NULL.
154 FileStreamReader* GetOrCreateFileReaderAtIndex(size_t index); 157 FileStreamReader* GetOrCreateFileReaderAtIndex(size_t index);
155 // If the reader is null, then this basically performs a delete operation. 158 // If the reader is null, then this basically performs a delete operation.
156 void SetFileReaderAtIndex(size_t index, scoped_ptr<FileStreamReader> reader); 159 void SetFileReaderAtIndex(size_t index, scoped_ptr<FileStreamReader> reader);
157 // Creates a FileStreamReader for the item with additional_offset. 160 // Creates a FileStreamReader for the item with additional_offset.
158 scoped_ptr<FileStreamReader> CreateFileStreamReader( 161 scoped_ptr<FileStreamReader> CreateFileStreamReader(
159 const BlobDataItem& item, 162 const BlobDataItem& item,
160 uint64_t additional_offset); 163 uint64_t additional_offset);
161 164
165 scoped_ptr<BlobDataHandle> blob_handle_;
162 scoped_ptr<BlobDataSnapshot> blob_data_; 166 scoped_ptr<BlobDataSnapshot> blob_data_;
163 scoped_ptr<FileStreamReaderProvider> file_stream_provider_; 167 scoped_ptr<FileStreamReaderProvider> file_stream_provider_;
164 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; 168 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
165 169
166 int net_error_; 170 int net_error_;
167 bool item_list_populated_ = false; 171 bool item_list_populated_ = false;
168 std::vector<uint64_t> item_length_list_; 172 std::vector<uint64_t> item_length_list_;
169 173
170 scoped_refptr<net::DrainableIOBuffer> read_buf_; 174 scoped_refptr<net::DrainableIOBuffer> read_buf_;
171 175
172 bool total_size_calculated_ = false; 176 bool total_size_calculated_ = false;
173 uint64_t total_size_ = 0; 177 uint64_t total_size_ = 0;
174 uint64_t remaining_bytes_ = 0; 178 uint64_t remaining_bytes_ = 0;
175 size_t pending_get_file_info_count_ = 0; 179 size_t pending_get_file_info_count_ = 0;
176 std::map<size_t, FileStreamReader*> index_to_reader_; 180 std::map<size_t, FileStreamReader*> index_to_reader_;
177 size_t current_item_index_ = 0; 181 size_t current_item_index_ = 0;
178 uint64_t current_item_offset_ = 0; 182 uint64_t current_item_offset_ = 0;
179 183
180 bool io_pending_ = false; 184 bool io_pending_ = false;
181 185
182 net::CompletionCallback size_callback_; 186 net::CompletionCallback size_callback_;
183 net::CompletionCallback read_callback_; 187 net::CompletionCallback read_callback_;
184 188
185 base::WeakPtrFactory<BlobReader> weak_factory_; 189 base::WeakPtrFactory<BlobReader> weak_factory_;
186 DISALLOW_COPY_AND_ASSIGN(BlobReader); 190 DISALLOW_COPY_AND_ASSIGN(BlobReader);
187 }; 191 };
188 192
189 } // namespace storage 193 } // namespace storage
190 #endif // STORAGE_BROWSER_BLOB_BLOB_READER_H_ 194 #endif // STORAGE_BROWSER_BLOB_BLOB_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698