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

Side by Side Diff: ppapi/proxy/enter_proxy.h

Issue 7740038: Use macros to define pepper interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review Created 9 years, 3 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
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_PROXY_ENTER_PROXY_H_ 5 #ifndef PPAPI_PROXY_ENTER_PROXY_H_
6 #define PPAPI_PROXY_ENTER_PROXY_H_ 6 #define PPAPI_PROXY_ENTER_PROXY_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ppapi/cpp/completion_callback.h" 9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/proxy/host_dispatcher.h" 10 #include "ppapi/proxy/host_dispatcher.h"
11 #include "ppapi/proxy/plugin_dispatcher.h" 11 #include "ppapi/proxy/plugin_dispatcher.h"
12 #include "ppapi/proxy/plugin_resource_tracker.h" 12 #include "ppapi/proxy/plugin_resource_tracker.h"
13 #include "ppapi/thunk/enter.h" 13 #include "ppapi/thunk/enter.h"
14 14
15 namespace ppapi { 15 namespace ppapi {
16
17 namespace thunk {
18 class ResourceCreationAPI;
19 }
20
16 namespace proxy { 21 namespace proxy {
17 22
18 // Wrapper around EnterResourceNoLock that takes a host resource. This is used 23 // Wrapper around EnterResourceNoLock that takes a host resource. This is used
19 // when handling messages in the plugin from the host and we need to convert to 24 // when handling messages in the plugin from the host and we need to convert to
20 // an object in the plugin side corresponding to that. 25 // an object in the plugin side corresponding to that.
21 // 26 //
22 // This never locks since we assume the host Resource is coming from IPC, and 27 // This never locks since we assume the host Resource is coming from IPC, and
23 // never logs errors since we assume the host is doing reasonable things. 28 // never logs errors since we assume the host is doing reasonable things.
24 template<typename ResourceT> 29 template<typename ResourceT>
25 class EnterPluginFromHostResource 30 class EnterPluginFromHostResource
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 CallbackFactory& factory, 113 CallbackFactory& factory,
109 Method method, 114 Method method,
110 const A& a) 115 const A& a)
111 : EnterHostFromHostResource<ResourceT>(host_resource), 116 : EnterHostFromHostResource<ResourceT>(host_resource),
112 needs_running_(true), 117 needs_running_(true),
113 callback_(factory.NewOptionalCallback(method, a)) { 118 callback_(factory.NewOptionalCallback(method, a)) {
114 if (this->failed()) 119 if (this->failed())
115 RunCallback(PP_ERROR_BADRESOURCE); 120 RunCallback(PP_ERROR_BADRESOURCE);
116 } 121 }
117 122
123 // For callbacks that take two extra parameters as a closure.
124 template<class CallbackFactory, typename Method, typename A, typename B>
125 EnterHostFromHostResourceForceCallback(
126 const HostResource& host_resource,
127 CallbackFactory& factory,
128 Method method,
129 const A& a,
130 const B& b)
131 : EnterHostFromHostResource<ResourceT>(host_resource),
132 needs_running_(true),
133 callback_(factory.NewOptionalCallback(method, a, b)) {
134 if (this->failed())
135 RunCallback(PP_ERROR_BADRESOURCE);
136 }
137
118 ~EnterHostFromHostResourceForceCallback() { 138 ~EnterHostFromHostResourceForceCallback() {
119 if (needs_running_) { 139 if (needs_running_) {
120 NOTREACHED() << "Should always call SetResult except in the " 140 NOTREACHED() << "Should always call SetResult except in the "
121 "initialization failed case."; 141 "initialization failed case.";
122 RunCallback(PP_ERROR_FAILED); 142 RunCallback(PP_ERROR_FAILED);
123 } 143 }
124 } 144 }
125 145
126 void SetResult(int32_t result) { 146 void SetResult(int32_t result) {
127 DCHECK(needs_running_) << "Don't call SetResult when there already is one."; 147 DCHECK(needs_running_) << "Don't call SetResult when there already is one.";
(...skipping 14 matching lines...) Expand all
142 } 162 }
143 163
144 bool needs_running_; 164 bool needs_running_;
145 pp::CompletionCallback callback_; 165 pp::CompletionCallback callback_;
146 }; 166 };
147 167
148 } // namespace proxy 168 } // namespace proxy
149 } // namespace ppapi 169 } // namespace ppapi
150 170
151 #endif // PPAPI_PROXY_ENTER_PROXY_H_ 171 #endif // PPAPI_PROXY_ENTER_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698