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
|
// 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.
#include "ppapi/proxy/resource_message_params.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/proxy/ppapi_messages.h"
namespace ppapi {
namespace proxy {
ResourceMessageParams::ResourceMessageParams()
: pp_resource_(0),
sequence_(0) {
}
ResourceMessageParams::ResourceMessageParams(PP_Resource resource,
int32_t sequence)
: pp_resource_(resource),
sequence_(sequence) {
}
ResourceMessageParams::~ResourceMessageParams() {
}
void ResourceMessageParams::Serialize(IPC::Message* msg) const {
IPC::ParamTraits<PP_Resource>::Write(msg, pp_resource_);
IPC::ParamTraits<int32_t>::Write(msg, sequence_);
IPC::ParamTraits<std::vector<SerializedHandle> >::Write(msg, handles_);
}
bool ResourceMessageParams::Deserialize(const IPC::Message* msg,
PickleIterator* iter) {
return IPC::ParamTraits<PP_Resource>::Read(msg, iter, &pp_resource_) &&
IPC::ParamTraits<int32_t>::Read(msg, iter, &sequence_) &&
IPC::ParamTraits<std::vector<SerializedHandle> >::Read(
msg, iter, &handles_);
}
const SerializedHandle* ResourceMessageParams::GetHandleOfTypeAtIndex(
size_t index,
SerializedHandle::Type type) const {
if (handles_.size() <= index)
return NULL;
if (handles_[index].type() != type)
return NULL;
return &handles_[index];
}
bool ResourceMessageParams::GetSharedMemoryHandleAtIndex(
size_t index,
base::SharedMemoryHandle* handle) const {
const SerializedHandle* serialized = GetHandleOfTypeAtIndex(
index, SerializedHandle::SHARED_MEMORY);
if (!serialized)
return false;
*handle = serialized->shmem();
return true;
}
bool ResourceMessageParams::GetSocketHandleAtIndex(
size_t index,
IPC::PlatformFileForTransit* handle) const {
const SerializedHandle* serialized = GetHandleOfTypeAtIndex(
index, SerializedHandle::SOCKET);
if (!serialized)
return false;
*handle = serialized->descriptor();
return true;
}
void ResourceMessageParams::AppendHandle(const SerializedHandle& handle) {
handles_.push_back(handle);
}
ResourceMessageCallParams::ResourceMessageCallParams()
: ResourceMessageParams(),
has_callback_(0) {
}
ResourceMessageCallParams::ResourceMessageCallParams(PP_Resource resource,
int32_t sequence)
: ResourceMessageParams(resource, sequence),
has_callback_(0) {
}
ResourceMessageCallParams::~ResourceMessageCallParams() {
}
void ResourceMessageCallParams::Serialize(IPC::Message* msg) const {
ResourceMessageParams::Serialize(msg);
IPC::ParamTraits<bool>::Write(msg, has_callback_);
}
bool ResourceMessageCallParams::Deserialize(const IPC::Message* msg,
PickleIterator* iter) {
if (!ResourceMessageParams::Deserialize(msg, iter))
return false;
return IPC::ParamTraits<bool>::Read(msg, iter, &has_callback_);
}
ResourceMessageReplyParams::ResourceMessageReplyParams()
: ResourceMessageParams(),
result_(PP_OK) {
}
ResourceMessageReplyParams::ResourceMessageReplyParams(PP_Resource resource,
int32_t sequence)
: ResourceMessageParams(resource, sequence),
result_(PP_OK) {
}
ResourceMessageReplyParams::~ResourceMessageReplyParams() {
}
void ResourceMessageReplyParams::Serialize(IPC::Message* msg) const {
ResourceMessageParams::Serialize(msg);
IPC::ParamTraits<int32_t>::Write(msg, result_);
}
bool ResourceMessageReplyParams::Deserialize(const IPC::Message* msg,
PickleIterator* iter) {
if (!ResourceMessageParams::Deserialize(msg, iter))
return false;
return IPC::ParamTraits<int32_t>::Read(msg, iter, &result_);
}
} // namespace proxy
} // namespace ppapi
|