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

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

Issue 8872065: Pepper: Var keeps invalid var_id if VarTracker release it and there is another reference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another approach to reset var_id on erase Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/shared_impl/var_tracker.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ppapi/c/pp_var.h" 12 #include "ppapi/c/pp_var.h"
13 #include "ppapi/shared_impl/ppapi_shared_export.h" 13 #include "ppapi/shared_impl/ppapi_shared_export.h"
14 14
15 namespace ppapi { 15 namespace ppapi {
16 16
17 class NPObjectVar; 17 class NPObjectVar;
18 class ProxyObjectVar; 18 class ProxyObjectVar;
19 class StringVar; 19 class StringVar;
20 class VarTracker;
20 21
21 // Var ------------------------------------------------------------------------- 22 // Var -------------------------------------------------------------------------
22 23
23 // Represents a non-POD var. 24 // Represents a non-POD var.
24 class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> { 25 class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> {
25 public: 26 public:
26 virtual ~Var(); 27 virtual ~Var();
27 28
28 // Returns a string representing the given var for logging purposes. 29 // Returns a string representing the given var for logging purposes.
29 static std::string PPVarToLogString(PP_Var var); 30 static std::string PPVarToLogString(PP_Var var);
(...skipping 11 matching lines...) Expand all
41 42
42 // Returns the ID corresponing to the string or object if it exists already, 43 // Returns the ID corresponing to the string or object if it exists already,
43 // or 0 if an ID hasn't been generated for this object (the plugin is holding 44 // or 0 if an ID hasn't been generated for this object (the plugin is holding
44 // no refs). 45 // no refs).
45 // 46 //
46 // Contrast to GetOrCreateVarID which creates the ID and a ref on behalf of 47 // Contrast to GetOrCreateVarID which creates the ID and a ref on behalf of
47 // the plugin. 48 // the plugin.
48 int32 GetExistingVarID() const; 49 int32 GetExistingVarID() const;
49 50
50 protected: 51 protected:
52 friend class VarTracker;
53
51 Var(); 54 Var();
52 55
53 // Returns the unique ID associated with this string or object, creating it 56 // Returns the unique ID associated with this string or object, creating it
54 // if necessary. The return value will be 0 if the string or object is 57 // if necessary. The return value will be 0 if the string or object is
55 // invalid. 58 // invalid.
56 // 59 //
57 // This function will take a reference to the var that will be passed to the 60 // This function will take a reference to the var that will be passed to the
58 // caller. 61 // caller.
59 int32 GetOrCreateVarID(); 62 int32 GetOrCreateVarID();
60 63
61 // Sets the internal object ID. This assumes that the ID hasn't been set 64 // Sets the internal object ID. This assumes that the ID hasn't been set
62 // before. This is used in cases where the ID is generated externally. 65 // before. This is used in cases where the ID is generated externally.
63 void AssignVarID(int32 id); 66 void AssignVarID(int32 id);
64 67
68 // Reset the assigned object ID.
69 void ResetVarID(void) { AssignVarID(0); };
dmichael (off chromium) 2011/12/13 15:34:32 nit: We don't normally put 'void' in the parameter
70
65 private: 71 private:
66 // This will be 0 if no ID has been assigned (this happens lazily). 72 // This will be 0 if no ID has been assigned (this happens lazily).
67 int32 var_id_; 73 int32 var_id_;
68 74
69 DISALLOW_COPY_AND_ASSIGN(Var); 75 DISALLOW_COPY_AND_ASSIGN(Var);
70 }; 76 };
71 77
72 // StringVar ------------------------------------------------------------------- 78 // StringVar -------------------------------------------------------------------
73 79
74 // Represents a string-based Var. 80 // Represents a string-based Var.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 115
110 private: 116 private:
111 std::string value_; 117 std::string value_;
112 118
113 DISALLOW_COPY_AND_ASSIGN(StringVar); 119 DISALLOW_COPY_AND_ASSIGN(StringVar);
114 }; 120 };
115 121
116 } // namespace ppapi 122 } // namespace ppapi
117 123
118 #endif // PPAPI_SHARED_IMPL_VAR_H_ 124 #endif // PPAPI_SHARED_IMPL_VAR_H_
OLDNEW
« no previous file with comments | « no previous file | ppapi/shared_impl/var_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698