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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/native_client/src/shared/ppapi_proxy/string_proxy_var.h
===================================================================
--- ppapi/native_client/src/shared/ppapi_proxy/string_proxy_var.h (revision 0)
+++ ppapi/native_client/src/shared/ppapi_proxy/string_proxy_var.h (revision 0)
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 The Native Client Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_STRING_PROXY_VAR_H_
+#define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_STRING_PROXY_VAR_H_
+
+#include "native_client/src/include/nacl_memory.h"
+#include "native_client/src/shared/ppapi_proxy/proxy_var.h"
+
+#include <string>
+
+namespace ppapi_proxy {
+
+// Subclass of ProxyVar that handles string objects.
+class StringProxyVar : public ProxyVar {
+ public:
+ explicit StringProxyVar(const std::string& contents)
+ : ProxyVar(PP_VARTYPE_STRING), contents_(contents) {}
+
+ StringProxyVar(const char* data, size_t len)
+ : ProxyVar(PP_VARTYPE_STRING), contents_(data, len) {}
+
+ const std::string& contents() const { return contents_; }
+
+ // Convenience function to do type checking and down-casting. This returns a
+ // scoped_refptr<>, so you don't have to down-cast the raw pointer.
+ static scoped_refptr<StringProxyVar> CastFromProxyVar(
+ SharedProxyVar proxy_var) {
+ if (proxy_var == NULL || proxy_var->pp_var_type() != PP_VARTYPE_STRING) {
+ scoped_refptr<StringProxyVar> string_var;
+ return string_var;
+ }
+ return scoped_refptr<StringProxyVar>(
+ static_cast<StringProxyVar*>(proxy_var.get()));
+ }
+
+ private:
+ std::string contents_;
+
+ StringProxyVar(); // Not implemented, do not use.
+};
+
+typedef scoped_refptr<StringProxyVar> SharedStringProxyVar;
+
+} // namespace ppapi_proxy
+
+#endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_STRING_PROXY_VAR_H_

Powered by Google App Engine
This is Rietveld 408576698