| OLD | NEW |
| 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" | 9 #include "mojo/shell/public/cpp/application_delegate.h" |
| 10 #include "mojo/shell/public/cpp/application_impl.h" | |
| 11 #include "mojo/shell/public/cpp/application_runner.h" | 10 #include "mojo/shell/public/cpp/application_runner.h" |
| 12 #include "mojo/shell/public/cpp/interface_factory.h" | 11 #include "mojo/shell/public/cpp/interface_factory.h" |
| 12 #include "mojo/shell/public/cpp/shell.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)), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 class PingableApp : public mojo::ApplicationDelegate, | 39 class PingableApp : public mojo::ApplicationDelegate, |
| 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 // ApplicationDelegate: |
| 47 void Initialize(ApplicationImpl* impl) override { app_url_ = impl->url(); } | 47 void Initialize(Shell* shell, const std::string& url, uint32_t id) override { |
| 48 app_url_ = url; |
| 49 } |
| 48 | 50 |
| 49 bool AcceptConnection(mojo::ApplicationConnection* connection) override { | 51 bool AcceptConnection(mojo::ApplicationConnection* connection) override { |
| 50 connection->AddService(this); | 52 connection->AddService(this); |
| 51 return true; | 53 return true; |
| 52 } | 54 } |
| 53 | 55 |
| 54 // InterfaceFactory<Pingable>: | 56 // InterfaceFactory<Pingable>: |
| 55 void Create(mojo::ApplicationConnection* connection, | 57 void Create(mojo::ApplicationConnection* connection, |
| 56 mojo::InterfaceRequest<Pingable> request) override { | 58 mojo::InterfaceRequest<Pingable> request) override { |
| 57 new PingableImpl(std::move(request), app_url_, | 59 new PingableImpl(std::move(request), app_url_, |
| 58 connection->GetConnectionURL()); | 60 connection->GetConnectionURL()); |
| 59 } | 61 } |
| 60 | 62 |
| 61 std::string app_url_; | 63 std::string app_url_; |
| 62 }; | 64 }; |
| 63 | 65 |
| 64 } // namespace mojo | 66 } // namespace mojo |
| 65 | 67 |
| 66 MojoResult MojoMain(MojoHandle shell_handle) { | 68 MojoResult MojoMain(MojoHandle shell_handle) { |
| 67 mojo::ApplicationRunner runner(new mojo::PingableApp); | 69 mojo::ApplicationRunner runner(new mojo::PingableApp); |
| 68 return runner.Run(shell_handle); | 70 return runner.Run(shell_handle); |
| 69 } | 71 } |
| OLD | NEW |