| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_RAW_VAR_DATA_H_ | 5 #ifndef PPAPI_PROXY_RAW_VAR_DATA_H_ |
| 6 #define PPAPI_PROXY_RAW_VAR_DATA_H_ | 6 #define PPAPI_PROXY_RAW_VAR_DATA_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 bool initialized_; | 125 bool initialized_; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 // A RawVarData class for PP_Vars which are value types. | 128 // A RawVarData class for PP_Vars which are value types. |
| 129 class BasicRawVarData : public RawVarData { | 129 class BasicRawVarData : public RawVarData { |
| 130 public: | 130 public: |
| 131 BasicRawVarData(); | 131 BasicRawVarData(); |
| 132 virtual ~BasicRawVarData(); | 132 virtual ~BasicRawVarData(); |
| 133 | 133 |
| 134 // RawVarData implementation. | 134 // RawVarData implementation. |
| 135 virtual PP_VarType Type() OVERRIDE; | 135 virtual PP_VarType Type() override; |
| 136 virtual bool Init(const PP_Var& var, PP_Instance instance) OVERRIDE; | 136 virtual bool Init(const PP_Var& var, PP_Instance instance) override; |
| 137 virtual PP_Var CreatePPVar(PP_Instance instance) OVERRIDE; | 137 virtual PP_Var CreatePPVar(PP_Instance instance) override; |
| 138 virtual void PopulatePPVar(const PP_Var& var, | 138 virtual void PopulatePPVar(const PP_Var& var, |
| 139 const std::vector<PP_Var>& graph) OVERRIDE; | 139 const std::vector<PP_Var>& graph) override; |
| 140 virtual void Write(IPC::Message* m, | 140 virtual void Write(IPC::Message* m, |
| 141 const HandleWriter& handle_writer) OVERRIDE; | 141 const HandleWriter& handle_writer) override; |
| 142 virtual bool Read(PP_VarType type, | 142 virtual bool Read(PP_VarType type, |
| 143 const IPC::Message* m, | 143 const IPC::Message* m, |
| 144 PickleIterator* iter) OVERRIDE; | 144 PickleIterator* iter) override; |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 PP_Var var_; | 147 PP_Var var_; |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 // A RawVarData class for string PP_Vars. | 150 // A RawVarData class for string PP_Vars. |
| 151 class StringRawVarData : public RawVarData { | 151 class StringRawVarData : public RawVarData { |
| 152 public: | 152 public: |
| 153 StringRawVarData(); | 153 StringRawVarData(); |
| 154 virtual ~StringRawVarData(); | 154 virtual ~StringRawVarData(); |
| 155 | 155 |
| 156 // RawVarData implementation. | 156 // RawVarData implementation. |
| 157 virtual PP_VarType Type() OVERRIDE; | 157 virtual PP_VarType Type() override; |
| 158 virtual bool Init(const PP_Var& var, PP_Instance instance) OVERRIDE; | 158 virtual bool Init(const PP_Var& var, PP_Instance instance) override; |
| 159 virtual PP_Var CreatePPVar(PP_Instance instance) OVERRIDE; | 159 virtual PP_Var CreatePPVar(PP_Instance instance) override; |
| 160 virtual void PopulatePPVar(const PP_Var& var, | 160 virtual void PopulatePPVar(const PP_Var& var, |
| 161 const std::vector<PP_Var>& graph) OVERRIDE; | 161 const std::vector<PP_Var>& graph) override; |
| 162 virtual void Write(IPC::Message* m, | 162 virtual void Write(IPC::Message* m, |
| 163 const HandleWriter& handle_writer) OVERRIDE; | 163 const HandleWriter& handle_writer) override; |
| 164 virtual bool Read(PP_VarType type, | 164 virtual bool Read(PP_VarType type, |
| 165 const IPC::Message* m, | 165 const IPC::Message* m, |
| 166 PickleIterator* iter) OVERRIDE; | 166 PickleIterator* iter) override; |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 // The data in the string. | 169 // The data in the string. |
| 170 std::string data_; | 170 std::string data_; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 // A RawVarData class for array buffer PP_Vars. | 173 // A RawVarData class for array buffer PP_Vars. |
| 174 class ArrayBufferRawVarData : public RawVarData { | 174 class ArrayBufferRawVarData : public RawVarData { |
| 175 public: | 175 public: |
| 176 // Enum for array buffer message types. | 176 // Enum for array buffer message types. |
| 177 enum ShmemType { | 177 enum ShmemType { |
| 178 ARRAY_BUFFER_NO_SHMEM, | 178 ARRAY_BUFFER_NO_SHMEM, |
| 179 ARRAY_BUFFER_SHMEM_HOST, | 179 ARRAY_BUFFER_SHMEM_HOST, |
| 180 ARRAY_BUFFER_SHMEM_PLUGIN, | 180 ARRAY_BUFFER_SHMEM_PLUGIN, |
| 181 }; | 181 }; |
| 182 | 182 |
| 183 ArrayBufferRawVarData(); | 183 ArrayBufferRawVarData(); |
| 184 virtual ~ArrayBufferRawVarData(); | 184 virtual ~ArrayBufferRawVarData(); |
| 185 | 185 |
| 186 // RawVarData implementation. | 186 // RawVarData implementation. |
| 187 virtual PP_VarType Type() OVERRIDE; | 187 virtual PP_VarType Type() override; |
| 188 virtual bool Init(const PP_Var& var, PP_Instance instance) OVERRIDE; | 188 virtual bool Init(const PP_Var& var, PP_Instance instance) override; |
| 189 virtual PP_Var CreatePPVar(PP_Instance instance) OVERRIDE; | 189 virtual PP_Var CreatePPVar(PP_Instance instance) override; |
| 190 virtual void PopulatePPVar(const PP_Var& var, | 190 virtual void PopulatePPVar(const PP_Var& var, |
| 191 const std::vector<PP_Var>& graph) OVERRIDE; | 191 const std::vector<PP_Var>& graph) override; |
| 192 virtual void Write(IPC::Message* m, | 192 virtual void Write(IPC::Message* m, |
| 193 const HandleWriter& handle_writer) OVERRIDE; | 193 const HandleWriter& handle_writer) override; |
| 194 virtual bool Read(PP_VarType type, | 194 virtual bool Read(PP_VarType type, |
| 195 const IPC::Message* m, | 195 const IPC::Message* m, |
| 196 PickleIterator* iter) OVERRIDE; | 196 PickleIterator* iter) override; |
| 197 virtual SerializedHandle* GetHandle() OVERRIDE; | 197 virtual SerializedHandle* GetHandle() override; |
| 198 | 198 |
| 199 private: | 199 private: |
| 200 // The type of the storage underlying the array buffer. | 200 // The type of the storage underlying the array buffer. |
| 201 ShmemType type_; | 201 ShmemType type_; |
| 202 // The data in the buffer. Valid for |type_| == ARRAY_BUFFER_NO_SHMEM. | 202 // The data in the buffer. Valid for |type_| == ARRAY_BUFFER_NO_SHMEM. |
| 203 std::string data_; | 203 std::string data_; |
| 204 // Host shmem handle. Valid for |type_| == ARRAY_BUFFER_SHMEM_HOST. | 204 // Host shmem handle. Valid for |type_| == ARRAY_BUFFER_SHMEM_HOST. |
| 205 int host_shm_handle_id_; | 205 int host_shm_handle_id_; |
| 206 // Plugin shmem handle. Valid for |type_| == ARRAY_BUFFER_SHMEM_PLUGIN. | 206 // Plugin shmem handle. Valid for |type_| == ARRAY_BUFFER_SHMEM_PLUGIN. |
| 207 SerializedHandle plugin_shm_handle_; | 207 SerializedHandle plugin_shm_handle_; |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 // A RawVarData class for array PP_Vars. | 210 // A RawVarData class for array PP_Vars. |
| 211 class ArrayRawVarData : public RawVarData { | 211 class ArrayRawVarData : public RawVarData { |
| 212 public: | 212 public: |
| 213 ArrayRawVarData(); | 213 ArrayRawVarData(); |
| 214 virtual ~ArrayRawVarData(); | 214 virtual ~ArrayRawVarData(); |
| 215 | 215 |
| 216 void AddChild(size_t element); | 216 void AddChild(size_t element); |
| 217 | 217 |
| 218 // RawVarData implementation. | 218 // RawVarData implementation. |
| 219 virtual PP_VarType Type() OVERRIDE; | 219 virtual PP_VarType Type() override; |
| 220 virtual bool Init(const PP_Var& var, PP_Instance instance) OVERRIDE; | 220 virtual bool Init(const PP_Var& var, PP_Instance instance) override; |
| 221 virtual PP_Var CreatePPVar(PP_Instance instance) OVERRIDE; | 221 virtual PP_Var CreatePPVar(PP_Instance instance) override; |
| 222 virtual void PopulatePPVar(const PP_Var& var, | 222 virtual void PopulatePPVar(const PP_Var& var, |
| 223 const std::vector<PP_Var>& graph) OVERRIDE; | 223 const std::vector<PP_Var>& graph) override; |
| 224 virtual void Write(IPC::Message* m, | 224 virtual void Write(IPC::Message* m, |
| 225 const HandleWriter& handle_writer) OVERRIDE; | 225 const HandleWriter& handle_writer) override; |
| 226 virtual bool Read(PP_VarType type, | 226 virtual bool Read(PP_VarType type, |
| 227 const IPC::Message* m, | 227 const IPC::Message* m, |
| 228 PickleIterator* iter) OVERRIDE; | 228 PickleIterator* iter) override; |
| 229 | 229 |
| 230 private: | 230 private: |
| 231 std::vector<size_t> children_; | 231 std::vector<size_t> children_; |
| 232 }; | 232 }; |
| 233 | 233 |
| 234 // A RawVarData class for dictionary PP_Vars. | 234 // A RawVarData class for dictionary PP_Vars. |
| 235 class DictionaryRawVarData : public RawVarData { | 235 class DictionaryRawVarData : public RawVarData { |
| 236 public: | 236 public: |
| 237 DictionaryRawVarData(); | 237 DictionaryRawVarData(); |
| 238 virtual ~DictionaryRawVarData(); | 238 virtual ~DictionaryRawVarData(); |
| 239 | 239 |
| 240 void AddChild(const std::string& key, size_t value); | 240 void AddChild(const std::string& key, size_t value); |
| 241 | 241 |
| 242 // RawVarData implementation. | 242 // RawVarData implementation. |
| 243 virtual PP_VarType Type() OVERRIDE; | 243 virtual PP_VarType Type() override; |
| 244 virtual bool Init(const PP_Var& var, PP_Instance instance) OVERRIDE; | 244 virtual bool Init(const PP_Var& var, PP_Instance instance) override; |
| 245 virtual PP_Var CreatePPVar(PP_Instance instance) OVERRIDE; | 245 virtual PP_Var CreatePPVar(PP_Instance instance) override; |
| 246 virtual void PopulatePPVar(const PP_Var& var, | 246 virtual void PopulatePPVar(const PP_Var& var, |
| 247 const std::vector<PP_Var>& graph) OVERRIDE; | 247 const std::vector<PP_Var>& graph) override; |
| 248 virtual void Write(IPC::Message* m, | 248 virtual void Write(IPC::Message* m, |
| 249 const HandleWriter& handle_writer) OVERRIDE; | 249 const HandleWriter& handle_writer) override; |
| 250 virtual bool Read(PP_VarType type, | 250 virtual bool Read(PP_VarType type, |
| 251 const IPC::Message* m, | 251 const IPC::Message* m, |
| 252 PickleIterator* iter) OVERRIDE; | 252 PickleIterator* iter) override; |
| 253 | 253 |
| 254 private: | 254 private: |
| 255 std::vector<std::pair<std::string, size_t> > children_; | 255 std::vector<std::pair<std::string, size_t> > children_; |
| 256 }; | 256 }; |
| 257 | 257 |
| 258 // A RawVarData class for resource PP_Vars. | 258 // A RawVarData class for resource PP_Vars. |
| 259 // This class does not hold a reference on the PP_Resource that is being | 259 // This class does not hold a reference on the PP_Resource that is being |
| 260 // serialized. If sending a resource from the plugin to the host, the plugin | 260 // serialized. If sending a resource from the plugin to the host, the plugin |
| 261 // should not release the ResourceVar before sending the serialized message to | 261 // should not release the ResourceVar before sending the serialized message to |
| 262 // the host, and the host should immediately consume the ResourceVar before | 262 // the host, and the host should immediately consume the ResourceVar before |
| 263 // processing further messages. | 263 // processing further messages. |
| 264 class ResourceRawVarData : public RawVarData { | 264 class ResourceRawVarData : public RawVarData { |
| 265 public: | 265 public: |
| 266 ResourceRawVarData(); | 266 ResourceRawVarData(); |
| 267 virtual ~ResourceRawVarData(); | 267 virtual ~ResourceRawVarData(); |
| 268 | 268 |
| 269 // RawVarData implementation. | 269 // RawVarData implementation. |
| 270 virtual PP_VarType Type() OVERRIDE; | 270 virtual PP_VarType Type() override; |
| 271 virtual bool Init(const PP_Var& var, PP_Instance instance) OVERRIDE; | 271 virtual bool Init(const PP_Var& var, PP_Instance instance) override; |
| 272 virtual PP_Var CreatePPVar(PP_Instance instance) OVERRIDE; | 272 virtual PP_Var CreatePPVar(PP_Instance instance) override; |
| 273 virtual void PopulatePPVar(const PP_Var& var, | 273 virtual void PopulatePPVar(const PP_Var& var, |
| 274 const std::vector<PP_Var>& graph) OVERRIDE; | 274 const std::vector<PP_Var>& graph) override; |
| 275 virtual void Write(IPC::Message* m, | 275 virtual void Write(IPC::Message* m, |
| 276 const HandleWriter& handle_writer) OVERRIDE; | 276 const HandleWriter& handle_writer) override; |
| 277 virtual bool Read(PP_VarType type, | 277 virtual bool Read(PP_VarType type, |
| 278 const IPC::Message* m, | 278 const IPC::Message* m, |
| 279 PickleIterator* iter) OVERRIDE; | 279 PickleIterator* iter) override; |
| 280 | 280 |
| 281 private: | 281 private: |
| 282 // Resource ID in the plugin. If one has not yet been created, this is 0. | 282 // Resource ID in the plugin. If one has not yet been created, this is 0. |
| 283 // This is a borrowed reference; the resource's refcount is not incremented. | 283 // This is a borrowed reference; the resource's refcount is not incremented. |
| 284 PP_Resource pp_resource_; | 284 PP_Resource pp_resource_; |
| 285 | 285 |
| 286 // Pending resource host ID in the renderer. | 286 // Pending resource host ID in the renderer. |
| 287 int pending_renderer_host_id_; | 287 int pending_renderer_host_id_; |
| 288 | 288 |
| 289 // Pending resource host ID in the browser. | 289 // Pending resource host ID in the browser. |
| 290 int pending_browser_host_id_; | 290 int pending_browser_host_id_; |
| 291 | 291 |
| 292 // A message containing information about how to create a plugin-side | 292 // A message containing information about how to create a plugin-side |
| 293 // resource. The message type will vary based on the resource type, and will | 293 // resource. The message type will vary based on the resource type, and will |
| 294 // usually contain a pending resource host ID, and other required information. | 294 // usually contain a pending resource host ID, and other required information. |
| 295 // If the resource was created directly, this is NULL. | 295 // If the resource was created directly, this is NULL. |
| 296 scoped_ptr<IPC::Message> creation_message_; | 296 scoped_ptr<IPC::Message> creation_message_; |
| 297 }; | 297 }; |
| 298 | 298 |
| 299 } // namespace proxy | 299 } // namespace proxy |
| 300 } // namespace ppapi | 300 } // namespace ppapi |
| 301 | 301 |
| 302 #endif // PPAPI_PROXY_RAW_VAR_DATA_H_ | 302 #endif // PPAPI_PROXY_RAW_VAR_DATA_H_ |
| OLD | NEW |