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

Side by Side Diff: examples/echo_terminal/main.cc

Issue 1979723002: ApplicationConnection devolution, part 3. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 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 <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 class EchoTerminalApp 98 class EchoTerminalApp
99 : public mojo::ApplicationDelegate, 99 : public mojo::ApplicationDelegate,
100 public mojo::terminal::TerminalClient { 100 public mojo::terminal::TerminalClient {
101 public: 101 public:
102 EchoTerminalApp() {} 102 EchoTerminalApp() {}
103 ~EchoTerminalApp() override {} 103 ~EchoTerminalApp() override {}
104 104
105 private: 105 private:
106 // |ApplicationDelegate| override: 106 // |ApplicationDelegate| override:
107 bool ConfigureIncomingConnection( 107 bool ConfigureIncomingConnection(
108 mojo::ApplicationConnection* connection) override { 108 mojo::ServiceProviderImpl* service_provider_impl) override {
109 connection->GetServiceProviderImpl() 109 service_provider_impl->AddService<mojo::terminal::TerminalClient>(
110 .AddService<mojo::terminal::TerminalClient>([this]( 110 [this](const mojo::ConnectionContext& connection_context,
111 const mojo::ConnectionContext& connection_context, 111 mojo::InterfaceRequest<mojo::terminal::TerminalClient>
112 mojo::InterfaceRequest<mojo::terminal::TerminalClient> 112 terminal_client_request) {
113 terminal_client_request) {
114 terminal_clients_.AddBinding(this, terminal_client_request.Pass()); 113 terminal_clients_.AddBinding(this, terminal_client_request.Pass());
115 }); 114 });
116 return true; 115 return true;
117 } 116 }
118 117
119 // |mojo::terminal::TerminalClient| implementation: 118 // |mojo::terminal::TerminalClient| implementation:
120 void ConnectToTerminal( 119 void ConnectToTerminal(
121 mojo::InterfaceHandle<mojo::files::File> terminal) override { 120 mojo::InterfaceHandle<mojo::files::File> terminal) override {
122 DCHECK(terminal); 121 DCHECK(terminal);
123 // The |TerminalEchoer| will own itself. 122 // The |TerminalEchoer| will own itself.
124 (new TerminalEchoer(mojo::files::FilePtr::Create(std::move(terminal)))) 123 (new TerminalEchoer(mojo::files::FilePtr::Create(std::move(terminal))))
125 ->StartReading(); 124 ->StartReading();
126 } 125 }
127 126
128 mojo::BindingSet<mojo::terminal::TerminalClient> terminal_clients_; 127 mojo::BindingSet<mojo::terminal::TerminalClient> terminal_clients_;
129 128
130 DISALLOW_COPY_AND_ASSIGN(EchoTerminalApp); 129 DISALLOW_COPY_AND_ASSIGN(EchoTerminalApp);
131 }; 130 };
132 131
133 MojoResult MojoMain(MojoHandle application_request) { 132 MojoResult MojoMain(MojoHandle application_request) {
134 mojo::ApplicationRunnerChromium runner(new EchoTerminalApp()); 133 mojo::ApplicationRunnerChromium runner(new EchoTerminalApp());
135 return runner.Run(application_request); 134 return runner.Run(application_request);
136 } 135 }
OLDNEW
« no previous file with comments | « examples/echo/echo_server.cc ('k') | examples/forwarding_content_handler/forwarding_content_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698