| 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/message_loop.h" | 6 #include "base/message_loop/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 24 matching lines...) Expand all Loading... |
| 35 base::MessageLoop message_loop_; | 35 base::MessageLoop message_loop_; |
| 36 TestGlobals globals_; | 36 TestGlobals globals_; |
| 37 PP_Instance pp_instance_; | 37 PP_Instance pp_instance_; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 struct CallbackRunInfo { | 40 struct CallbackRunInfo { |
| 41 // All valid results (PP_OK, PP_ERROR_...) are nonpositive. | 41 // All valid results (PP_OK, PP_ERROR_...) are nonpositive. |
| 42 CallbackRunInfo() : run_count(0), result(1) {} | 42 CallbackRunInfo() : run_count(0), result(1) {} |
| 43 unsigned run_count; | 43 unsigned run_count; |
| 44 int32_t result; | 44 int32_t result; |
| 45 int32_t completion_task_result; |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 void TestCallback(void* user_data, int32_t result) { | 48 void TestCallback(void* user_data, int32_t result) { |
| 48 CallbackRunInfo* info = reinterpret_cast<CallbackRunInfo*>(user_data); | 49 CallbackRunInfo* info = reinterpret_cast<CallbackRunInfo*>(user_data); |
| 49 info->run_count++; | 50 info->run_count++; |
| 50 if (info->run_count == 1) | 51 if (info->run_count == 1) |
| 51 info->result = result; | 52 info->result = result; |
| 52 } | 53 } |
| 53 | 54 |
| 55 int32_t TestCompletionTask(int32_t result) { |
| 56 return |
| 57 } |
| 58 |
| 54 } // namespace | 59 } // namespace |
| 55 | 60 |
| 56 // CallbackShutdownTest -------------------------------------------------------- | 61 // CallbackShutdownTest -------------------------------------------------------- |
| 57 | 62 |
| 58 namespace { | 63 namespace { |
| 59 | 64 |
| 60 class CallbackShutdownTest : public TrackedCallbackTest { | 65 class CallbackShutdownTest : public TrackedCallbackTest { |
| 61 public: | 66 public: |
| 62 CallbackShutdownTest() {} | 67 CallbackShutdownTest() {} |
| 63 | 68 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // Unref it again and do the same. | 262 // Unref it again and do the same. |
| 258 resource_tracker->ReleaseResource(new_resource_id); | 263 resource_tracker->ReleaseResource(new_resource_id); |
| 259 base::MessageLoop::current()->RunUntilIdle(); | 264 base::MessageLoop::current()->RunUntilIdle(); |
| 260 resource->CheckFinalState(); | 265 resource->CheckFinalState(); |
| 261 | 266 |
| 262 // This shouldn't be needed, but make sure there are no stranded tasks. | 267 // This shouldn't be needed, but make sure there are no stranded tasks. |
| 263 base::MessageLoop::current()->RunUntilIdle(); | 268 base::MessageLoop::current()->RunUntilIdle(); |
| 264 } | 269 } |
| 265 | 270 |
| 266 } // namespace ppapi | 271 } // namespace ppapi |
| OLD | NEW |