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

Side by Side Diff: ppapi/thunk/enter.h

Issue 7006022: Revert 87415 - Convert more interfaces to the new thunk system. This goes up to and including (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/shared_impl/tracker_base.h ('k') | ppapi/thunk/ppb_directory_reader_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PPAPI_THUNK_ENTER_H_ 5 #ifndef PPAPI_THUNK_ENTER_H_
6 #define PPAPI_THUNK_ENTER_H_ 6 #define PPAPI_THUNK_ENTER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "ppapi/c/pp_resource.h" 9 #include "ppapi/c/pp_resource.h"
10 #include "ppapi/proxy/interface_id.h" 10 #include "ppapi/proxy/interface_id.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 instance, FunctionsT::interface_id); 45 instance, FunctionsT::interface_id);
46 if (base) 46 if (base)
47 functions_ = base->GetAs<FunctionsT>(); 47 functions_ = base->GetAs<FunctionsT>();
48 // TODO(brettw) check error and if report_error is set, do something. 48 // TODO(brettw) check error and if report_error is set, do something.
49 } 49 }
50 ~EnterFunction() {} 50 ~EnterFunction() {}
51 51
52 bool succeeded() const { return !!functions_; } 52 bool succeeded() const { return !!functions_; }
53 bool failed() const { return !functions_; } 53 bool failed() const { return !functions_; }
54 54
55 PP_Instance instance() const { return instance_; }
56 FunctionsT* functions() { return functions_; } 55 FunctionsT* functions() { return functions_; }
57 56
58 private: 57 private:
59 PP_Instance instance_;
60 FunctionsT* functions_; 58 FunctionsT* functions_;
61 59
62 DISALLOW_COPY_AND_ASSIGN(EnterFunction); 60 DISALLOW_COPY_AND_ASSIGN(EnterFunction);
63 }; 61 };
64 62
65 // Like EnterResource but assumes the lock is already held. 63 // Like EnterResource but assumes the lock is already held.
66 // TODO(brettw) actually implement locks, this is just a placeholder for now. 64 // TODO(brettw) actually implement locks, this is just a placeholder for now.
67 template<typename FunctionsT> 65 template<typename FunctionsT>
68 class EnterFunctionNoLock : public EnterFunction<FunctionsT> { 66 class EnterFunctionNoLock : public EnterFunction<FunctionsT> {
69 public: 67 public:
70 EnterFunctionNoLock(PP_Instance instance, bool report_error) 68 EnterFunctionNoLock(PP_Instance instance, bool report_error)
71 : EnterFunction<FunctionsT>(instance, report_error) { 69 : EnterFunction<FunctionsT>(instance, report_error) {
72 // TODO(brettw) assert the lock is held. 70 // TODO(brettw) assert the lock is held.
73 } 71 }
74 }; 72 };
75 73
76 // Used when a caller has a resource, and wants to do EnterFunction for the
77 // instance corresponding to that resource.
78 template<typename FunctionsT>
79 class EnterFunctionGivenResource : public EnterFunction<FunctionsT> {
80 public:
81 EnterFunctionGivenResource(PP_Resource resource, bool report_error)
82 : EnterFunction<FunctionsT>(
83 TrackerBase::Get()->GetInstanceForResource(resource),
84 report_error) {
85 }
86 };
87
88 // EnterResource ---------------------------------------------------------------
89
90 template<typename ResourceT> 74 template<typename ResourceT>
91 class EnterResource { 75 class EnterResource {
92 public: 76 public:
93 EnterResource(PP_Resource resource, bool report_error) 77 EnterResource(PP_Resource resource, bool report_error)
94 : object_(NULL) { 78 : object_(NULL) {
95 ResourceObjectBase* base = TrackerBase::Get()->GetResourceAPI(resource); 79 ResourceObjectBase* base = TrackerBase::Get()->GetResourceAPI(resource);
96 if (base) 80 if (base)
97 object_ = base->GetAs<ResourceT>(); 81 object_ = base->GetAs<ResourceT>();
98 // TODO(brettw) check error and if report_error is set, do something. 82 // TODO(brettw) check error and if report_error is set, do something.
99 } 83 }
(...skipping 18 matching lines...) Expand all
118 EnterResourceNoLock(PP_Resource resource, bool report_error) 102 EnterResourceNoLock(PP_Resource resource, bool report_error)
119 : EnterResource<ResourceT>(resource, report_error) { 103 : EnterResource<ResourceT>(resource, report_error) {
120 // TODO(brettw) assert the lock is held. 104 // TODO(brettw) assert the lock is held.
121 } 105 }
122 }; 106 };
123 107
124 } // namespace thunk 108 } // namespace thunk
125 } // namespace ppapi 109 } // namespace ppapi
126 110
127 #endif // PPAPI_THUNK_ENTER_H_ 111 #endif // PPAPI_THUNK_ENTER_H_
OLDNEW
« no previous file with comments | « ppapi/shared_impl/tracker_base.h ('k') | ppapi/thunk/ppb_directory_reader_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698