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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium 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 PPAPI_CPP_DEV_STRUCT_WRAPPER_BASE_DEV_
6 #define PPAPI_CPP_DEV_STRUCT_WRAPPER_BASE_DEV_
7
8 #include "ppapi/c/dev/pp_optional_structs_dev.h"
9 #include "ppapi/cpp/dev/array_dev.h"
10 #include "ppapi/cpp/dev/may_own_ptr_dev.h"
11 #include "ppapi/cpp/logging.h"
12 #include "ppapi/cpp/var.h"
13
14 namespace pp {
15 namespace internal {
16
17 // The only purpose of this class is for CallbackOutputTraits to determined
18 // whether a class is a struct wrapper.
19 class StructWrapperIdentifier {
20 };
21
22 template <class Type, class ArrayType = void>
23 class StructWrapperBase : public StructWrapperIdentifier {
24 public:
25 typedef Type CType;
26 typedef ArrayType CArrayType;
27
28 typedef CType* COutputType;
29 typedef const CType* CInputType;
30
31 StructWrapperBase() {
32 }
33
34 // For struct / array members.
35 // It doesn't take ownership of |storage|, therefore |storage| must live
36 // longer than this object.
37 StructWrapperBase(CType* storage, NotOwned) : storage_(storage, NOT_OWNED) {
38 }
39
40 virtual ~StructWrapperBase() {
41 }
42
43 // For input parameters to call PPB_* functions.
44 const CType* ToStruct() const {
45 return storage_.get();
46 }
47
48 // For output parameters to call PPB_* functions. The returned pointer is
49 // still owned by this object. And after it is used, EndRawUpdate() must be
50 // called.
51 CType* StartRawUpdate() {
52 NotifyStartRawUpdate();
53 return storage_.get();
54 }
55
56 void EndRawUpdate() {
57 NotifyEndRawUpdate();
58 }
59
60 protected:
61 virtual void NotifyStartRawUpdate() = 0;
62 virtual void NotifyEndRawUpdate() = 0;
63
64 MayOwnPtr<CType> storage_;
65
66 private:
67 // Disallow copy and assign.
68 StructWrapperBase(const StructWrapperBase<CType, CArrayType>& other);
69 StructWrapperBase<CType, CArrayType>& operator=(
70 const StructWrapperBase<CType, CArrayType>& other);
71 };
72
73 } // namespace internal
74 } // namespace pp
75
76 #endif // PPAPI_CPP_DEV_STRUCT_WRAPPER_BASE_DEV_
OLDNEW
« 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