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_SHARED_IMPL_VAR_H_ | 5 #ifndef PPAPI_SHARED_IMPL_VAR_H_ |
6 #define PPAPI_SHARED_IMPL_VAR_H_ | 6 #define PPAPI_SHARED_IMPL_VAR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 const std::string& value() const { return value_; } | 106 const std::string& value() const { return value_; } |
107 // Return a pointer to the internal string. This allows other objects to | 107 // Return a pointer to the internal string. This allows other objects to |
108 // temporarily store a weak pointer to our internal string. Use with care; the | 108 // temporarily store a weak pointer to our internal string. Use with care; the |
109 // pointer *will* become invalid if this StringVar is removed from the | 109 // pointer *will* become invalid if this StringVar is removed from the |
110 // tracker. (All of this applies to value(), but this one's even easier to use | 110 // tracker. (All of this applies to value(), but this one's even easier to use |
111 // dangerously). | 111 // dangerously). |
112 const std::string* ptr() const { return &value_; } | 112 const std::string* ptr() const { return &value_; } |
113 | 113 |
114 // Var override. | 114 // Var override. |
115 virtual StringVar* AsStringVar() OVERRIDE; | 115 virtual StringVar* AsStringVar() override; |
116 virtual PP_VarType GetType() const OVERRIDE; | 116 virtual PP_VarType GetType() const override; |
117 | 117 |
118 // Helper function to create a PP_Var of type string that contains a copy of | 118 // Helper function to create a PP_Var of type string that contains a copy of |
119 // the given string. The input data must be valid UTF-8 encoded text, if it | 119 // the given string. The input data must be valid UTF-8 encoded text, if it |
120 // is not valid UTF-8, a NULL var will be returned. | 120 // is not valid UTF-8, a NULL var will be returned. |
121 // | 121 // |
122 // The return value will have a reference count of 1. Internally, this will | 122 // The return value will have a reference count of 1. Internally, this will |
123 // create a StringVar and return the reference to it in the var. | 123 // create a StringVar and return the reference to it in the var. |
124 static PP_Var StringToPPVar(const std::string& str); | 124 static PP_Var StringToPPVar(const std::string& str); |
125 static PP_Var StringToPPVar(const char* str, uint32 len); | 125 static PP_Var StringToPPVar(const char* str, uint32 len); |
126 | 126 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // to some value that is not -1. On the host side, plugin_shm_handle will be | 169 // to some value that is not -1. On the host side, plugin_shm_handle will be |
170 // set to a valid SharedMemoryHandle. | 170 // set to a valid SharedMemoryHandle. |
171 // | 171 // |
172 // Returns true if creating the shared memory (and copying) is successful, | 172 // Returns true if creating the shared memory (and copying) is successful, |
173 // false otherwise. | 173 // false otherwise. |
174 virtual bool CopyToNewShmem(PP_Instance instance, | 174 virtual bool CopyToNewShmem(PP_Instance instance, |
175 int* host_shm_handle_id, | 175 int* host_shm_handle_id, |
176 base::SharedMemoryHandle* plugin_shm_handle) = 0; | 176 base::SharedMemoryHandle* plugin_shm_handle) = 0; |
177 | 177 |
178 // Var override. | 178 // Var override. |
179 virtual ArrayBufferVar* AsArrayBufferVar() OVERRIDE; | 179 virtual ArrayBufferVar* AsArrayBufferVar() override; |
180 virtual PP_VarType GetType() const OVERRIDE; | 180 virtual PP_VarType GetType() const override; |
181 | 181 |
182 // Helper function that converts a PP_Var to an ArrayBufferVar. This will | 182 // Helper function that converts a PP_Var to an ArrayBufferVar. This will |
183 // return NULL if the PP_Var is not of ArrayBuffer type. | 183 // return NULL if the PP_Var is not of ArrayBuffer type. |
184 static ArrayBufferVar* FromPPVar(PP_Var var); | 184 static ArrayBufferVar* FromPPVar(PP_Var var); |
185 | 185 |
186 private: | 186 private: |
187 DISALLOW_COPY_AND_ASSIGN(ArrayBufferVar); | 187 DISALLOW_COPY_AND_ASSIGN(ArrayBufferVar); |
188 }; | 188 }; |
189 | 189 |
190 } // namespace ppapi | 190 } // namespace ppapi |
191 | 191 |
192 #endif // PPAPI_SHARED_IMPL_VAR_H_ | 192 #endif // PPAPI_SHARED_IMPL_VAR_H_ |
OLD | NEW |