OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef STORAGE_COMMON_BLOB_STORAGE_BLOB_ITEM_BYTES_REQUEST_H_ |
| 6 #define STORAGE_COMMON_BLOB_STORAGE_BLOB_ITEM_BYTES_REQUEST_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 #include <ostream> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "storage/common/blob_storage/blob_storage_constants.h" |
| 13 #include "storage/common/storage_common_export.h" |
| 14 |
| 15 namespace storage { |
| 16 |
| 17 // This class is serialized over IPC to request bytes from a blob item. |
| 18 struct STORAGE_COMMON_EXPORT BlobItemBytesRequest { |
| 19 // Not using std::numeric_limits<T>::max() because of non-C++11 builds. |
| 20 static const size_t kInvalidIndex = SIZE_MAX; |
| 21 static const uint64_t kInvalidSize = kuint64max; |
| 22 |
| 23 static BlobItemBytesRequest CreateIPCRequest(size_t request_number, |
| 24 size_t renderer_item_index, |
| 25 size_t renderer_item_offset, |
| 26 size_t size); |
| 27 |
| 28 static BlobItemBytesRequest CreateSharedMemoryRequest( |
| 29 size_t request_number, |
| 30 size_t renderer_item_index, |
| 31 size_t renderer_item_offset, |
| 32 size_t size, |
| 33 size_t handle_index, |
| 34 uint64_t handle_offset); |
| 35 |
| 36 static BlobItemBytesRequest CreateFileRequest(size_t request_number, |
| 37 size_t renderer_item_index, |
| 38 uint64_t renderer_item_offset, |
| 39 uint64_t size, |
| 40 size_t handle_index, |
| 41 uint64_t handle_offset); |
| 42 |
| 43 BlobItemBytesRequest(); |
| 44 BlobItemBytesRequest(size_t request_number, |
| 45 IPCBlobItemRequestStrategy transport_strategy, |
| 46 size_t renderer_item_index, |
| 47 uint64_t renderer_item_offset, |
| 48 uint64_t size, |
| 49 size_t handle_index, |
| 50 uint64_t handle_offset); |
| 51 ~BlobItemBytesRequest(); |
| 52 |
| 53 // The request number uniquely identifies the memory request. We can't use |
| 54 // the renderer item index or browser item index as there can be multiple |
| 55 // requests for both (as segmentation boundaries can exist in both). |
| 56 size_t request_number; |
| 57 IPCBlobItemRequestStrategy transport_strategy; |
| 58 size_t renderer_item_index; |
| 59 uint64_t renderer_item_offset; |
| 60 uint64_t size; |
| 61 size_t handle_index; |
| 62 uint64_t handle_offset; |
| 63 }; |
| 64 |
| 65 STORAGE_COMMON_EXPORT void PrintTo(const BlobItemBytesRequest& request, |
| 66 std::ostream* os); |
| 67 |
| 68 #if defined(UNIT_TEST) |
| 69 STORAGE_COMMON_EXPORT inline bool operator==(const BlobItemBytesRequest& a, |
| 70 const BlobItemBytesRequest& b) { |
| 71 return a.request_number == b.request_number && |
| 72 a.transport_strategy == b.transport_strategy && |
| 73 a.renderer_item_index == b.renderer_item_index && |
| 74 a.renderer_item_offset == b.renderer_item_offset && a.size == b.size && |
| 75 a.handle_index == b.handle_index && a.handle_offset == b.handle_offset; |
| 76 } |
| 77 |
| 78 STORAGE_COMMON_EXPORT inline bool operator!=(const BlobItemBytesRequest& a, |
| 79 const BlobItemBytesRequest& b) { |
| 80 return !(a == b); |
| 81 } |
| 82 #endif // defined(UNIT_TEST) |
| 83 |
| 84 } // namespace storage |
| 85 |
| 86 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_ITEM_BYTES_REQUEST_H_ |
OLD | NEW |