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

Side by Side Diff: ppapi/tests/test_utils.h

Issue 12817009: Add Query() support to FileRef (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits, more callback ref shuffling. Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_TESTS_TEST_UTILS_H_ 5 #ifndef PPAPI_TESTS_TEST_UTILS_H_
6 #define PPAPI_TESTS_TEST_UTILS_H_ 6 #define PPAPI_TESTS_TEST_UTILS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ppapi/c/dev/ppb_testing_dev.h" 10 #include "ppapi/c/dev/ppb_testing_dev.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 TestCompletionCallbackWithOutput(PP_Instance instance, 183 TestCompletionCallbackWithOutput(PP_Instance instance,
184 CallbackType callback_type) : 184 CallbackType callback_type) :
185 TestCompletionCallback(instance, callback_type) { 185 TestCompletionCallback(instance, callback_type) {
186 } 186 }
187 187
188 pp::CompletionCallbackWithOutput<OutputT> GetCallbackWithOutput(); 188 pp::CompletionCallbackWithOutput<OutputT> GetCallbackWithOutput();
189 operator pp::CompletionCallbackWithOutput<OutputT>() { 189 operator pp::CompletionCallbackWithOutput<OutputT>() {
190 return GetCallbackWithOutput(); 190 return GetCallbackWithOutput();
191 } 191 }
192 192
193 const OutputT& output() { return output_storage_.output(); } 193 OutputT output() {
194 return pp::internal::CallbackOutputTraits<OutputT>::StorageToPluginArg(
195 output_storage_);
196 }
194 197
195 typename pp::CompletionCallbackWithOutput<OutputT>::OutputStorageType 198 typename pp::CompletionCallbackWithOutput<OutputT>::OutputStorageType
196 output_storage_; 199 output_storage_;
197 }; 200 };
198 201
199 template <typename OutputT> 202 template <typename OutputT>
200 pp::CompletionCallbackWithOutput<OutputT> 203 pp::CompletionCallbackWithOutput<OutputT>
201 TestCompletionCallbackWithOutput<OutputT>::GetCallbackWithOutput() { 204 TestCompletionCallbackWithOutput<OutputT>::GetCallbackWithOutput() {
202 Reset(); 205 Reset();
203 if (callback_type_ == PP_BLOCKING) { 206 if (callback_type_ == PP_BLOCKING) {
204 pp::CompletionCallbackWithOutput<OutputT> cc( 207 pp::CompletionCallbackWithOutput<OutputT> cc(&output_storage_);
205 &TestCompletionCallback::Handler,
206 this,
207 &output_storage_);
208 return cc; 208 return cc;
209 } 209 }
210 210
211 target_loop_ = pp::MessageLoop::GetCurrent(); 211 target_loop_ = pp::MessageLoop::GetCurrent();
212 pp::CompletionCallbackWithOutput<OutputT> cc( 212 pp::CompletionCallbackWithOutput<OutputT> cc(
213 &TestCompletionCallback::Handler, 213 &TestCompletionCallback::Handler,
214 this, 214 this,
215 &output_storage_); 215 &output_storage_);
216 if (callback_type_ == PP_OPTIONAL) 216 if (callback_type_ == PP_OPTIONAL)
217 cc.set_flags(PP_COMPLETIONCALLBACK_FLAG_OPTIONAL); 217 cc.set_flags(PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
218 return cc; 218 return cc;
219 } 219 }
220 220
221 221
222 // Verifies that the callback didn't record any errors. If the callback is run 222 // Verifies that the callback didn't record any errors. If the callback is run
223 // in an unexpected way (e.g., if it's invoked asynchronously when the call 223 // in an unexpected way (e.g., if it's invoked asynchronously when the call
224 // should have blocked), this returns an appropriate error string. 224 // should have blocked), this returns an appropriate error string.
225 #define CHECK_CALLBACK_BEHAVIOR(callback) \ 225 #define CHECK_CALLBACK_BEHAVIOR(callback) \
226 do { \ 226 do { \
227 if ((callback).failed()) \ 227 if ((callback).failed()) \
228 return (callback).errors(); \ 228 return MakeFailureMessage(__FILE__, __LINE__, \
229 (callback).errors().c_str()); \
229 } while (false) 230 } while (false)
230 231
231 /* 232 /*
232 * A set of macros to use for platform detection. These were largely copied 233 * A set of macros to use for platform detection. These were largely copied
233 * from chromium's build_config.h. 234 * from chromium's build_config.h.
234 */ 235 */
235 #if defined(__APPLE__) 236 #if defined(__APPLE__)
236 #define PPAPI_OS_MACOSX 1 237 #define PPAPI_OS_MACOSX 1
237 #elif defined(ANDROID) 238 #elif defined(ANDROID)
238 #define PPAPI_OS_ANDROID 1 239 #define PPAPI_OS_ANDROID 1
(...skipping 13 matching lines...) Expand all
252 #error Please add support for your platform in ppapi/tests/test_utils.h 253 #error Please add support for your platform in ppapi/tests/test_utils.h
253 #endif 254 #endif
254 255
255 /* These are used to determine POSIX-like implementations vs Windows. */ 256 /* These are used to determine POSIX-like implementations vs Windows. */
256 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ 257 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
257 defined(__OpenBSD__) || defined(__sun) || defined(__native_client__) 258 defined(__OpenBSD__) || defined(__sun) || defined(__native_client__)
258 #define PPAPI_POSIX 1 259 #define PPAPI_POSIX 1
259 #endif 260 #endif
260 261
261 #endif // PPAPI_TESTS_TEST_UTILS_H_ 262 #endif // PPAPI_TESTS_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698