| 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/runner/test/pingable.mojom.h" | |
| 10 #include "mojo/shell/public/cpp/application_delegate.h" | 9 #include "mojo/shell/public/cpp/application_delegate.h" |
| 11 #include "mojo/shell/public/cpp/application_impl.h" | 10 #include "mojo/shell/public/cpp/application_impl.h" |
| 12 #include "mojo/shell/public/cpp/application_runner.h" | 11 #include "mojo/shell/public/cpp/application_runner.h" |
| 13 #include "mojo/shell/public/cpp/interface_factory.h" | 12 #include "mojo/shell/public/cpp/interface_factory.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, request.Pass()), | 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 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 48 | 48 |
| 49 bool ConfigureIncomingConnection( | 49 bool ConfigureIncomingConnection( |
| 50 mojo::ApplicationConnection* connection) override { | 50 mojo::ApplicationConnection* connection) override { |
| 51 connection->AddService(this); | 51 connection->AddService(this); |
| 52 return true; | 52 return true; |
| 53 } | 53 } |
| 54 | 54 |
| 55 // InterfaceFactory<Pingable>: | 55 // InterfaceFactory<Pingable>: |
| 56 void Create(mojo::ApplicationConnection* connection, | 56 void Create(mojo::ApplicationConnection* connection, |
| 57 mojo::InterfaceRequest<Pingable> request) override { | 57 mojo::InterfaceRequest<Pingable> request) override { |
| 58 new PingableImpl(request.Pass(), app_url_, connection->GetConnectionURL()); | 58 new PingableImpl(std::move(request), app_url_, |
| 59 connection->GetConnectionURL()); |
| 59 } | 60 } |
| 60 | 61 |
| 61 std::string app_url_; | 62 std::string app_url_; |
| 62 }; | 63 }; |
| 63 | 64 |
| 64 } // namespace mojo | 65 } // namespace mojo |
| 65 | 66 |
| 66 MojoResult MojoMain(MojoHandle shell_handle) { | 67 MojoResult MojoMain(MojoHandle shell_handle) { |
| 67 mojo::ApplicationRunner runner(new mojo::PingableApp); | 68 mojo::ApplicationRunner runner(new mojo::PingableApp); |
| 68 return runner.Run(shell_handle); | 69 return runner.Run(shell_handle); |
| 69 } | 70 } |
| OLD | NEW |