OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_PROXY_RESOURCE_MESSAGE_PARAMS_H_ | 5 #ifndef PPAPI_PROXY_RESOURCE_MESSAGE_PARAMS_H_ |
6 #define PPAPI_PROXY_RESOURCE_MESSAGE_PARAMS_H_ | 6 #define PPAPI_PROXY_RESOURCE_MESSAGE_PARAMS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 std::vector<base::SharedMemoryHandle>* handles) const; | 68 std::vector<base::SharedMemoryHandle>* handles) const; |
69 | 69 |
70 // Appends the given handle to the list of handles sent with the call or | 70 // Appends the given handle to the list of handles sent with the call or |
71 // reply. | 71 // reply. |
72 void AppendHandle(const SerializedHandle& handle) const; | 72 void AppendHandle(const SerializedHandle& handle) const; |
73 | 73 |
74 protected: | 74 protected: |
75 ResourceMessageParams(); | 75 ResourceMessageParams(); |
76 ResourceMessageParams(PP_Resource resource, int32_t sequence); | 76 ResourceMessageParams(PP_Resource resource, int32_t sequence); |
77 | 77 |
78 virtual void Serialize(IPC::Message* msg) const; | 78 virtual void Serialize(base::Pickle* msg) const; |
79 virtual bool Deserialize(const IPC::Message* msg, base::PickleIterator* iter); | 79 virtual bool Deserialize(const base::Pickle* msg, base::PickleIterator* iter); |
80 | 80 |
81 // Writes everything except the handles to |msg|. | 81 // Writes everything except the handles to |msg|. |
82 void WriteHeader(IPC::Message* msg) const; | 82 void WriteHeader(base::Pickle* msg) const; |
83 // Writes the handles to |msg|. | 83 // Writes the handles to |msg|. |
84 void WriteHandles(IPC::Message* msg) const; | 84 void WriteHandles(base::Pickle* msg) const; |
85 // Matching deserialize helpers. | 85 // Matching deserialize helpers. |
86 bool ReadHeader(const IPC::Message* msg, base::PickleIterator* iter); | 86 bool ReadHeader(const base::Pickle* msg, base::PickleIterator* iter); |
87 bool ReadHandles(const IPC::Message* msg, base::PickleIterator* iter); | 87 bool ReadHandles(const base::Pickle* msg, base::PickleIterator* iter); |
88 | 88 |
89 private: | 89 private: |
90 class PPAPI_PROXY_EXPORT SerializedHandles | 90 class PPAPI_PROXY_EXPORT SerializedHandles |
91 : public base::RefCountedThreadSafe<SerializedHandles> { | 91 : public base::RefCountedThreadSafe<SerializedHandles> { |
92 public: | 92 public: |
93 SerializedHandles(); | 93 SerializedHandles(); |
94 ~SerializedHandles(); | 94 ~SerializedHandles(); |
95 | 95 |
96 void set_should_close(bool value) { should_close_ = value; } | 96 void set_should_close(bool value) { should_close_ = value; } |
97 std::vector<SerializedHandle>& data() { return data_; } | 97 std::vector<SerializedHandle>& data() { return data_; } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 class PPAPI_PROXY_EXPORT ResourceMessageCallParams | 140 class PPAPI_PROXY_EXPORT ResourceMessageCallParams |
141 : public ResourceMessageParams { | 141 : public ResourceMessageParams { |
142 public: | 142 public: |
143 ResourceMessageCallParams(); | 143 ResourceMessageCallParams(); |
144 ResourceMessageCallParams(PP_Resource resource, int32_t sequence); | 144 ResourceMessageCallParams(PP_Resource resource, int32_t sequence); |
145 ~ResourceMessageCallParams() override; | 145 ~ResourceMessageCallParams() override; |
146 | 146 |
147 void set_has_callback() { has_callback_ = true; } | 147 void set_has_callback() { has_callback_ = true; } |
148 bool has_callback() const { return has_callback_; } | 148 bool has_callback() const { return has_callback_; } |
149 | 149 |
150 void Serialize(IPC::Message* msg) const override; | 150 void Serialize(base::Pickle* msg) const override; |
151 bool Deserialize(const IPC::Message* msg, | 151 bool Deserialize(const base::Pickle* msg, |
152 base::PickleIterator* iter) override; | 152 base::PickleIterator* iter) override; |
153 | 153 |
154 private: | 154 private: |
155 bool has_callback_; | 155 bool has_callback_; |
156 }; | 156 }; |
157 | 157 |
158 // Parameters common to all ResourceMessage "Reply" requests. | 158 // Parameters common to all ResourceMessage "Reply" requests. |
159 class PPAPI_PROXY_EXPORT ResourceMessageReplyParams | 159 class PPAPI_PROXY_EXPORT ResourceMessageReplyParams |
160 : public ResourceMessageParams { | 160 : public ResourceMessageParams { |
161 public: | 161 public: |
162 ResourceMessageReplyParams(); | 162 ResourceMessageReplyParams(); |
163 ResourceMessageReplyParams(PP_Resource resource, int32_t sequence); | 163 ResourceMessageReplyParams(PP_Resource resource, int32_t sequence); |
164 ~ResourceMessageReplyParams() override; | 164 ~ResourceMessageReplyParams() override; |
165 | 165 |
166 void set_result(int32_t r) { result_ = r; } | 166 void set_result(int32_t r) { result_ = r; } |
167 int32_t result() const { return result_; } | 167 int32_t result() const { return result_; } |
168 | 168 |
169 void Serialize(IPC::Message* msg) const override; | 169 void Serialize(base::Pickle* msg) const override; |
170 bool Deserialize(const IPC::Message* msg, | 170 bool Deserialize(const base::Pickle* msg, |
171 base::PickleIterator* iter) override; | 171 base::PickleIterator* iter) override; |
172 | 172 |
173 // Writes everything except the handles to |msg|. | 173 // Writes everything except the handles to |msg|. |
174 void WriteReplyHeader(IPC::Message* msg) const; | 174 void WriteReplyHeader(base::Pickle* msg) const; |
175 | 175 |
176 private: | 176 private: |
177 // Pepper "result code" for the callback. | 177 // Pepper "result code" for the callback. |
178 int32_t result_; | 178 int32_t result_; |
179 }; | 179 }; |
180 | 180 |
181 } // namespace proxy | 181 } // namespace proxy |
182 } // namespace ppapi | 182 } // namespace ppapi |
183 | 183 |
184 namespace IPC { | 184 namespace IPC { |
185 | 185 |
186 template <> struct PPAPI_PROXY_EXPORT | 186 template <> struct PPAPI_PROXY_EXPORT |
187 ParamTraits<ppapi::proxy::ResourceMessageCallParams> { | 187 ParamTraits<ppapi::proxy::ResourceMessageCallParams> { |
188 typedef ppapi::proxy::ResourceMessageCallParams param_type; | 188 typedef ppapi::proxy::ResourceMessageCallParams param_type; |
189 static void Write(Message* m, const param_type& p) { | 189 static void Write(base::Pickle* m, const param_type& p) { p.Serialize(m); } |
190 p.Serialize(m); | 190 static bool Read(const base::Pickle* m, |
191 } | 191 base::PickleIterator* iter, |
192 static bool Read(const Message* m, base::PickleIterator* iter, | |
193 param_type* r) { | 192 param_type* r) { |
194 return r->Deserialize(m, iter); | 193 return r->Deserialize(m, iter); |
195 } | 194 } |
196 static void Log(const param_type& p, std::string* l) { | 195 static void Log(const param_type& p, std::string* l) { |
197 } | 196 } |
198 }; | 197 }; |
199 | 198 |
200 template <> struct PPAPI_PROXY_EXPORT | 199 template <> struct PPAPI_PROXY_EXPORT |
201 ParamTraits<ppapi::proxy::ResourceMessageReplyParams> { | 200 ParamTraits<ppapi::proxy::ResourceMessageReplyParams> { |
202 typedef ppapi::proxy::ResourceMessageReplyParams param_type; | 201 typedef ppapi::proxy::ResourceMessageReplyParams param_type; |
203 static void Write(Message* m, const param_type& p) { | 202 static void Write(base::Pickle* m, const param_type& p) { p.Serialize(m); } |
204 p.Serialize(m); | 203 static bool Read(const base::Pickle* m, |
205 } | 204 base::PickleIterator* iter, |
206 static bool Read(const Message* m, base::PickleIterator* iter, | |
207 param_type* r) { | 205 param_type* r) { |
208 return r->Deserialize(m, iter); | 206 return r->Deserialize(m, iter); |
209 } | 207 } |
210 static void Log(const param_type& p, std::string* l) { | 208 static void Log(const param_type& p, std::string* l) { |
211 } | 209 } |
212 }; | 210 }; |
213 | 211 |
214 } // namespace IPC | 212 } // namespace IPC |
215 | 213 |
216 #endif // PPAPI_PROXY_RESOURCE_MESSAGE_PARAMS_H_ | 214 #endif // PPAPI_PROXY_RESOURCE_MESSAGE_PARAMS_H_ |
OLD | NEW |