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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 // Write the graph to a message using the given HandleWriter. | 66 // Write the graph to a message using the given HandleWriter. |
67 void Write(IPC::Message* m, const HandleWriter& handle_writer); | 67 void Write(IPC::Message* m, const HandleWriter& handle_writer); |
68 // Write the graph to a message using the default handle writer. | 68 // Write the graph to a message using the default handle writer. |
69 void Write(IPC::Message* m); | 69 void Write(IPC::Message* m); |
70 | 70 |
71 // Create a RawVarDataGraph from the given message. | 71 // Create a RawVarDataGraph from the given message. |
72 static scoped_ptr<RawVarDataGraph> Read(const IPC::Message* m, | 72 static scoped_ptr<RawVarDataGraph> Read(const IPC::Message* m, |
73 PickleIterator* iter); | 73 PickleIterator* iter); |
74 | 74 |
| 75 // Returns a vector of SerializedHandles associated with this RawVarDataGraph. |
| 76 // Ownership of the pointers remains with the elements of the RawVarDataGraph. |
| 77 std::vector<SerializedHandle*> GetHandles(); |
| 78 |
| 79 // Sets the threshold size at which point we switch from transmitting |
| 80 // array buffers in IPC messages to using shared memory. This is only used |
| 81 // for testing purposes where we need to transmit small buffers using shmem |
| 82 // (in order to have fast tests). |
| 83 static void SetMinimumArrayBufferSizeForShmemForTest(uint32 threshold); |
| 84 |
75 // A list of the nodes in the graph. | 85 // A list of the nodes in the graph. |
76 ScopedVector<RawVarData> data_; | 86 ScopedVector<RawVarData> data_; |
77 }; | 87 }; |
78 | 88 |
79 // Abstract base class for the data contained in a PP_Var. | 89 // Abstract base class for the data contained in a PP_Var. |
80 class RawVarData { | 90 class RawVarData { |
81 public: | 91 public: |
82 // Create a new, empty RawVarData for the given type. | 92 // Create a new, empty RawVarData for the given type. |
83 static RawVarData* Create(PP_VarType type); | 93 static RawVarData* Create(PP_VarType type); |
84 RawVarData(); | 94 RawVarData(); |
(...skipping 15 matching lines...) Expand all Loading... |
100 const std::vector<PP_Var>& graph) = 0; | 110 const std::vector<PP_Var>& graph) = 0; |
101 | 111 |
102 // Writes the RawVarData to a message. | 112 // Writes the RawVarData to a message. |
103 virtual void Write(IPC::Message* m, | 113 virtual void Write(IPC::Message* m, |
104 const HandleWriter& handle_writer) = 0; | 114 const HandleWriter& handle_writer) = 0; |
105 // Reads the RawVarData from a message. Returns true on success. | 115 // Reads the RawVarData from a message. Returns true on success. |
106 virtual bool Read(PP_VarType type, | 116 virtual bool Read(PP_VarType type, |
107 const IPC::Message* m, | 117 const IPC::Message* m, |
108 PickleIterator* iter) = 0; | 118 PickleIterator* iter) = 0; |
109 | 119 |
| 120 // Returns a SerializedHandle associated with this RawVarData or NULL if none |
| 121 // exists. Ownership of the pointer remains with the RawVarData. |
| 122 virtual SerializedHandle* GetHandle(); |
| 123 |
110 bool initialized() { return initialized_; } | 124 bool initialized() { return initialized_; } |
111 | 125 |
112 protected: | 126 protected: |
113 bool initialized_; | 127 bool initialized_; |
114 }; | 128 }; |
115 | 129 |
116 // A RawVarData class for PP_Vars which are value types. | 130 // A RawVarData class for PP_Vars which are value types. |
117 class BasicRawVarData : public RawVarData { | 131 class BasicRawVarData : public RawVarData { |
118 public: | 132 public: |
119 BasicRawVarData(); | 133 BasicRawVarData(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 virtual PP_VarType Type() OVERRIDE; | 189 virtual PP_VarType Type() OVERRIDE; |
176 virtual bool Init(const PP_Var& var, PP_Instance instance) OVERRIDE; | 190 virtual bool Init(const PP_Var& var, PP_Instance instance) OVERRIDE; |
177 virtual PP_Var CreatePPVar(PP_Instance instance) OVERRIDE; | 191 virtual PP_Var CreatePPVar(PP_Instance instance) OVERRIDE; |
178 virtual void PopulatePPVar(const PP_Var& var, | 192 virtual void PopulatePPVar(const PP_Var& var, |
179 const std::vector<PP_Var>& graph) OVERRIDE; | 193 const std::vector<PP_Var>& graph) OVERRIDE; |
180 virtual void Write(IPC::Message* m, | 194 virtual void Write(IPC::Message* m, |
181 const HandleWriter& handle_writer) OVERRIDE; | 195 const HandleWriter& handle_writer) OVERRIDE; |
182 virtual bool Read(PP_VarType type, | 196 virtual bool Read(PP_VarType type, |
183 const IPC::Message* m, | 197 const IPC::Message* m, |
184 PickleIterator* iter) OVERRIDE; | 198 PickleIterator* iter) OVERRIDE; |
| 199 virtual SerializedHandle* GetHandle() OVERRIDE; |
185 | 200 |
186 private: | 201 private: |
187 // The type of the storage underlying the array buffer. | 202 // The type of the storage underlying the array buffer. |
188 ShmemType type_; | 203 ShmemType type_; |
189 // The data in the buffer. Valid for |type_| == ARRAY_BUFFER_NO_SHMEM. | 204 // The data in the buffer. Valid for |type_| == ARRAY_BUFFER_NO_SHMEM. |
190 std::string data_; | 205 std::string data_; |
191 // Host shmem handle. Valid for |type_| == ARRAY_BUFFER_SHMEM_HOST. | 206 // Host shmem handle. Valid for |type_| == ARRAY_BUFFER_SHMEM_HOST. |
192 int host_shm_handle_id_; | 207 int host_shm_handle_id_; |
193 // Plugin shmem handle. Valid for |type_| == ARRAY_BUFFER_SHMEM_PLUGIN. | 208 // Plugin shmem handle. Valid for |type_| == ARRAY_BUFFER_SHMEM_PLUGIN. |
194 SerializedHandle plugin_shm_handle_; | 209 SerializedHandle plugin_shm_handle_; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 PickleIterator* iter) OVERRIDE; | 254 PickleIterator* iter) OVERRIDE; |
240 | 255 |
241 private: | 256 private: |
242 std::vector<std::pair<std::string, size_t> > children_; | 257 std::vector<std::pair<std::string, size_t> > children_; |
243 }; | 258 }; |
244 | 259 |
245 } // namespace proxy | 260 } // namespace proxy |
246 } // namespace ppapi | 261 } // namespace ppapi |
247 | 262 |
248 #endif // PPAPI_PROXY_RAW_VAR_DATA_H_ | 263 #endif // PPAPI_PROXY_RAW_VAR_DATA_H_ |
OLD | NEW |