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

Side by Side Diff: mojo/public/cpp/bindings/tests/associated_interface_unittest.cc

Issue 2104363004: Remove remaining calls to deprecated MessageLoop methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR gab Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
15 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
16 #include "mojo/public/cpp/bindings/associated_binding.h" 17 #include "mojo/public/cpp/bindings/associated_binding.h"
17 #include "mojo/public/cpp/bindings/associated_group.h" 18 #include "mojo/public/cpp/bindings/associated_group.h"
18 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" 19 #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
19 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" 20 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
20 #include "mojo/public/cpp/bindings/associated_interface_request.h" 21 #include "mojo/public/cpp/bindings/associated_interface_request.h"
21 #include "mojo/public/cpp/bindings/binding.h" 22 #include "mojo/public/cpp/bindings/binding.h"
22 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" 23 #include "mojo/public/cpp/bindings/lib/multiplex_router.h"
23 #include "mojo/public/interfaces/bindings/tests/test_associated_interfaces.mojom .h" 24 #include "mojo/public/interfaces/bindings/tests/test_associated_interfaces.mojom .h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 85
85 private: 86 private:
86 static void DeleteSender(IntegerSenderImpl* sender) { delete sender; } 87 static void DeleteSender(IntegerSenderImpl* sender) { delete sender; }
87 88
88 Binding<IntegerSenderConnection> binding_; 89 Binding<IntegerSenderConnection> binding_;
89 }; 90 };
90 91
91 class AssociatedInterfaceTest : public testing::Test { 92 class AssociatedInterfaceTest : public testing::Test {
92 public: 93 public:
93 AssociatedInterfaceTest() {} 94 AssociatedInterfaceTest() {}
94 ~AssociatedInterfaceTest() override { loop_.RunUntilIdle(); } 95 ~AssociatedInterfaceTest() override { base::RunLoop().RunUntilIdle(); }
95 96
96 void PumpMessages() { loop_.RunUntilIdle(); } 97 void PumpMessages() { base::RunLoop().RunUntilIdle(); }
97 98
98 template <typename T> 99 template <typename T>
99 AssociatedInterfacePtrInfo<T> EmulatePassingAssociatedPtrInfo( 100 AssociatedInterfacePtrInfo<T> EmulatePassingAssociatedPtrInfo(
100 AssociatedInterfacePtrInfo<T> ptr_info, 101 AssociatedInterfacePtrInfo<T> ptr_info,
101 scoped_refptr<MultiplexRouter> target) { 102 scoped_refptr<MultiplexRouter> target) {
102 ScopedInterfaceEndpointHandle handle = ptr_info.PassHandle(); 103 ScopedInterfaceEndpointHandle handle = ptr_info.PassHandle();
103 CHECK(!handle.is_local()); 104 CHECK(!handle.is_local());
104 return AssociatedInterfacePtrInfo<T>( 105 return AssociatedInterfacePtrInfo<T>(
105 target->CreateLocalEndpointHandle(handle.release()), 106 target->CreateLocalEndpointHandle(handle.release()),
106 ptr_info.version()); 107 ptr_info.version());
107 } 108 }
108 109
109 template <typename T> 110 template <typename T>
110 AssociatedInterfaceRequest<T> EmulatePassingAssociatedRequest( 111 AssociatedInterfaceRequest<T> EmulatePassingAssociatedRequest(
111 AssociatedInterfaceRequest<T> request, 112 AssociatedInterfaceRequest<T> request,
112 scoped_refptr<MultiplexRouter> target) { 113 scoped_refptr<MultiplexRouter> target) {
113 ScopedInterfaceEndpointHandle handle = request.PassHandle(); 114 ScopedInterfaceEndpointHandle handle = request.PassHandle();
114 CHECK(!handle.is_local()); 115 CHECK(!handle.is_local());
115 return MakeAssociatedRequest<T>( 116 return MakeAssociatedRequest<T>(
116 target->CreateLocalEndpointHandle(handle.release())); 117 target->CreateLocalEndpointHandle(handle.release()));
117 } 118 }
118 119
119 // Okay to call from any thread. 120 // Okay to call from any thread.
120 void QuitRunLoop(base::RunLoop* run_loop) { 121 void QuitRunLoop(base::RunLoop* run_loop) {
121 if (loop_.task_runner()->BelongsToCurrentThread()) { 122 if (loop_.task_runner()->BelongsToCurrentThread()) {
122 run_loop->Quit(); 123 run_loop->Quit();
123 } else { 124 } else {
124 loop_.PostTask( 125 loop_.task_runner()->PostTask(
125 FROM_HERE, 126 FROM_HERE,
126 base::Bind(&AssociatedInterfaceTest::QuitRunLoop, 127 base::Bind(&AssociatedInterfaceTest::QuitRunLoop,
127 base::Unretained(this), base::Unretained(run_loop))); 128 base::Unretained(this), base::Unretained(run_loop)));
128 } 129 }
129 } 130 }
130 131
131 private: 132 private:
132 base::MessageLoop loop_; 133 base::MessageLoop loop_;
133 }; 134 };
134 135
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 585
585 // The previous wait has dispatched the GetSender request message, therefore 586 // The previous wait has dispatched the GetSender request message, therefore
586 // an associated interface has been set up on the pipe. It is not allowed to 587 // an associated interface has been set up on the pipe. It is not allowed to
587 // wait or pause. 588 // wait or pause.
588 EXPECT_TRUE(connection.binding()->HasAssociatedInterfaces()); 589 EXPECT_TRUE(connection.binding()->HasAssociatedInterfaces());
589 } 590 }
590 591
591 } // namespace 592 } // namespace
592 } // namespace test 593 } // namespace test
593 } // namespace mojo 594 } // namespace mojo
OLDNEW
« no previous file with comments | « media/test/pipeline_integration_test.cc ('k') | mojo/public/cpp/bindings/tests/binding_callback_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698