OLD | NEW |
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 #include "ppapi/tests/test_utils.h" | 5 #include "ppapi/tests/test_utils.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #if defined(_MSC_VER) | 9 #if defined(_MSC_VER) |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 CallbackType callback_type) | 143 CallbackType callback_type) |
144 : wait_for_result_called_(false), | 144 : wait_for_result_called_(false), |
145 have_result_(false), | 145 have_result_(false), |
146 result_(PP_OK_COMPLETIONPENDING), | 146 result_(PP_OK_COMPLETIONPENDING), |
147 callback_type_(callback_type), | 147 callback_type_(callback_type), |
148 post_quit_task_(false), | 148 post_quit_task_(false), |
149 instance_(instance), | 149 instance_(instance), |
150 delegate_(NULL) { | 150 delegate_(NULL) { |
151 } | 151 } |
152 | 152 |
153 int32_t TestCompletionCallback::WaitForResult() { | |
154 PP_DCHECK(!wait_for_result_called_); | |
155 wait_for_result_called_ = true; | |
156 errors_.clear(); | |
157 if (!have_result_) { | |
158 post_quit_task_ = true; | |
159 RunMessageLoop(); | |
160 } | |
161 return result_; | |
162 } | |
163 | |
164 void TestCompletionCallback::WaitForResult(int32_t result) { | 153 void TestCompletionCallback::WaitForResult(int32_t result) { |
165 PP_DCHECK(!wait_for_result_called_); | 154 PP_DCHECK(!wait_for_result_called_); |
166 wait_for_result_called_ = true; | 155 wait_for_result_called_ = true; |
167 errors_.clear(); | 156 errors_.clear(); |
168 if (result == PP_OK_COMPLETIONPENDING) { | 157 if (result == PP_OK_COMPLETIONPENDING) { |
169 if (!have_result_) { | 158 if (!have_result_) { |
170 post_quit_task_ = true; | 159 post_quit_task_ = true; |
171 RunMessageLoop(); | 160 RunMessageLoop(); |
172 } | 161 } |
173 if (callback_type_ == PP_BLOCKING) { | 162 if (callback_type_ == PP_BLOCKING) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 pp::MessageLoop loop(pp::MessageLoop::GetCurrent()); | 261 pp::MessageLoop loop(pp::MessageLoop::GetCurrent()); |
273 // If we don't have a message loop, we're probably running in process, where | 262 // If we don't have a message loop, we're probably running in process, where |
274 // PPB_MessageLoop is not supported. Just use the Testing message loop. | 263 // PPB_MessageLoop is not supported. Just use the Testing message loop. |
275 if (loop.is_null() || loop == pp::MessageLoop::GetForMainThread()) { | 264 if (loop.is_null() || loop == pp::MessageLoop::GetForMainThread()) { |
276 GetTestingInterface()->QuitMessageLoop(instance_); | 265 GetTestingInterface()->QuitMessageLoop(instance_); |
277 } else { | 266 } else { |
278 const bool should_quit = false; | 267 const bool should_quit = false; |
279 loop.PostQuit(should_quit); | 268 loop.PostQuit(should_quit); |
280 } | 269 } |
281 } | 270 } |
OLD | NEW |