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

Unified Diff: ppapi/tests/test_utils.cc

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export AssertLockHeld Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/tests/test_url_loader.cc ('k') | ppapi/thunk/enter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_utils.cc
diff --git a/ppapi/tests/test_utils.cc b/ppapi/tests/test_utils.cc
index 7405e93da34182a24e713ce9b13a827e2abe21d2..cae96dc74c75e201d704ca0072808d33913687eb 100644
--- a/ppapi/tests/test_utils.cc
+++ b/ppapi/tests/test_utils.cc
@@ -97,6 +97,7 @@ TestCompletionCallback::TestCompletionCallback(PP_Instance instance)
// what the tests currently expect.
callback_type_(PP_OPTIONAL),
post_quit_task_(false),
+ run_count_(0), // TODO(dmichael): Remove when all tests are updated.
instance_(instance) {
}
@@ -172,10 +173,10 @@ void TestCompletionCallback::WaitForAbortResult(int32_t result) {
final_result));
return;
}
- } else if (result != PP_OK) {
+ } else if (result < PP_OK) {
errors_.assign(
- ReportError("TestCompletionCallback: Expected PP_ERROR_ABORTED or"
- "PP_OK. Ran synchronously.",
+ ReportError("TestCompletionCallback: Expected PP_ERROR_ABORTED or "
+ "non-error response. Ran synchronously.",
result));
return;
}
@@ -198,6 +199,7 @@ void TestCompletionCallback::Reset() {
result_ = PP_OK_COMPLETIONPENDING;
have_result_ = false;
post_quit_task_ = false;
+ run_count_ = 0; // TODO(dmichael): Remove when all tests are updated.
errors_.clear();
}
@@ -205,9 +207,12 @@ void TestCompletionCallback::Reset() {
void TestCompletionCallback::Handler(void* user_data, int32_t result) {
TestCompletionCallback* callback =
static_cast<TestCompletionCallback*>(user_data);
+ // If this check fails, it means that the callback was invoked twice or that
+ // the PPAPI call completed synchronously, but also ran the callback.
PP_DCHECK(!callback->have_result_);
callback->result_ = result;
callback->have_result_ = true;
+ callback->run_count_++; // TODO(dmichael): Remove when all tests are updated.
if (callback->post_quit_task_) {
callback->post_quit_task_ = false;
GetTestingInterface()->QuitMessageLoop(callback->instance_);
« no previous file with comments | « ppapi/tests/test_url_loader.cc ('k') | ppapi/thunk/enter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698