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

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

Issue 116963003: App APIs in Pepper: C++ APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes according to Sam's suggestions. 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_output_traits_dev.h
diff --git a/ppapi/cpp/dev/struct_wrapper_output_traits_dev.h b/ppapi/cpp/dev/struct_wrapper_output_traits_dev.h
new file mode 100644
index 0000000000000000000000000000000000000000..f398c973848da13d115802cc24d2c49372a748cb
--- /dev/null
+++ b/ppapi/cpp/dev/struct_wrapper_output_traits_dev.h
@@ -0,0 +1,37 @@
+// 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_OUTPUT_TRAITS_DEV_
+#define PPAPI_CPP_DEV_STRUCT_WRAPPER_OUTPUT_TRAITS_DEV_
+
+namespace pp {
+namespace internal {
+
+// This class is used as the base class for CallbackOutputTraits specialized for
+// C struct wrappers.
+template <typename T>
+struct StructWrapperOutputTraits {
+ typedef typename T::CType* APIArgType;
+ typedef T StorageType;
+
+ // Returns the underlying C struct of |t|, which can be passed to the browser
+ // as an output parameter.
+ static inline APIArgType StorageToAPIArg(StorageType& t) {
+ return t.StartRawUpdate();
+ }
+
+ // For each |t| passed into StorageToAPIArg(), this method must be called
+ // exactly once in order to match StartRawUpdate() and EndRawUpdate().
+ static inline T& StorageToPluginArg(StorageType& t) {
+ t.EndRawUpdate();
+ return t;
+ }
+
+ static inline void Initialize(StorageType* /* t */) {}
+};
+
+} // namespace internal
+} // namespace pp
+
+#endif // PPAPI_CPP_DEV_STRUCT_WRAPPER_OUTPUT_TRAITS_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