| 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "ppapi/c/pp_completion_callback.h" | 7 #include "ppapi/c/pp_completion_callback.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/shared_impl/callback_tracker.h" | 9 #include "ppapi/shared_impl/callback_tracker.h" |
| 10 #include "ppapi/shared_impl/resource.h" | 10 #include "ppapi/shared_impl/resource.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 void TestCallback(void* user_data, int32_t result) { | 48 void TestCallback(void* user_data, int32_t result) { |
| 49 CallbackRunInfo* info = reinterpret_cast<CallbackRunInfo*>(user_data); | 49 CallbackRunInfo* info = reinterpret_cast<CallbackRunInfo*>(user_data); |
| 50 info->run_count++; | 50 info->run_count++; |
| 51 if (info->run_count == 1) | 51 if (info->run_count == 1) |
| 52 info->result = result; | 52 info->result = result; |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace | 55 } // namespace |
| 56 | 56 |
| 57 // BlockingCallbackTest -------------------------------------------------------- |
| 58 |
| 59 // Tests that blocking callbacks work properly. |
| 60 /* |
| 61 TEST_F(TrackedCallbackTest, blah) { |
| 62 } |
| 63 */ |
| 64 |
| 57 // CallbackShutdownTest -------------------------------------------------------- | 65 // CallbackShutdownTest -------------------------------------------------------- |
| 58 | 66 |
| 59 namespace { | 67 namespace { |
| 60 | 68 |
| 61 class CallbackShutdownTest : public TrackedCallbackTest { | 69 class CallbackShutdownTest : public TrackedCallbackTest { |
| 62 public: | 70 public: |
| 63 CallbackShutdownTest() {} | 71 CallbackShutdownTest() {} |
| 64 | 72 |
| 65 // Cases: | 73 // Cases: |
| 66 // (1) A callback which is run (so shouldn't be aborted on shutdown). | 74 // (1) A callback which is run (so shouldn't be aborted on shutdown). |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // Unref it again and do the same. | 266 // Unref it again and do the same. |
| 259 resource_tracker->ReleaseResource(new_resource_id); | 267 resource_tracker->ReleaseResource(new_resource_id); |
| 260 MessageLoop::current()->RunAllPending(); | 268 MessageLoop::current()->RunAllPending(); |
| 261 resource->CheckFinalState(); | 269 resource->CheckFinalState(); |
| 262 | 270 |
| 263 // This shouldn't be needed, but make sure there are no stranded tasks. | 271 // This shouldn't be needed, but make sure there are no stranded tasks. |
| 264 MessageLoop::current()->RunAllPending(); | 272 MessageLoop::current()->RunAllPending(); |
| 265 } | 273 } |
| 266 | 274 |
| 267 } // namespace ppapi | 275 } // namespace ppapi |
| OLD | NEW |