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

Side by Side Diff: mojo/shell/tests/connect/connect_test_app.cc

Issue 1775793002: Fix chrome --mash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 9 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 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // InterfaceFactory<test::mojom::BlockedInterface>: 86 // InterfaceFactory<test::mojom::BlockedInterface>:
87 void Create(Connection* connection, 87 void Create(Connection* connection,
88 test::mojom::BlockedInterfaceRequest request) override { 88 test::mojom::BlockedInterfaceRequest request) override {
89 blocked_bindings_.AddBinding(this, std::move(request)); 89 blocked_bindings_.AddBinding(this, std::move(request));
90 } 90 }
91 91
92 // test::mojom::ConnectTestService: 92 // test::mojom::ConnectTestService:
93 void GetTitle(const GetTitleCallback& callback) override { 93 void GetTitle(const GetTitleCallback& callback) override {
94 callback.Run("APP"); 94 callback.Run("APP");
95 } 95 }
96 void GetInstance(const GetInstanceCallback& callback) override {
97 callback.Run(identity_.instance());
98 }
96 99
97 // test::mojom::StandaloneApp: 100 // test::mojom::StandaloneApp:
98 void ConnectToAllowedAppInBlockedPackage( 101 void ConnectToAllowedAppInBlockedPackage(
99 const ConnectToAllowedAppInBlockedPackageCallback& callback) override { 102 const ConnectToAllowedAppInBlockedPackageCallback& callback) override {
100 base::RunLoop run_loop; 103 base::RunLoop run_loop;
101 scoped_ptr<Connection> connection = 104 scoped_ptr<Connection> connection =
102 connector_->Connect("mojo:connect_test_a"); 105 connector_->Connect("mojo:connect_test_a");
103 connection->SetConnectionLostClosure( 106 connection->SetConnectionLostClosure(
104 base::Bind(&ConnectTestApp::OnConnectionBlocked, 107 base::Bind(&ConnectTestApp::OnConnectionBlocked,
105 base::Unretained(this), callback, &run_loop)); 108 base::Unretained(this), callback, &run_loop));
106 test::mojom::ConnectTestServicePtr test_service; 109 test::mojom::ConnectTestServicePtr test_service;
107 connection->GetInterface(&test_service); 110 connection->GetInterface(&test_service);
108 test_service->GetTitle( 111 test_service->GetTitle(
109 base::Bind(&ConnectTestApp::OnGotTitle, base::Unretained(this), 112 base::Bind(&ConnectTestApp::OnGotTitle, base::Unretained(this),
110 callback, &run_loop)); 113 callback, &run_loop));
111 { 114 {
112 // This message is dispatched as a task on the same run loop, so we need 115 // This message is dispatched as a task on the same run loop, so we need
113 // to allow nesting in order to pump additional signals. 116 // to allow nesting in order to pump additional signals.
114 base::MessageLoop::ScopedNestableTaskAllower allow( 117 base::MessageLoop::ScopedNestableTaskAllower allow(
115 base::MessageLoop::current()); 118 base::MessageLoop::current());
116 run_loop.Run(); 119 run_loop.Run();
117 } 120 }
118 } 121 }
119 void GetInstance(const GetInstanceCallback& callback) override {
120 callback.Run(identity_.instance());
121 }
122 122
123 // test::mojom::BlockedInterface: 123 // test::mojom::BlockedInterface:
124 void GetTitleBlocked(const GetTitleBlockedCallback& callback) override { 124 void GetTitleBlocked(const GetTitleBlockedCallback& callback) override {
125 callback.Run("Called Blocked Interface!"); 125 callback.Run("Called Blocked Interface!");
126 } 126 }
127 127
128 void OnConnectionBlocked( 128 void OnConnectionBlocked(
129 const ConnectToAllowedAppInBlockedPackageCallback& callback, 129 const ConnectToAllowedAppInBlockedPackageCallback& callback,
130 base::RunLoop* run_loop) { 130 base::RunLoop* run_loop) {
131 callback.Run("uninitialized"); 131 callback.Run("uninitialized");
(...skipping 26 matching lines...) Expand all
158 158
159 } // namespace shell 159 } // namespace shell
160 } // namespace mojo 160 } // namespace mojo
161 161
162 162
163 MojoResult MojoMain(MojoHandle shell_handle) { 163 MojoResult MojoMain(MojoHandle shell_handle) {
164 MojoResult rv = mojo::ApplicationRunner( 164 MojoResult rv = mojo::ApplicationRunner(
165 new mojo::shell::ConnectTestApp).Run(shell_handle); 165 new mojo::shell::ConnectTestApp).Run(shell_handle);
166 return rv; 166 return rv;
167 } 167 }
OLDNEW
« no previous file with comments | « mojo/shell/tests/connect/connect_test.mojom ('k') | mojo/shell/tests/connect/connect_test_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698