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

Unified Diff: ppapi/native_client/src/shared/ppapi_proxy/array_buffer_proxy_var.h

Issue 9022021: Proxy PPB_ArrayBuffer_Dev, make them work over Messaging (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comment. Created 8 years, 12 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
« no previous file with comments | « chrome/test/ui/ppapi_uitest.cc ('k') | ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/native_client/src/shared/ppapi_proxy/array_buffer_proxy_var.h
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/array_buffer_proxy_var.h b/ppapi/native_client/src/shared/ppapi_proxy/array_buffer_proxy_var.h
new file mode 100644
index 0000000000000000000000000000000000000000..fe0849d87f50d34bf9d8cfe391f1994baab1f35c
--- /dev/null
+++ b/ppapi/native_client/src/shared/ppapi_proxy/array_buffer_proxy_var.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2011 The Chromium 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_ARRAY_BUFFER_PROXY_VAR_H_
+#define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_ARRAY_BUFFER_PROXY_VAR_H_
+
+#include "native_client/src/include/nacl_memory.h"
+#include "native_client/src/shared/ppapi_proxy/proxy_var.h"
+
+#include <vector>
+
+namespace ppapi_proxy {
+
+// Subclass of ProxyVar that handles ArrayBuffer objects.
+class ArrayBufferProxyVar : public ProxyVar {
+ public:
+ explicit ArrayBufferProxyVar(uint32_t size_in_bytes)
+ : ProxyVar(PP_VARTYPE_ARRAY_BUFFER), buffer_(size_in_bytes, 0) {}
+
+ void* buffer() { return buffer_.empty() ? NULL : &buffer_[0]; }
+ uint32_t buffer_length() const { return buffer_.size(); }
+
+ // 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<ArrayBufferProxyVar> CastFromProxyVar(
+ SharedProxyVar proxy_var) {
+ if (proxy_var == NULL ||
+ proxy_var->pp_var_type() != PP_VARTYPE_ARRAY_BUFFER) {
+ scoped_refptr<ArrayBufferProxyVar> null_ptr;
+ return null_ptr;
+ }
+ return scoped_refptr<ArrayBufferProxyVar>(
+ static_cast<ArrayBufferProxyVar*>(proxy_var.get()));
+ }
+
+ private:
+ std::vector<uint8_t> buffer_;
+};
+
+typedef scoped_refptr<ArrayBufferProxyVar> SharedArrayBufferProxyVar;
+
+} // namespace ppapi_proxy
+
+#endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_ARRAY_BUFFER_PROXY_VAR_H_
« no previous file with comments | « chrome/test/ui/ppapi_uitest.cc ('k') | ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698