Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Unified Diff: mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc

Issue 2668153003: Mojo C++ Bindings: Eliminate unbound ThreadSafeInterfacePtr (Closed)
Patch Set: format and rebase... Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
index 4849c617bcec4588e7bcd754937b0caa3ab673b0..fb602f596f45c0538f072d6365236a0906a80cee 100644
--- a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
@@ -853,16 +853,20 @@ TEST_F(InterfacePtrTest, ThreadSafeInterfacePointer) {
run_loop.Run();
}
-TEST_F(InterfacePtrTest, BindLaterThreadSafeInterfacePointer) {
+TEST_F(InterfacePtrTest, ThreadSafeInterfacePointerWithTaskRunner) {
// Create and start the thread from where we'll bind the interface pointer.
base::Thread other_thread("service test thread");
other_thread.Start();
const scoped_refptr<base::SingleThreadTaskRunner>& other_thread_task_runner =
other_thread.message_loop()->task_runner();
+ math::CalculatorPtr ptr;
+ math::CalculatorRequest request(&ptr);
+
// Create a ThreadSafeInterfacePtr that we'll bind from a different thread.
scoped_refptr<math::ThreadSafeCalculatorPtr> thread_safe_ptr =
- math::ThreadSafeCalculatorPtr::CreateUnbound(other_thread_task_runner);
+ math::ThreadSafeCalculatorPtr::Create(ptr.PassInterface(),
+ other_thread_task_runner);
ASSERT_TRUE(thread_safe_ptr);
MathCalculatorImpl* math_calc_impl = nullptr;
@@ -872,15 +876,15 @@ TEST_F(InterfacePtrTest, BindLaterThreadSafeInterfacePointer) {
[](const scoped_refptr<base::TaskRunner>& main_task_runner,
const base::Closure& quit_closure,
const scoped_refptr<math::ThreadSafeCalculatorPtr>& thread_safe_ptr,
+ math::CalculatorRequest request,
MathCalculatorImpl** math_calc_impl) {
math::CalculatorPtr ptr;
// In real life, the implementation would have a legitimate owner.
- *math_calc_impl = new MathCalculatorImpl(MakeRequest(&ptr));
- thread_safe_ptr->Bind(std::move(ptr));
+ *math_calc_impl = new MathCalculatorImpl(std::move(request));
main_task_runner->PostTask(FROM_HERE, quit_closure);
},
base::SequencedTaskRunnerHandle::Get(), run_loop.QuitClosure(),
- thread_safe_ptr, &math_calc_impl);
+ thread_safe_ptr, base::Passed(&request), &math_calc_impl);
other_thread.message_loop()->task_runner()->PostTask(FROM_HERE, run_method);
run_loop.Run();
}
« no previous file with comments | « mojo/public/cpp/bindings/tests/associated_interface_unittest.cc ('k') | mojo/public/cpp/bindings/thread_safe_interface_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698