Index: storage/common/blob_storage/blob_item_bytes_request.h |
diff --git a/storage/common/blob_storage/blob_item_bytes_request.h b/storage/common/blob_storage/blob_item_bytes_request.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8cc7cd96d70ed236822d95b815a112bb3a02b74f |
--- /dev/null |
+++ b/storage/common/blob_storage/blob_item_bytes_request.h |
@@ -0,0 +1,120 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef STORAGE_COMMON_FILEAPI_BLOB_ITEM_BYTES_REQUEST_H_ |
+#define STORAGE_COMMON_FILEAPI_BLOB_ITEM_BYTES_REQUEST_H_ |
+ |
+#include <stdint.h> |
+#include <ostream> |
+ |
+#include "base/basictypes.h" |
+#include "storage/common/blob_storage/blob_storage_constants.h" |
+#include "storage/common/storage_common_export.h" |
+ |
+namespace storage { |
+ |
+// This class is serialized over IPC to request bytes from a blob item. |
+struct STORAGE_COMMON_EXPORT BlobItemBytesRequest { |
+ // not using std::numeric_limits<T>::max() because of non-C++11 builds. |
+ static const size_t kInvalidIndex = SIZE_MAX; |
+ static const uint64_t kInvalidSize = kuint64max; |
+ |
+ static BlobItemBytesRequest CreateIPCRequest(size_t request_number, |
michaeln
2015/08/18 03:04:41
Not sure the set of create helpers is needed? At t
dmurph
2015/09/15 01:12:12
You'll notice some constants below though, which h
|
+ size_t renderer_item_index, |
+ size_t renderer_item_offset, |
+ size_t size) { |
+ return BlobItemBytesRequest(request_number, IPCBlobItemRequestStrategy::IPC, |
+ renderer_item_index, renderer_item_offset, size, |
+ kInvalidIndex, kInvalidSize); |
+ } |
+ |
+ static BlobItemBytesRequest CreateSharedMemoryRequest( |
+ size_t request_number, |
+ size_t renderer_item_index, |
+ size_t renderer_item_offset, |
+ size_t size, |
+ size_t handle_index, |
+ uint64_t handle_offset) { |
+ return BlobItemBytesRequest(request_number, |
+ IPCBlobItemRequestStrategy::SHARED_MEMORY, |
+ renderer_item_index, renderer_item_offset, size, |
+ handle_index, handle_offset); |
+ } |
+ |
+ static BlobItemBytesRequest CreateFileRequest(size_t request_number, |
+ size_t renderer_item_index, |
+ uint64_t renderer_item_offset, |
+ uint64_t size, |
+ size_t handle_index, |
+ uint64_t handle_offset) { |
+ return BlobItemBytesRequest( |
+ request_number, IPCBlobItemRequestStrategy::FILE, renderer_item_index, |
+ renderer_item_offset, size, handle_index, handle_offset); |
+ } |
+ |
+ BlobItemBytesRequest() |
+ : request_number(kInvalidIndex), |
+ transport_strategy(IPCBlobItemRequestStrategy::UNKNOWN), |
+ renderer_item_index(kInvalidIndex), |
+ renderer_item_offset(kInvalidSize), |
+ size(kInvalidSize), |
+ handle_index(kInvalidIndex), |
+ handle_offset(kInvalidSize) {} |
+ ~BlobItemBytesRequest() {} |
+ |
+ BlobItemBytesRequest(size_t request_number, |
+ IPCBlobItemRequestStrategy transport_strategy, |
+ size_t renderer_item_index, |
+ uint64_t renderer_item_offset, |
+ uint64_t size, |
+ size_t handle_index, |
+ uint64_t handle_offset) |
+ : request_number(request_number), |
+ transport_strategy(transport_strategy), |
+ renderer_item_index(renderer_item_index), |
+ renderer_item_offset(renderer_item_offset), |
+ size(size), |
+ handle_index(handle_index), |
+ handle_offset(handle_offset) {} |
+ |
+ size_t request_number; |
+ IPCBlobItemRequestStrategy transport_strategy; |
+ size_t renderer_item_index; |
+ uint64_t renderer_item_offset; |
+ uint64_t size; |
+ size_t handle_index; |
+ uint64_t handle_offset; |
+}; |
+ |
+#if defined(UNIT_TEST) |
+STORAGE_COMMON_EXPORT inline bool operator==(const BlobItemBytesRequest& a, |
+ const BlobItemBytesRequest& b) { |
+ return a.request_number == b.request_number && |
+ a.transport_strategy == b.transport_strategy && |
+ a.renderer_item_index == b.renderer_item_index && |
+ a.renderer_item_offset == b.renderer_item_offset && a.size == b.size && |
+ a.handle_index == b.handle_index && a.handle_offset == b.handle_offset; |
+} |
+ |
+STORAGE_COMMON_EXPORT inline bool operator!=(const BlobItemBytesRequest& a, |
+ const BlobItemBytesRequest& b) { |
+ return !(a == b); |
+} |
+ |
+STORAGE_COMMON_EXPORT inline ::std::ostream& operator<<( |
+ ::std::ostream& os, |
+ const BlobItemBytesRequest& request) { |
+ os << "{ request_number: " << request.request_number |
+ << ", transport_strategy: " << static_cast<int>(request.transport_strategy) |
+ << ", renderer_item_index: " << request.renderer_item_index |
+ << ", renderer_item_offset: " << request.renderer_item_offset |
+ << ", size: " << request.size << ", handle_index: " << request.handle_index |
+ << ", handle_offset: " << request.handle_offset << " }"; |
+ return os; |
+} |
+#endif // defined(UNIT_TEST) |
+ |
+} // namespace storage |
+ |
+#endif // STORAGE_COMMON_FILEAPI_BLOB_ITEM_BYTES_REQUEST_H_ |