summaryrefslogtreecommitdiff
path: root/chromium/content/common/fileapi/webblob_messages.h
blob: 2d1caf26034b16bea21eaaa072fbaf3d59c38c05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// Copyright (c) 2012 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.

// IPC messages for HTML5 Blob and Stream.
// Multiply-included message file, hence no include guard.

#include <stddef.h>

#include <set>

#include "base/memory/shared_memory.h"
#include "content/common/content_export.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_message_utils.h"
#include "ipc/ipc_param_traits.h"
#include "ipc/ipc_platform_file.h"
#include "storage/common/blob_storage/blob_item_bytes_request.h"
#include "storage/common/blob_storage/blob_item_bytes_response.h"
#include "storage/common/blob_storage/blob_storage_constants.h"
#include "storage/common/data_element.h"
#include "url/ipc/url_param_traits.h"

#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
#define IPC_MESSAGE_START BlobMsgStart

// Trait definitions for async blob transport messages.

IPC_ENUM_TRAITS_MAX_VALUE(storage::IPCBlobItemRequestStrategy,
                          storage::IPCBlobItemRequestStrategy::LAST)
IPC_ENUM_TRAITS_MAX_VALUE(storage::BlobStatus, storage::BlobStatus::LAST)

IPC_STRUCT_TRAITS_BEGIN(storage::BlobItemBytesRequest)
  IPC_STRUCT_TRAITS_MEMBER(request_number)
  IPC_STRUCT_TRAITS_MEMBER(transport_strategy)
  IPC_STRUCT_TRAITS_MEMBER(renderer_item_index)
  IPC_STRUCT_TRAITS_MEMBER(renderer_item_offset)
  IPC_STRUCT_TRAITS_MEMBER(size)
  IPC_STRUCT_TRAITS_MEMBER(handle_index)
  IPC_STRUCT_TRAITS_MEMBER(handle_offset)
IPC_STRUCT_TRAITS_END()

IPC_STRUCT_TRAITS_BEGIN(storage::BlobItemBytesResponse)
  IPC_STRUCT_TRAITS_MEMBER(request_number)
  IPC_STRUCT_TRAITS_MEMBER(inline_data)
  IPC_STRUCT_TRAITS_MEMBER(time_file_modified)
IPC_STRUCT_TRAITS_END()

// This message is to tell the browser that we will be building a blob. The
// DataElements are used to:
// * describe & transport non-memory resources (blobs, files, etc)
// * describe the size of memory items
// * 'shortcut' transport the memory up to the IPC limit so the browser can use
//   it if it's not currently full.
// See https://bit.ly/BlobStorageRefactor
//
// NOTE: This message is synchronous to ensure that the browser is aware of the
// UUID before the UUID is passed to another process. This protects against a
// race condition in which the browser could be asked about a UUID that doesn't
// yet exist from its perspective. See also https://goo.gl/bfdE64.
//
IPC_SYNC_MESSAGE_CONTROL4_0(
    BlobStorageMsg_RegisterBlob,
    std::string /* uuid */,
    std::string /* content_type */,
    std::string /* content_disposition */,
    std::vector<storage::DataElement> /* item_descriptions */)

IPC_MESSAGE_CONTROL4(
    BlobStorageMsg_RequestMemoryItem,
    std::string /* uuid */,
    std::vector<storage::BlobItemBytesRequest> /* requests */,
    std::vector<base::SharedMemoryHandle> /* memory_handles */,
    std::vector<IPC::PlatformFileForTransit> /* file_handles */)

IPC_MESSAGE_CONTROL2(
    BlobStorageMsg_MemoryItemResponse,
    std::string /* uuid */,
    std::vector<storage::BlobItemBytesResponse> /* responses */)

IPC_MESSAGE_CONTROL2(BlobStorageMsg_SendBlobStatus,
                     std::string /* uuid */,
                     storage::BlobStatus /* code */)

IPC_MESSAGE_CONTROL1(BlobHostMsg_IncrementRefCount,
                     std::string /* uuid */)
IPC_MESSAGE_CONTROL1(BlobHostMsg_DecrementRefCount,
                     std::string /* uuid */)
// NOTE: This message is synchronous to ensure that the browser is aware of the
// UUID before the UUID is passed to another process. This protects against a
// race condition in which the browser could be asked about a UUID that doesn't
// yet exist from its perspective. See also https://goo.gl/bfdE64.
IPC_SYNC_MESSAGE_CONTROL2_0(BlobHostMsg_RegisterPublicURL,
                            GURL,
                            std::string /* uuid */)
IPC_MESSAGE_CONTROL1(BlobHostMsg_RevokePublicURL,
                     GURL)

// Stream messages sent from the renderer to the browser.

// Registers a stream as being built.
IPC_MESSAGE_CONTROL2(StreamHostMsg_StartBuilding,
                     GURL /* url */,
                     std::string /* content_type */)

// Appends data to a stream being built.
IPC_MESSAGE_CONTROL2(StreamHostMsg_AppendBlobDataItem,
                     GURL /* url */,
                     storage::DataElement)

// Appends data to a stream being built.
IPC_SYNC_MESSAGE_CONTROL3_0(StreamHostMsg_SyncAppendSharedMemory,
                            GURL /* url */,
                            base::SharedMemoryHandle,
                            uint32_t /* buffer size */)

// Flushes contents buffered in the stream.
IPC_MESSAGE_CONTROL1(StreamHostMsg_Flush,
                     GURL /* url */)

// Finishes building a stream.
IPC_MESSAGE_CONTROL1(StreamHostMsg_FinishBuilding,
                     GURL /* url */)

// Aborts building a stream.
IPC_MESSAGE_CONTROL1(StreamHostMsg_AbortBuilding,
                     GURL /* url */)

// Creates a new stream that's a clone of an existing src stream.
IPC_MESSAGE_CONTROL2(StreamHostMsg_Clone,
                     GURL /* url */,
                     GURL /* src_url */)

// Removes a stream.
IPC_MESSAGE_CONTROL1(StreamHostMsg_Remove,
                     GURL /* url */)