Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: ppapi/shared_impl/var.h

Issue 1097393007: Update {virtual,override} to follow C++11 style in ppapi. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split off one file into separate review. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // 94 //
95 // Converting a PP_Var to a string: 95 // Converting a PP_Var to a string:
96 // StringVar* string = StringVar::FromPPVar(var); 96 // StringVar* string = StringVar::FromPPVar(var);
97 // if (!string) 97 // if (!string)
98 // return false; // Not a string or an invalid var. 98 // return false; // Not a string or an invalid var.
99 // DoSomethingWithTheString(string->value()); 99 // DoSomethingWithTheString(string->value());
100 class PPAPI_SHARED_EXPORT StringVar : public Var { 100 class PPAPI_SHARED_EXPORT StringVar : public Var {
101 public: 101 public:
102 explicit StringVar(const std::string& str); 102 explicit StringVar(const std::string& str);
103 StringVar(const char* str, uint32 len); 103 StringVar(const char* str, uint32 len);
104 virtual ~StringVar(); 104 ~StringVar() override;
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 StringVar* AsStringVar() override;
116 virtual PP_VarType GetType() const override; 116 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 24 matching lines...) Expand all
151 // PpapiGlobals::Get()->GetVarTracker()->CreateArrayBuffer(size); 151 // PpapiGlobals::Get()->GetVarTracker()->CreateArrayBuffer(size);
152 // 152 //
153 // Converting a PP_Var to an ArrayBufferVar: 153 // Converting a PP_Var to an ArrayBufferVar:
154 // ArrayBufferVar* array = ArrayBufferVar::FromPPVar(var); 154 // ArrayBufferVar* array = ArrayBufferVar::FromPPVar(var);
155 // if (!array) 155 // if (!array)
156 // return false; // Not an ArrayBuffer or an invalid var. 156 // return false; // Not an ArrayBuffer or an invalid var.
157 // DoSomethingWithTheBuffer(array); 157 // DoSomethingWithTheBuffer(array);
158 class PPAPI_SHARED_EXPORT ArrayBufferVar : public Var { 158 class PPAPI_SHARED_EXPORT ArrayBufferVar : public Var {
159 public: 159 public:
160 ArrayBufferVar(); 160 ArrayBufferVar();
161 virtual ~ArrayBufferVar(); 161 ~ArrayBufferVar() override;
162 162
163 virtual void* Map() = 0; 163 virtual void* Map() = 0;
164 virtual void Unmap() = 0; 164 virtual void Unmap() = 0;
165 virtual uint32 ByteLength() = 0; 165 virtual uint32 ByteLength() = 0;
166 166
167 // Creates a new shared memory region, and copies the data in the 167 // Creates a new shared memory region, and copies the data in the
168 // ArrayBufferVar into it. On the plugin side, host_shm_handle_id will be set 168 // ArrayBufferVar into it. On the plugin side, host_shm_handle_id will be set
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 ArrayBufferVar* AsArrayBufferVar() override;
180 virtual PP_VarType GetType() const override; 180 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_
OLDNEW
« no previous file with comments | « ppapi/shared_impl/thread_aware_callback_unittest.cc ('k') | ppapi/shared_impl/var_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698