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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/location.h" |
6 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
7 #include "base/message_loop/message_loop.h" | |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/single_thread_task_runner.h" |
9 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/simple_thread.h" | 11 #include "base/threading/simple_thread.h" |
11 #include "ppapi/c/pp_completion_callback.h" | 12 #include "ppapi/c/pp_completion_callback.h" |
12 #include "ppapi/c/pp_errors.h" | 13 #include "ppapi/c/pp_errors.h" |
13 #include "ppapi/proxy/ppapi_proxy_test.h" | 14 #include "ppapi/proxy/ppapi_proxy_test.h" |
14 #include "ppapi/proxy/ppb_message_loop_proxy.h" | 15 #include "ppapi/proxy/ppb_message_loop_proxy.h" |
15 #include "ppapi/shared_impl/callback_tracker.h" | 16 #include "ppapi/shared_impl/callback_tracker.h" |
16 #include "ppapi/shared_impl/proxy_lock.h" | 17 #include "ppapi/shared_impl/proxy_lock.h" |
17 #include "ppapi/shared_impl/resource.h" | 18 #include "ppapi/shared_impl/resource.h" |
18 #include "ppapi/shared_impl/resource_tracker.h" | 19 #include "ppapi/shared_impl/resource_tracker.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 ProxyAutoLock acquire; | 239 ProxyAutoLock acquire; |
239 reference_holder_ = 0; | 240 reference_holder_ = 0; |
240 } | 241 } |
241 | 242 |
242 // Create the test callbacks on a background thread, so that we can verify | 243 // Create the test callbacks on a background thread, so that we can verify |
243 // they are run on the same thread where they were created. | 244 // they are run on the same thread where they were created. |
244 void CreateCallbacksOnLoop(MessageLoopResource* loop_resource) { | 245 void CreateCallbacksOnLoop(MessageLoopResource* loop_resource) { |
245 ProxyAutoLock acquire; | 246 ProxyAutoLock acquire; |
246 // |thread_checker_| will bind to the background thread. | 247 // |thread_checker_| will bind to the background thread. |
247 thread_checker_.DetachFromThread(); | 248 thread_checker_.DetachFromThread(); |
248 loop_resource->message_loop_proxy()->PostTask(FROM_HERE, | 249 loop_resource->task_runner()->PostTask( |
249 RunWhileLocked( | 250 FROM_HERE, RunWhileLocked(base::Bind( |
250 base::Bind(&CallbackMockResource::CreateCallbacks, this))); | 251 &CallbackMockResource::CreateCallbacks, this))); |
251 } | 252 } |
252 | 253 |
253 int32_t CompletionTask(CallbackRunInfo* info, int32_t result) { | 254 int32_t CompletionTask(CallbackRunInfo* info, int32_t result) { |
254 // The completion task must run on the thread where the callback was | 255 // The completion task must run on the thread where the callback was |
255 // created, and must hold the proxy lock. | 256 // created, and must hold the proxy lock. |
256 CHECK(thread_checker_.CalledOnValidThread()); | 257 CHECK(thread_checker_.CalledOnValidThread()); |
257 ProxyLock::AssertAcquired(); | 258 ProxyLock::AssertAcquired(); |
258 | 259 |
259 // We should run before the callback. | 260 // We should run before the callback. |
260 CHECK_EQ(0U, info->run_count()); | 261 CHECK_EQ(0U, info->run_count()); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 resource->ReleaseRef(); | 463 resource->ReleaseRef(); |
463 resource->CheckFinalState(); | 464 resource->CheckFinalState(); |
464 { | 465 { |
465 ProxyAutoLock lock; | 466 ProxyAutoLock lock; |
466 resource = nullptr; | 467 resource = nullptr; |
467 } | 468 } |
468 } | 469 } |
469 | 470 |
470 } // namespace proxy | 471 } // namespace proxy |
471 } // namespace ppapi | 472 } // namespace ppapi |
OLD | NEW |