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

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

Issue 23346009: [PPAPI] Added a new Var subclass, ResourceVar. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 4 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
« no previous file with comments | « no previous file | ppapi/shared_impl/var.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
13 #include "base/platform_file.h" 13 #include "base/platform_file.h"
14 #include "ppapi/c/pp_file_info.h"
15 #include "ppapi/c/pp_resource.h"
14 #include "ppapi/c/pp_var.h" 16 #include "ppapi/c/pp_var.h"
15 #include "ppapi/shared_impl/host_resource.h" 17 #include "ppapi/shared_impl/host_resource.h"
16 #include "ppapi/shared_impl/ppapi_shared_export.h" 18 #include "ppapi/shared_impl/ppapi_shared_export.h"
17 19
18 namespace ppapi { 20 namespace ppapi {
19 21
20 class ArrayBufferVar; 22 class ArrayBufferVar;
21 class ArrayVar; 23 class ArrayVar;
22 class DictionaryVar; 24 class DictionaryVar;
23 class NPObjectVar; 25 class NPObjectVar;
24 class ProxyObjectVar; 26 class ProxyObjectVar;
27 class ResourceVar;
25 class StringVar; 28 class StringVar;
26 class VarTracker; 29 class VarTracker;
27 30
28 // Var ------------------------------------------------------------------------- 31 // Var -------------------------------------------------------------------------
29 32
30 // Represents a non-POD var. 33 // Represents a non-POD var.
31 class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> { 34 class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> {
32 public: 35 public:
33 virtual ~Var(); 36 virtual ~Var();
34 37
35 // Returns a string representing the given var for logging purposes. 38 // Returns a string representing the given var for logging purposes.
36 static std::string PPVarToLogString(PP_Var var); 39 static std::string PPVarToLogString(PP_Var var);
37 40
38 virtual StringVar* AsStringVar(); 41 virtual StringVar* AsStringVar();
39 virtual ArrayBufferVar* AsArrayBufferVar(); 42 virtual ArrayBufferVar* AsArrayBufferVar();
40 virtual NPObjectVar* AsNPObjectVar(); 43 virtual NPObjectVar* AsNPObjectVar();
41 virtual ProxyObjectVar* AsProxyObjectVar(); 44 virtual ProxyObjectVar* AsProxyObjectVar();
42 virtual ArrayVar* AsArrayVar(); 45 virtual ArrayVar* AsArrayVar();
43 virtual DictionaryVar* AsDictionaryVar(); 46 virtual DictionaryVar* AsDictionaryVar();
47 virtual ResourceVar* AsResourceVar();
44 48
45 // Creates a PP_Var corresponding to this object. The return value will have 49 // Creates a PP_Var corresponding to this object. The return value will have
46 // one reference addrefed on behalf of the caller. 50 // one reference addrefed on behalf of the caller.
47 PP_Var GetPPVar(); 51 PP_Var GetPPVar();
48 52
49 // Returns the type of this var. 53 // Returns the type of this var.
50 virtual PP_VarType GetType() const = 0; 54 virtual PP_VarType GetType() const = 0;
51 55
52 // Returns the ID corresponing to the string or object if it exists already, 56 // Returns the ID corresponing to the string or object if it exists already,
53 // or 0 if an ID hasn't been generated for this object (the plugin is holding 57 // or 0 if an ID hasn't been generated for this object (the plugin is holding
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 virtual PP_VarType GetType() const OVERRIDE; 184 virtual PP_VarType GetType() const OVERRIDE;
181 185
182 // Helper function that converts a PP_Var to an ArrayBufferVar. This will 186 // Helper function that converts a PP_Var to an ArrayBufferVar. This will
183 // return NULL if the PP_Var is not of ArrayBuffer type. 187 // return NULL if the PP_Var is not of ArrayBuffer type.
184 static ArrayBufferVar* FromPPVar(PP_Var var); 188 static ArrayBufferVar* FromPPVar(PP_Var var);
185 189
186 private: 190 private:
187 DISALLOW_COPY_AND_ASSIGN(ArrayBufferVar); 191 DISALLOW_COPY_AND_ASSIGN(ArrayBufferVar);
188 }; 192 };
189 193
194 // ResourceVar -----------------------------------------------------------------
yzshen1 2013/08/26 17:20:46 Please consider a separate file. (Just as array an
Matt Giuca 2013/08/28 07:12:14 Done.
195
196 // The information about a resource var that is serialized.
197 struct PPAPI_SHARED_EXPORT ResourceInfo {
Matt Giuca 2013/08/23 08:41:16 The reason I put this in a separate struct (instea
Matt Giuca 2013/08/28 07:12:14 Gone.
198 ResourceInfo(); // Makes a null resource info.
199
200 // Pending host resource ID in the renderer. 0 if there is already a real
yzshen1 2013/08/26 17:20:46 nit, but better to be consistent: this is a "resou
Matt Giuca 2013/08/28 07:12:14 Gone.
201 // resource.
202 int pending_renderer_id;
yzshen1 2013/08/26 17:20:46 how about pending_*host*_id or pending_renderer_ho
Matt Giuca 2013/08/28 07:12:14 Gone.
203
204 // TODO(mgiuca): Also add a pending_browser_id when we create a separate
205 // pending host resource in the browser.
206
207 // Real resource ID in the plugin. 0 if one has not yet been created
208 // (indicating that there is a pending host resource).
yzshen1 2013/08/26 17:20:46 nit, but better to be consistent: pending "resourc
Matt Giuca 2013/08/28 07:12:14 Gone.
209 PP_Resource resource_id;
210
211 // Type of the file system (for file system resources only).
212 PP_FileSystemType file_system_type;
raymes 2013/08/26 00:06:11 As discussed could this be an IPC::Message which i
yzshen1 2013/08/26 17:20:46 +1 to use some more generic format instead of havi
Matt Giuca 2013/08/28 07:12:14 Done.
213 };
214
215 // Represents a resource Var.
216 class PPAPI_SHARED_EXPORT ResourceVar : public Var {
Matt Giuca 2013/08/23 08:41:16 Now I am a bit uncertain about exactly what method
raymes 2013/08/26 00:06:11 I would just have a set/get ResourceInfo. A setter
Matt Giuca 2013/08/28 07:12:14 Done.
217 public:
218 ResourceVar(); // Makes a null resource var.
219 virtual ~ResourceVar();
220
221 // Sets the pending host resource ID.
222 void SetPendingId(int pending_renderer_id);
yzshen1 2013/08/26 17:20:46 The setters and getters are using different naming
Matt Giuca 2013/08/28 07:12:14 Gone.
223
224 // Sets the resource ID.
225 void SetResourceId(int resource_id);
226
227 // Sets the file system type.
228 void SetFileSystemType(PP_FileSystemType file_system_type);
229
230 // Gets the resource ID associated with this var.
yzshen1 2013/08/26 17:20:46 "pending host ID", please
Matt Giuca 2013/08/28 07:12:14 Gone.
231 // This is 0 if a resource is still pending.
232 int pending_renderer_id() const { return data_.pending_renderer_id; }
233
234 // Gets the resource ID associated with this var.
235 // This is 0 if a resource is still pending.
236 PP_Resource resource_id() const { return data_.resource_id; }
237
238 // Gets the file system type.
239 // Only valid for file system resources.
240 PP_FileSystemType file_system_type() const { return data_.file_system_type; }
241
242 // Get the data associated with this resource.
243 const ResourceInfo& data() const { return data_; }
244
245 // Get the data associated with this resource.
246 ResourceInfo* mutable_data() { return &data_; }
yzshen1 2013/08/26 17:20:46 Maybe the following two signatures look more consi
Matt Giuca 2013/08/28 07:12:14 Gone. But for reference, I'm following the patter
yzshen1 2013/08/28 17:31:58 Okay.
247
248 // Var override.
249 virtual ResourceVar* AsResourceVar() OVERRIDE;
250 virtual PP_VarType GetType() const OVERRIDE;
251
252 // Helper function that converts a PP_Var to a ResourceVar. This will
253 // return NULL if the PP_Var is not of Resource type.
254 static ResourceVar* FromPPVar(PP_Var var);
255
256 private:
257 ResourceInfo data_;
258
259 DISALLOW_COPY_AND_ASSIGN(ResourceVar);
260 };
261
190 } // namespace ppapi 262 } // namespace ppapi
191 263
192 #endif // PPAPI_SHARED_IMPL_VAR_H_ 264 #endif // PPAPI_SHARED_IMPL_VAR_H_
OLDNEW
« no previous file with comments | « no previous file | ppapi/shared_impl/var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698