summaryrefslogtreecommitdiffstats
path: root/ppapi/tests/test_utils.cc
diff options
context:
space:
mode:
authortoyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-29 04:41:42 +0000
committertoyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-29 04:41:42 +0000
commitcc2386c4e2a249c1dc8f55890c8f3c16a6a9d346 (patch)
tree880f8a6ff0233937f9225f3e387f6e2de5c894a8 /ppapi/tests/test_utils.cc
parentd1a043626caa76ada7af34f21ac57a2dc308a92f (diff)
downloadchromium_src-cc2386c4e2a249c1dc8f55890c8f3c16a6a9d346.zip
chromium_src-cc2386c4e2a249c1dc8f55890c8f3c16a6a9d346.tar.gz
chromium_src-cc2386c4e2a249c1dc8f55890c8f3c16a6a9d346.tar.bz2
Allow to release WebSocket resource in completion callbacks invoked by Close().
- Protect |this| around invoking plugin callbacks - Add unit tests to check the case BUG= TEST=browser_tests Review URL: https://chromiumcodereview.appspot.com/10661026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144872 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/test_utils.cc')
-rw-r--r--ppapi/tests/test_utils.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/ppapi/tests/test_utils.cc b/ppapi/tests/test_utils.cc
index cae96dc..b1744dc 100644
--- a/ppapi/tests/test_utils.cc
+++ b/ppapi/tests/test_utils.cc
@@ -98,7 +98,8 @@ TestCompletionCallback::TestCompletionCallback(PP_Instance instance)
callback_type_(PP_OPTIONAL),
post_quit_task_(false),
run_count_(0), // TODO(dmichael): Remove when all tests are updated.
- instance_(instance) {
+ instance_(instance),
+ delegate_(NULL) {
}
TestCompletionCallback::TestCompletionCallback(PP_Instance instance,
@@ -108,7 +109,8 @@ TestCompletionCallback::TestCompletionCallback(PP_Instance instance,
result_(PP_OK_COMPLETIONPENDING),
callback_type_(force_async ? PP_REQUIRED : PP_OPTIONAL),
post_quit_task_(false),
- instance_(instance) {
+ instance_(instance),
+ delegate_(NULL) {
}
TestCompletionCallback::TestCompletionCallback(PP_Instance instance,
@@ -118,7 +120,8 @@ TestCompletionCallback::TestCompletionCallback(PP_Instance instance,
result_(PP_OK_COMPLETIONPENDING),
callback_type_(callback_type),
post_quit_task_(false),
- instance_(instance) {
+ instance_(instance),
+ delegate_(NULL) {
}
int32_t TestCompletionCallback::WaitForResult() {
@@ -200,6 +203,7 @@ void TestCompletionCallback::Reset() {
have_result_ = false;
post_quit_task_ = false;
run_count_ = 0; // TODO(dmichael): Remove when all tests are updated.
+ delegate_ = NULL;
errors_.clear();
}
@@ -213,6 +217,8 @@ void TestCompletionCallback::Handler(void* user_data, int32_t result) {
callback->result_ = result;
callback->have_result_ = true;
callback->run_count_++; // TODO(dmichael): Remove when all tests are updated.
+ if (callback->delegate_)
+ callback->delegate_->OnCallback(user_data, result);
if (callback->post_quit_task_) {
callback->post_quit_task_ = false;
GetTestingInterface()->QuitMessageLoop(callback->instance_);