OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_SLICE_H_ |
| 6 #define STORAGE_BROWSER_BLOB_BLOB_SLICE_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "storage/browser/blob/internal_blob_data.h" |
| 15 #include "storage/browser/blob/shareable_blob_data_item.h" |
| 16 |
| 17 namespace storage { |
| 18 |
| 19 class BlobSlice { |
| 20 public: |
| 21 BlobSlice(); |
| 22 BlobSlice(const InternalBlobData& source, |
| 23 uint64_t offset, |
| 24 uint64_t size, |
| 25 bool done_building); |
| 26 BlobSlice(BlobSlice&&); |
| 27 ~BlobSlice(); |
| 28 |
| 29 bool done_building() { return done_building_; } |
| 30 |
| 31 size_t copying_memory_size() { return copying_memory_size_; } |
| 32 |
| 33 // If our first item is a new memory item, where we are a slice of the item |
| 34 // in the original blob. See first_item_slice_offset() and first_item_index(). |
| 35 bool has_sliced_first_memory_item() { return has_sliced_first_memory_item_; } |
| 36 // If our last item is a new memory item, where we are a slice of the item |
| 37 // in the original blob. |
| 38 bool has_sliced_last_memory_item() { return has_sliced_last_memory_item_; } |
| 39 |
| 40 size_t first_item_slice_offset() { return first_item_slice_offset_; } |
| 41 size_t first_item_index() { return first_item_index_; } |
| 42 size_t last_item_index() { return last_item_index_; } |
| 43 |
| 44 const std::vector<scoped_refptr<ShareableBlobDataItem>>& items() { |
| 45 return items_; |
| 46 } |
| 47 |
| 48 private: |
| 49 void BinarySearch(const InternalBlobData& source_blob, |
| 50 uint64_t blob_offset, |
| 51 size_t* item_index, |
| 52 uint64_t* offset_in_item); |
| 53 |
| 54 size_t copying_memory_size_ = 0; |
| 55 bool done_building_ = true; |
| 56 |
| 57 bool has_sliced_first_memory_item_ = false; |
| 58 bool has_sliced_last_memory_item_ = false; |
| 59 size_t first_item_slice_offset_ = 0; |
| 60 size_t first_item_index_ = 0; |
| 61 size_t last_item_index_ = 0; |
| 62 |
| 63 std::vector<scoped_refptr<ShareableBlobDataItem>> items_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(BlobSlice); |
| 66 }; |
| 67 |
| 68 } // namespace storage |
| 69 #endif // STORAGE_BROWSER_BLOB_BLOB_SLICE_H_ |
OLD | NEW |