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_module.h" | 12 #include "ppapi/c/pp_module.h" |
13 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
| 14 #include "ppapi/shared_impl/ppapi_shared_export.h" |
14 | 15 |
15 namespace ppapi { | 16 namespace ppapi { |
16 | 17 |
17 class NPObjectVar; | 18 class NPObjectVar; |
18 class ProxyObjectVar; | 19 class ProxyObjectVar; |
19 class StringVar; | 20 class StringVar; |
20 | 21 |
21 // Var ------------------------------------------------------------------------- | 22 // Var ------------------------------------------------------------------------- |
22 | 23 |
23 // Represents a non-POD var. This is derived from a resource even though it | 24 // Represents a non-POD var. This is derived from a resource even though it |
24 // isn't a resource from the plugin's perspective. This allows us to re-use | 25 // isn't a resource from the plugin's perspective. This allows us to re-use |
25 // the refcounting and the association with the module from the resource code. | 26 // the refcounting and the association with the module from the resource code. |
26 class Var : public base::RefCounted<Var> { | 27 class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> { |
27 public: | 28 public: |
28 virtual ~Var(); | 29 virtual ~Var(); |
29 | 30 |
30 // Returns a string representing the given var for logging purposes. | 31 // Returns a string representing the given var for logging purposes. |
31 static std::string PPVarToLogString(PP_Var var); | 32 static std::string PPVarToLogString(PP_Var var); |
32 | 33 |
33 virtual StringVar* AsStringVar(); | 34 virtual StringVar* AsStringVar(); |
34 virtual NPObjectVar* AsNPObjectVar(); | 35 virtual NPObjectVar* AsNPObjectVar(); |
35 virtual ProxyObjectVar* AsProxyObjectVar(); | 36 virtual ProxyObjectVar* AsProxyObjectVar(); |
36 | 37 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Represents a string-based Var. | 82 // Represents a string-based Var. |
82 // | 83 // |
83 // Returning a given string as a PP_Var: | 84 // Returning a given string as a PP_Var: |
84 // return StringVar::StringToPPVar(module, my_string); | 85 // return StringVar::StringToPPVar(module, my_string); |
85 // | 86 // |
86 // Converting a PP_Var to a string: | 87 // Converting a PP_Var to a string: |
87 // StringVar* string = StringVar::FromPPVar(var); | 88 // StringVar* string = StringVar::FromPPVar(var); |
88 // if (!string) | 89 // if (!string) |
89 // return false; // Not a string or an invalid var. | 90 // return false; // Not a string or an invalid var. |
90 // DoSomethingWithTheString(string->value()); | 91 // DoSomethingWithTheString(string->value()); |
91 class StringVar : public Var { | 92 class PPAPI_SHARED_EXPORT StringVar : public Var { |
92 public: | 93 public: |
93 StringVar(PP_Module module, const std::string& str); | 94 StringVar(PP_Module module, const std::string& str); |
94 StringVar(PP_Module module, const char* str, uint32 len); | 95 StringVar(PP_Module module, const char* str, uint32 len); |
95 virtual ~StringVar(); | 96 virtual ~StringVar(); |
96 | 97 |
97 const std::string& value() const { return value_; } | 98 const std::string& value() const { return value_; } |
98 | 99 |
99 // Var override. | 100 // Var override. |
100 virtual StringVar* AsStringVar() OVERRIDE; | 101 virtual StringVar* AsStringVar() OVERRIDE; |
101 virtual PP_Var GetPPVar() OVERRIDE; | 102 virtual PP_Var GetPPVar() OVERRIDE; |
(...skipping 15 matching lines...) Expand all Loading... |
117 | 118 |
118 private: | 119 private: |
119 std::string value_; | 120 std::string value_; |
120 | 121 |
121 DISALLOW_COPY_AND_ASSIGN(StringVar); | 122 DISALLOW_COPY_AND_ASSIGN(StringVar); |
122 }; | 123 }; |
123 | 124 |
124 } // namespace ppapi | 125 } // namespace ppapi |
125 | 126 |
126 #endif // PPAPI_SHARED_IMPL_VAR_H_ | 127 #endif // PPAPI_SHARED_IMPL_VAR_H_ |
OLD | NEW |