OLD | NEW |
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 Loading... |
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 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 112 |
110 private: | 113 private: |
111 std::string value_; | 114 std::string value_; |
112 | 115 |
113 DISALLOW_COPY_AND_ASSIGN(StringVar); | 116 DISALLOW_COPY_AND_ASSIGN(StringVar); |
114 }; | 117 }; |
115 | 118 |
116 } // namespace ppapi | 119 } // namespace ppapi |
117 | 120 |
118 #endif // PPAPI_SHARED_IMPL_VAR_H_ | 121 #endif // PPAPI_SHARED_IMPL_VAR_H_ |
OLD | NEW |