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" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "ppapi/c/pp_var.h" | 12 #include "ppapi/c/pp_var.h" |
14 #include "ppapi/shared_impl/ppapi_shared_export.h" | 13 #include "ppapi/shared_impl/ppapi_shared_export.h" |
15 | 14 |
16 namespace ppapi { | 15 namespace ppapi { |
17 | 16 |
18 class ArrayBufferVar; | 17 class ArrayBufferVar; |
19 class NPObjectVar; | 18 class NPObjectVar; |
20 class ProxyObjectVar; | 19 class ProxyObjectVar; |
21 class StringVar; | 20 class StringVar; |
22 class VarTracker; | 21 class VarTracker; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // Returning a given string as a PP_Var: | 84 // Returning a given string as a PP_Var: |
86 // return StringVar::StringToPPVar(my_string); | 85 // return StringVar::StringToPPVar(my_string); |
87 // | 86 // |
88 // Converting a PP_Var to a string: | 87 // Converting a PP_Var to a string: |
89 // StringVar* string = StringVar::FromPPVar(var); | 88 // StringVar* string = StringVar::FromPPVar(var); |
90 // if (!string) | 89 // if (!string) |
91 // return false; // Not a string or an invalid var. | 90 // return false; // Not a string or an invalid var. |
92 // DoSomethingWithTheString(string->value()); | 91 // DoSomethingWithTheString(string->value()); |
93 class PPAPI_SHARED_EXPORT StringVar : public Var { | 92 class PPAPI_SHARED_EXPORT StringVar : public Var { |
94 public: | 93 public: |
95 StringVar(const std::string& str); | 94 explicit StringVar(const std::string& str); |
96 StringVar(const char* str, uint32 len); | 95 StringVar(const char* str, uint32 len); |
97 virtual ~StringVar(); | 96 virtual ~StringVar(); |
98 | 97 |
99 const std::string& value() const { return value_; } | 98 const std::string& value() const { return value_; } |
100 // Return a pointer to the internal string. This allows other objects to | 99 // Return a pointer to the internal string. This allows other objects to |
101 // temporarily store a weak pointer to our internal string. Use with care; the | 100 // temporarily store a weak pointer to our internal string. Use with care; the |
102 // pointer *will* become invalid if this StringVar is removed from the | 101 // pointer *will* become invalid if this StringVar is removed from the |
103 // tracker. (All of this applies to value(), but this one's even easier to use | 102 // tracker. (All of this applies to value(), but this one's even easier to use |
104 // dangerously). | 103 // dangerously). |
105 const std::string* ptr() const { return &value_; } | 104 const std::string* ptr() const { return &value_; } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // return NULL if the PP_Var is not of ArrayBuffer type. | 164 // return NULL if the PP_Var is not of ArrayBuffer type. |
166 static ArrayBufferVar* FromPPVar(PP_Var var); | 165 static ArrayBufferVar* FromPPVar(PP_Var var); |
167 | 166 |
168 private: | 167 private: |
169 DISALLOW_COPY_AND_ASSIGN(ArrayBufferVar); | 168 DISALLOW_COPY_AND_ASSIGN(ArrayBufferVar); |
170 }; | 169 }; |
171 | 170 |
172 } // namespace ppapi | 171 } // namespace ppapi |
173 | 172 |
174 #endif // PPAPI_SHARED_IMPL_VAR_H_ | 173 #endif // PPAPI_SHARED_IMPL_VAR_H_ |
OLD | NEW |