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

Side by Side Diff: ppapi/native_client/src/shared/ppapi_proxy/string_proxy_var.h

Issue 7740013: Cloning a bunch of stuff from the native_client repository at r6528 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_STRING_PROXY_VAR_H_
6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_STRING_PROXY_VAR_H_
7
8 #include "native_client/src/include/nacl_memory.h"
9 #include "native_client/src/shared/ppapi_proxy/proxy_var.h"
10
11 #include <string>
12
13 namespace ppapi_proxy {
14
15 // Subclass of ProxyVar that handles string objects.
16 class StringProxyVar : public ProxyVar {
17 public:
18 explicit StringProxyVar(const std::string& contents)
19 : ProxyVar(PP_VARTYPE_STRING), contents_(contents) {}
20
21 StringProxyVar(const char* data, size_t len)
22 : ProxyVar(PP_VARTYPE_STRING), contents_(data, len) {}
23
24 const std::string& contents() const { return contents_; }
25
26 // Convenience function to do type checking and down-casting. This returns a
27 // scoped_refptr<>, so you don't have to down-cast the raw pointer.
28 static scoped_refptr<StringProxyVar> CastFromProxyVar(
29 SharedProxyVar proxy_var) {
30 if (proxy_var == NULL || proxy_var->pp_var_type() != PP_VARTYPE_STRING) {
31 scoped_refptr<StringProxyVar> string_var;
32 return string_var;
33 }
34 return scoped_refptr<StringProxyVar>(
35 static_cast<StringProxyVar*>(proxy_var.get()));
36 }
37
38 private:
39 std::string contents_;
40
41 StringProxyVar(); // Not implemented, do not use.
42 };
43
44 typedef scoped_refptr<StringProxyVar> SharedStringProxyVar;
45
46 } // namespace ppapi_proxy
47
48 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_STRING_PROXY_VAR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698