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

Unified Diff: examples/bank_app/customer.cc

Issue 2012873003: More ApplicationDelegate/ApplicationRunner[Chromium] conversion. (Closed) Base URL: https://github.com/domokit/mojo.git@work791_run_app_options
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « examples/bank_app/bank.cc ('k') | examples/echo/echo_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/bank_app/customer.cc
diff --git a/examples/bank_app/customer.cc b/examples/bank_app/customer.cc
index 77562c93b13dd30413b22c3e7fcdd1cf116c6c45..9d9790f8588e87b1f6d3de84d41637fc4f29f998 100644
--- a/examples/bank_app/customer.cc
+++ b/examples/bank_app/customer.cc
@@ -2,14 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <memory>
-
#include "examples/bank_app/bank.mojom.h"
#include "mojo/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/application_runner.h"
+#include "mojo/public/cpp/application/application_impl_base.h"
#include "mojo/public/cpp/application/connect.h"
+#include "mojo/public/cpp/application/run_application.h"
#include "mojo/public/cpp/utility/run_loop.h"
#include "mojo/services/vanadium/security/interfaces/principal.mojom.h"
@@ -24,10 +21,10 @@ class LoginHandler {
}
};
-class BankCustomer : public mojo::ApplicationDelegate {
+class BankCustomer : public mojo::ApplicationImplBase {
public:
- void Initialize(mojo::ApplicationImpl* app) override {
- mojo::ConnectToService(app->shell(), "mojo:principal_service",
+ void OnInitialize() override {
+ mojo::ConnectToService(shell(), "mojo:principal_service",
GetProxy(&login_service_));
// Login to the principal service to get a user identity.
@@ -38,7 +35,7 @@ class BankCustomer : public mojo::ApplicationDelegate {
}
BankPtr bank;
- mojo::ConnectToService(app->shell(), "mojo:bank", GetProxy(&bank));
+ mojo::ConnectToService(shell(), "mojo:bank", GetProxy(&bank));
bank->Deposit(500/*usd*/);
bank->Withdraw(100/*usd*/);
auto gb_callback = [](const int32_t& balance) {
@@ -47,9 +44,8 @@ class BankCustomer : public mojo::ApplicationDelegate {
bank->GetBalance(mojo::Callback<void(const int32_t&)>(gb_callback));
bank.WaitForIncomingResponse();
}
- void Quit() override {
- login_service_->Logout();
- }
+ void OnQuit() override { login_service_->Logout(); }
+
private:
vanadium::PrincipalServicePtr login_service_;
};
@@ -57,7 +53,6 @@ class BankCustomer : public mojo::ApplicationDelegate {
} // namespace examples
MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunner runner(
- std::unique_ptr<examples::BankCustomer>(new examples::BankCustomer()));
- return runner.Run(application_request);
+ examples::BankCustomer bank_customer;
+ return mojo::RunMainApplication(application_request, &bank_customer);
}
« no previous file with comments | « examples/bank_app/bank.cc ('k') | examples/echo/echo_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698