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

Side by Side Diff: shell/test/pingable_app.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 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 <memory>
6
7 #include "mojo/public/c/system/main.h" 5 #include "mojo/public/c/system/main.h"
8 #include "mojo/public/cpp/application/application_delegate.h" 6 #include "mojo/public/cpp/application/application_impl_base.h"
9 #include "mojo/public/cpp/application/application_impl.h" 7 #include "mojo/public/cpp/application/run_application.h"
10 #include "mojo/public/cpp/application/application_runner.h" 8 #include "mojo/public/cpp/application/service_provider_impl.h"
11 #include "mojo/public/cpp/bindings/callback.h" 9 #include "mojo/public/cpp/bindings/callback.h"
12 #include "mojo/public/cpp/bindings/interface_request.h" 10 #include "mojo/public/cpp/bindings/interface_request.h"
13 #include "mojo/public/cpp/bindings/strong_binding.h" 11 #include "mojo/public/cpp/bindings/strong_binding.h"
14 #include "shell/test/pingable.mojom.h" 12 #include "shell/test/pingable.mojom.h"
15 13
16 using mojo::String; 14 using mojo::String;
17 15
18 class PingableImpl : public Pingable { 16 class PingableImpl : public Pingable {
19 public: 17 public:
20 PingableImpl(mojo::InterfaceRequest<Pingable> request, 18 PingableImpl(mojo::InterfaceRequest<Pingable> request,
(...skipping 10 matching lines...) Expand all
31 const String& message, 29 const String& message,
32 const mojo::Callback<void(String, String, String)>& callback) override { 30 const mojo::Callback<void(String, String, String)>& callback) override {
33 callback.Run(app_url_, connection_url_, message); 31 callback.Run(app_url_, connection_url_, message);
34 } 32 }
35 33
36 mojo::StrongBinding<Pingable> binding_; 34 mojo::StrongBinding<Pingable> binding_;
37 std::string app_url_; 35 std::string app_url_;
38 std::string connection_url_; 36 std::string connection_url_;
39 }; 37 };
40 38
41 class PingableApp : public mojo::ApplicationDelegate { 39 class PingableApp : public mojo::ApplicationImplBase {
42 public: 40 public:
43 PingableApp() {} 41 PingableApp() {}
44 ~PingableApp() override {} 42 ~PingableApp() override {}
45 43
46 private: 44 private:
47 // ApplicationDelegate: 45 // ApplicationImplBase:
48 void Initialize(mojo::ApplicationImpl* impl) override { 46 bool OnAcceptConnection(
49 app_url_ = impl->url();
50 }
51
52 bool ConfigureIncomingConnection(
53 mojo::ServiceProviderImpl* service_provider_impl) override { 47 mojo::ServiceProviderImpl* service_provider_impl) override {
54 service_provider_impl->AddService<Pingable>( 48 service_provider_impl->AddService<Pingable>(
55 [this](const mojo::ConnectionContext& connection_context, 49 [this](const mojo::ConnectionContext& connection_context,
56 mojo::InterfaceRequest<Pingable> pingable_request) { 50 mojo::InterfaceRequest<Pingable> pingable_request) {
57 new PingableImpl(pingable_request.Pass(), app_url_, 51 new PingableImpl(pingable_request.Pass(), url(),
58 connection_context.connection_url); 52 connection_context.connection_url);
59 }); 53 });
60 return true; 54 return true;
61 } 55 }
62
63 std::string app_url_;
64 }; 56 };
65 57
66 MojoResult MojoMain(MojoHandle application_request) { 58 MojoResult MojoMain(MojoHandle application_request) {
67 mojo::ApplicationRunner runner( 59 PingableApp pingable_app;
68 std::unique_ptr<PingableApp>(new PingableApp())); 60 return mojo::RunMainApplication(application_request, &pingable_app);
69 return runner.Run(application_request);
70 } 61 }
OLDNEW
« no previous file with comments | « services/url_response_disk_cache/url_response_disk_cache_app.cc ('k') | shell/url_response_disk_cache_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698