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

Side by Side Diff: examples/moterm_example_app/moterm_example_app.cc

Issue 1682113003: Mojo C++ bindings: Generate InterfaceHandle<> instead of InterfacePtr<>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase ontop of master, address trung's comments Created 4 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 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 // This is a simple example application (with an embeddable view), which embeds 5 // This is a simple example application (with an embeddable view), which embeds
6 // the Moterm view, uses it to prompt the user, etc. 6 // the Moterm view, uses it to prompt the user, etc.
7 7
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <utility>
11 12
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "mojo/application/application_runner_chromium.h" 18 #include "mojo/application/application_runner_chromium.h"
18 #include "mojo/common/binding_set.h" 19 #include "mojo/common/binding_set.h"
19 #include "mojo/public/c/system/main.h" 20 #include "mojo/public/c/system/main.h"
20 #include "mojo/public/cpp/application/application_connection.h" 21 #include "mojo/public/cpp/application/application_connection.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 126
126 Fputs(moterm_file_.get(), 127 Fputs(moterm_file_.get(),
127 base::StringPrintf("\nGoing to %s ...\n", dest_url.c_str()).c_str()); 128 base::StringPrintf("\nGoing to %s ...\n", dest_url.c_str()).c_str());
128 moterm_file_.reset(); 129 moterm_file_.reset();
129 130
130 mojo::ServiceProviderPtr dest_sp; 131 mojo::ServiceProviderPtr dest_sp;
131 shell_->ConnectToApplication(dest_url, GetProxy(&dest_sp), nullptr); 132 shell_->ConnectToApplication(dest_url, GetProxy(&dest_sp), nullptr);
132 mojo::terminal::TerminalClientPtr dest_terminal_client; 133 mojo::terminal::TerminalClientPtr dest_terminal_client;
133 mojo::ConnectToService(dest_sp.get(), &dest_terminal_client); 134 mojo::ConnectToService(dest_sp.get(), &dest_terminal_client);
134 moterm_terminal_->ConnectToClient( 135 moterm_terminal_->ConnectToClient(
135 dest_terminal_client.Pass(), true, 136 std::move(dest_terminal_client), true,
136 base::Bind(&MotermExampleAppView::OnDestinationDone, 137 base::Bind(&MotermExampleAppView::OnDestinationDone,
137 weak_factory_.GetWeakPtr())); 138 weak_factory_.GetWeakPtr()));
138 } 139 }
139 void OnDestinationDone(mojo::files::Error error) { 140 void OnDestinationDone(mojo::files::Error error) {
140 // We should always succeed. (It'll only fail on synchronous failures, which 141 // We should always succeed. (It'll only fail on synchronous failures, which
141 // only occur when it's busy.) 142 // only occur when it's busy.)
142 DCHECK_EQ(error, mojo::files::Error::OK); 143 DCHECK_EQ(error, mojo::files::Error::OK);
143 StartPrompt(false); 144 StartPrompt(false);
144 } 145 }
145 146
(...skipping 12 matching lines...) Expand all
158 class MotermExampleApp : public mojo::ui::ViewProviderApp { 159 class MotermExampleApp : public mojo::ui::ViewProviderApp {
159 public: 160 public:
160 MotermExampleApp() {} 161 MotermExampleApp() {}
161 ~MotermExampleApp() override {} 162 ~MotermExampleApp() override {}
162 163
163 // |ViewProviderApp|: 164 // |ViewProviderApp|:
164 void CreateView( 165 void CreateView(
165 const std::string& connection_url, 166 const std::string& connection_url,
166 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, 167 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request,
167 mojo::InterfaceRequest<mojo::ServiceProvider> services, 168 mojo::InterfaceRequest<mojo::ServiceProvider> services,
168 mojo::ServiceProviderPtr exposed_services) override { 169 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services) override {
169 new MotermExampleAppView(app_impl()->shell(), view_owner_request.Pass()); 170 new MotermExampleAppView(app_impl()->shell(), view_owner_request.Pass());
170 } 171 }
171 172
172 private: 173 private:
173 DISALLOW_COPY_AND_ASSIGN(MotermExampleApp); 174 DISALLOW_COPY_AND_ASSIGN(MotermExampleApp);
174 }; 175 };
175 176
176 MojoResult MojoMain(MojoHandle application_request) { 177 MojoResult MojoMain(MojoHandle application_request) {
177 mojo::ApplicationRunnerChromium runner(new MotermExampleApp()); 178 mojo::ApplicationRunnerChromium runner(new MotermExampleApp());
178 return runner.Run(application_request); 179 return runner.Run(application_request);
179 } 180 }
OLDNEW
« no previous file with comments | « examples/indirect_service/indirect_service_demo.cc ('k') | examples/native_run_app/native_run_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698