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

Unified Diff: ppapi/cpp/dev/struct_wrapper_base_dev.h

Issue 60173003: Draft: apps APIs in Pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | « ppapi/cpp/dev/string_wrapper_dev.cc ('k') | ppapi/cpp/dev/to_c_type_converter_dev.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/dev/struct_wrapper_base_dev.h
diff --git a/ppapi/cpp/dev/struct_wrapper_base_dev.h b/ppapi/cpp/dev/struct_wrapper_base_dev.h
new file mode 100644
index 0000000000000000000000000000000000000000..2a7809a421fac9152d93d3210585504e3e4ca624
--- /dev/null
+++ b/ppapi/cpp/dev/struct_wrapper_base_dev.h
@@ -0,0 +1,76 @@
+// Copyright (c) 2013 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 PPAPI_CPP_DEV_STRUCT_WRAPPER_BASE_DEV_
+#define PPAPI_CPP_DEV_STRUCT_WRAPPER_BASE_DEV_
+
+#include "ppapi/c/dev/pp_optional_structs_dev.h"
+#include "ppapi/cpp/dev/array_dev.h"
+#include "ppapi/cpp/dev/may_own_ptr_dev.h"
+#include "ppapi/cpp/logging.h"
+#include "ppapi/cpp/var.h"
+
+namespace pp {
+namespace internal {
+
+// The only purpose of this class is for CallbackOutputTraits to determined
+// whether a class is a struct wrapper.
+class StructWrapperIdentifier {
+};
+
+template <class Type, class ArrayType = void>
+class StructWrapperBase : public StructWrapperIdentifier {
+ public:
+ typedef Type CType;
+ typedef ArrayType CArrayType;
+
+ typedef CType* COutputType;
+ typedef const CType* CInputType;
+
+ StructWrapperBase() {
+ }
+
+ // For struct / array members.
+ // It doesn't take ownership of |storage|, therefore |storage| must live
+ // longer than this object.
+ StructWrapperBase(CType* storage, NotOwned) : storage_(storage, NOT_OWNED) {
+ }
+
+ virtual ~StructWrapperBase() {
+ }
+
+ // For input parameters to call PPB_* functions.
+ const CType* ToStruct() const {
+ return storage_.get();
+ }
+
+ // For output parameters to call PPB_* functions. The returned pointer is
+ // still owned by this object. And after it is used, EndRawUpdate() must be
+ // called.
+ CType* StartRawUpdate() {
+ NotifyStartRawUpdate();
+ return storage_.get();
+ }
+
+ void EndRawUpdate() {
+ NotifyEndRawUpdate();
+ }
+
+ protected:
+ virtual void NotifyStartRawUpdate() = 0;
+ virtual void NotifyEndRawUpdate() = 0;
+
+ MayOwnPtr<CType> storage_;
+
+ private:
+ // Disallow copy and assign.
+ StructWrapperBase(const StructWrapperBase<CType, CArrayType>& other);
+ StructWrapperBase<CType, CArrayType>& operator=(
+ const StructWrapperBase<CType, CArrayType>& other);
+};
+
+} // namespace internal
+} // namespace pp
+
+#endif // PPAPI_CPP_DEV_STRUCT_WRAPPER_BASE_DEV_
« no previous file with comments | « ppapi/cpp/dev/string_wrapper_dev.cc ('k') | ppapi/cpp/dev/to_c_type_converter_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698