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

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/fixes Created 4 years, 10 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 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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <map> 10 #include <map>
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 BlobReader(const BlobDataHandle* blob_handle, 120 BlobReader(const BlobDataHandle* blob_handle,
121 scoped_ptr<FileStreamReaderProvider> file_stream_provider, 121 scoped_ptr<FileStreamReaderProvider> file_stream_provider,
122 base::SequencedTaskRunner* file_task_runner); 122 base::SequencedTaskRunner* file_task_runner);
123 123
124 bool total_size_calculated() const { return total_size_calculated_; } 124 bool total_size_calculated() const { return total_size_calculated_; }
125 125
126 private: 126 private:
127 Status ReportError(int net_error); 127 Status ReportError(int net_error);
128 void InvalidateCallbacksAndDone(int net_error, net::CompletionCallback done); 128 void InvalidateCallbacksAndDone(int net_error, net::CompletionCallback done);
129 129
130 void AsyncCalculateSize(const net::CompletionCallback& done,
131 bool async_succeeded);
132 Status CalculateSizeImpl(const net::CompletionCallback& done);
130 bool AddItemLength(size_t index, uint64_t length); 133 bool AddItemLength(size_t index, uint64_t length);
131 bool ResolveFileItemLength(const BlobDataItem& item, 134 bool ResolveFileItemLength(const BlobDataItem& item,
132 int64_t total_length, 135 int64_t total_length,
133 uint64_t* output_length); 136 uint64_t* output_length);
134 void DidGetFileItemLength(size_t index, int64_t result); 137 void DidGetFileItemLength(size_t index, int64_t result);
135 void DidCountSize(); 138 void DidCountSize();
136 139
137 // For reading the blob. 140 // For reading the blob.
138 // Returns if we're done, PENDING_IO if we're waiting on async. 141 // Returns if we're done, PENDING_IO if we're waiting on async.
139 Status ReadLoop(int* bytes_read); 142 Status ReadLoop(int* bytes_read);
(...skipping 16 matching lines...) Expand all
156 // Returns a FileStreamReader for a blob item at |index|. 159 // Returns a FileStreamReader for a blob item at |index|.
157 // If the item at |index| is not of file this returns NULL. 160 // If the item at |index| is not of file this returns NULL.
158 FileStreamReader* GetOrCreateFileReaderAtIndex(size_t index); 161 FileStreamReader* GetOrCreateFileReaderAtIndex(size_t index);
159 // If the reader is null, then this basically performs a delete operation. 162 // If the reader is null, then this basically performs a delete operation.
160 void SetFileReaderAtIndex(size_t index, scoped_ptr<FileStreamReader> reader); 163 void SetFileReaderAtIndex(size_t index, scoped_ptr<FileStreamReader> reader);
161 // Creates a FileStreamReader for the item with additional_offset. 164 // Creates a FileStreamReader for the item with additional_offset.
162 scoped_ptr<FileStreamReader> CreateFileStreamReader( 165 scoped_ptr<FileStreamReader> CreateFileStreamReader(
163 const BlobDataItem& item, 166 const BlobDataItem& item,
164 uint64_t additional_offset); 167 uint64_t additional_offset);
165 168
169 scoped_ptr<BlobDataHandle> blob_handle_;
166 scoped_ptr<BlobDataSnapshot> blob_data_; 170 scoped_ptr<BlobDataSnapshot> blob_data_;
167 scoped_ptr<FileStreamReaderProvider> file_stream_provider_; 171 scoped_ptr<FileStreamReaderProvider> file_stream_provider_;
168 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; 172 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
169 173
170 int net_error_; 174 int net_error_;
171 bool item_list_populated_ = false; 175 bool item_list_populated_ = false;
172 std::vector<uint64_t> item_length_list_; 176 std::vector<uint64_t> item_length_list_;
173 177
174 scoped_refptr<net::DrainableIOBuffer> read_buf_; 178 scoped_refptr<net::DrainableIOBuffer> read_buf_;
175 179
176 bool total_size_calculated_ = false; 180 bool total_size_calculated_ = false;
177 uint64_t total_size_ = 0; 181 uint64_t total_size_ = 0;
178 uint64_t remaining_bytes_ = 0; 182 uint64_t remaining_bytes_ = 0;
179 size_t pending_get_file_info_count_ = 0; 183 size_t pending_get_file_info_count_ = 0;
180 std::map<size_t, FileStreamReader*> index_to_reader_; 184 std::map<size_t, FileStreamReader*> index_to_reader_;
181 size_t current_item_index_ = 0; 185 size_t current_item_index_ = 0;
182 uint64_t current_item_offset_ = 0; 186 uint64_t current_item_offset_ = 0;
183 187
184 bool io_pending_ = false; 188 bool io_pending_ = false;
185 189
186 net::CompletionCallback size_callback_; 190 net::CompletionCallback size_callback_;
187 net::CompletionCallback read_callback_; 191 net::CompletionCallback read_callback_;
188 192
189 base::WeakPtrFactory<BlobReader> weak_factory_; 193 base::WeakPtrFactory<BlobReader> weak_factory_;
190 DISALLOW_COPY_AND_ASSIGN(BlobReader); 194 DISALLOW_COPY_AND_ASSIGN(BlobReader);
191 }; 195 };
192 196
193 } // namespace storage 197 } // namespace storage
194 #endif // STORAGE_BROWSER_BLOB_BLOB_READER_H_ 198 #endif // STORAGE_BROWSER_BLOB_BLOB_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698