| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
| 10 #include "mojo/public/cpp/bindings/binding_set.h" | 10 #include "mojo/public/cpp/bindings/binding_set.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 scoped_ptr<Connection> connection = | 103 scoped_ptr<Connection> connection = |
| 104 connector_->Connect("mojo:connect_test_a"); | 104 connector_->Connect("mojo:connect_test_a"); |
| 105 connection->SetRemoteInterfaceProviderConnectionErrorHandler( | 105 connection->SetRemoteInterfaceProviderConnectionErrorHandler( |
| 106 base::Bind(&ConnectTestApp::OnConnectionBlocked, | 106 base::Bind(&ConnectTestApp::OnConnectionBlocked, |
| 107 base::Unretained(this), callback, &run_loop)); | 107 base::Unretained(this), callback, &run_loop)); |
| 108 test::mojom::ConnectTestServicePtr test_service; | 108 test::mojom::ConnectTestServicePtr test_service; |
| 109 connection->GetInterface(&test_service); | 109 connection->GetInterface(&test_service); |
| 110 test_service->GetTitle( | 110 test_service->GetTitle( |
| 111 base::Bind(&ConnectTestApp::OnGotTitle, base::Unretained(this), | 111 base::Bind(&ConnectTestApp::OnGotTitle, base::Unretained(this), |
| 112 callback, &run_loop)); | 112 callback, &run_loop)); |
| 113 { | 113 run_loop.Run(); |
| 114 // This message is dispatched as a task on the same run loop, so we need | |
| 115 // to allow nesting in order to pump additional signals. | |
| 116 base::MessageLoop::ScopedNestableTaskAllower allow( | |
| 117 base::MessageLoop::current()); | |
| 118 run_loop.Run(); | |
| 119 } | |
| 120 } | 114 } |
| 121 | 115 |
| 122 // test::mojom::BlockedInterface: | 116 // test::mojom::BlockedInterface: |
| 123 void GetTitleBlocked(const GetTitleBlockedCallback& callback) override { | 117 void GetTitleBlocked(const GetTitleBlockedCallback& callback) override { |
| 124 callback.Run("Called Blocked Interface!"); | 118 callback.Run("Called Blocked Interface!"); |
| 125 } | 119 } |
| 126 | 120 |
| 127 void OnConnectionBlocked( | 121 void OnConnectionBlocked( |
| 128 const ConnectToAllowedAppInBlockedPackageCallback& callback, | 122 const ConnectToAllowedAppInBlockedPackageCallback& callback, |
| 129 base::RunLoop* run_loop) { | 123 base::RunLoop* run_loop) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 158 | 152 |
| 159 } // namespace shell | 153 } // namespace shell |
| 160 } // namespace mojo | 154 } // namespace mojo |
| 161 | 155 |
| 162 | 156 |
| 163 MojoResult MojoMain(MojoHandle shell_handle) { | 157 MojoResult MojoMain(MojoHandle shell_handle) { |
| 164 MojoResult rv = mojo::ApplicationRunner( | 158 MojoResult rv = mojo::ApplicationRunner( |
| 165 new mojo::shell::ConnectTestApp).Run(shell_handle); | 159 new mojo::shell::ConnectTestApp).Run(shell_handle); |
| 166 return rv; | 160 return rv; |
| 167 } | 161 } |
| OLD | NEW |