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

Side by Side Diff: mojo/shell/standalone/test/pingable_app.cc

Issue 1675083002: Rename ApplicationDelegate to ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegate
Patch Set: . 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 #include "mojo/public/c/system/main.h" 5 #include "mojo/public/c/system/main.h"
6 #include "mojo/public/cpp/bindings/callback.h" 6 #include "mojo/public/cpp/bindings/callback.h"
7 #include "mojo/public/cpp/bindings/interface_request.h" 7 #include "mojo/public/cpp/bindings/interface_request.h"
8 #include "mojo/public/cpp/bindings/strong_binding.h" 8 #include "mojo/public/cpp/bindings/strong_binding.h"
9 #include "mojo/shell/public/cpp/application_delegate.h"
10 #include "mojo/shell/public/cpp/application_runner.h" 9 #include "mojo/shell/public/cpp/application_runner.h"
11 #include "mojo/shell/public/cpp/interface_factory.h" 10 #include "mojo/shell/public/cpp/interface_factory.h"
12 #include "mojo/shell/public/cpp/shell.h" 11 #include "mojo/shell/public/cpp/shell.h"
12 #include "mojo/shell/public/cpp/shell_client.h"
13 #include "mojo/shell/standalone/test/pingable.mojom.h" 13 #include "mojo/shell/standalone/test/pingable.mojom.h"
14 14
15 namespace mojo { 15 namespace mojo {
16 16
17 class PingableImpl : public Pingable { 17 class PingableImpl : public Pingable {
18 public: 18 public:
19 PingableImpl(InterfaceRequest<Pingable> request, 19 PingableImpl(InterfaceRequest<Pingable> request,
20 const std::string& app_url, 20 const std::string& app_url,
21 const std::string& connection_url) 21 const std::string& connection_url)
22 : binding_(this, std::move(request)), 22 : binding_(this, std::move(request)),
23 app_url_(app_url), 23 app_url_(app_url),
24 connection_url_(connection_url) {} 24 connection_url_(connection_url) {}
25 25
26 ~PingableImpl() override {} 26 ~PingableImpl() override {}
27 27
28 private: 28 private:
29 void Ping(const String& message, 29 void Ping(const String& message,
30 const Callback<void(String, String, String)>& callback) override { 30 const Callback<void(String, String, String)>& callback) override {
31 callback.Run(app_url_, connection_url_, message); 31 callback.Run(app_url_, connection_url_, message);
32 } 32 }
33 33
34 StrongBinding<Pingable> binding_; 34 StrongBinding<Pingable> binding_;
35 std::string app_url_; 35 std::string app_url_;
36 std::string connection_url_; 36 std::string connection_url_;
37 }; 37 };
38 38
39 class PingableApp : public mojo::ApplicationDelegate, 39 class PingableApp : public mojo::ShellClient,
40 public mojo::InterfaceFactory<Pingable> { 40 public mojo::InterfaceFactory<Pingable> {
41 public: 41 public:
42 PingableApp() {} 42 PingableApp() {}
43 ~PingableApp() override {} 43 ~PingableApp() override {}
44 44
45 private: 45 private:
46 // ApplicationDelegate: 46 // mojo::ShellClient:
47 void Initialize(Shell* shell, const std::string& url, uint32_t id) override { 47 void Initialize(Shell* shell, const std::string& url, uint32_t id) override {
48 app_url_ = url; 48 app_url_ = url;
49 } 49 }
50 50
51 bool AcceptConnection(mojo::ApplicationConnection* connection) override { 51 bool AcceptConnection(mojo::Connection* connection) override {
52 connection->AddService(this); 52 connection->AddService(this);
53 return true; 53 return true;
54 } 54 }
55 55
56 // InterfaceFactory<Pingable>: 56 // InterfaceFactory<Pingable>:
57 void Create(mojo::ApplicationConnection* connection, 57 void Create(mojo::Connection* connection,
58 mojo::InterfaceRequest<Pingable> request) override { 58 mojo::InterfaceRequest<Pingable> request) override {
59 new PingableImpl(std::move(request), app_url_, 59 new PingableImpl(std::move(request), app_url_,
60 connection->GetConnectionURL()); 60 connection->GetConnectionURL());
61 } 61 }
62 62
63 std::string app_url_; 63 std::string app_url_;
64 }; 64 };
65 65
66 } // namespace mojo 66 } // namespace mojo
67 67
68 MojoResult MojoMain(MojoHandle shell_handle) { 68 MojoResult MojoMain(MojoHandle shell_handle) {
69 mojo::ApplicationRunner runner(new mojo::PingableApp); 69 mojo::ApplicationRunner runner(new mojo::PingableApp);
70 return runner.Run(shell_handle); 70 return runner.Run(shell_handle);
71 } 71 }
OLDNEW
« no previous file with comments | « mojo/shell/standalone/android/android_handler.cc ('k') | mojo/shell/static_application_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698