| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include <memory> | |
| 8 #include <utility> | 7 #include <utility> |
| 9 | 8 |
| 10 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
| 11 #include "mojo/public/cpp/application/application_delegate.h" | 10 #include "mojo/public/cpp/application/application_impl_base.h" |
| 12 #include "mojo/public/cpp/application/application_impl.h" | 11 #include "mojo/public/cpp/application/run_application.h" |
| 13 #include "mojo/public/cpp/application/application_runner.h" | 12 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 14 #include "mojo/public/cpp/bindings/strong_binding.h" | 13 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 15 #include "mojo/public/cpp/system/wait.h" | 14 #include "mojo/public/cpp/system/wait.h" |
| 16 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" | 15 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" |
| 17 | 16 |
| 18 namespace mojo { | 17 namespace mojo { |
| 19 namespace examples { | 18 namespace examples { |
| 20 | 19 |
| 21 class PrintBodyApplication : public Application { | 20 class PrintBodyApplication : public Application { |
| 22 public: | 21 public: |
| 23 PrintBodyApplication(InterfaceRequest<Application> request, | 22 PrintBodyApplication(InterfaceRequest<Application> request, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 void StartApplication(InterfaceRequest<Application> application, | 84 void StartApplication(InterfaceRequest<Application> application, |
| 86 URLResponsePtr response) override { | 85 URLResponsePtr response) override { |
| 87 // The application will delete itself after being connected to. | 86 // The application will delete itself after being connected to. |
| 88 new PrintBodyApplication(application.Pass(), response->body.Pass()); | 87 new PrintBodyApplication(application.Pass(), response->body.Pass()); |
| 89 } | 88 } |
| 90 | 89 |
| 91 StrongBinding<ContentHandler> binding_; | 90 StrongBinding<ContentHandler> binding_; |
| 92 MOJO_DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); | 91 MOJO_DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); |
| 93 }; | 92 }; |
| 94 | 93 |
| 95 class ContentHandlerApp : public ApplicationDelegate { | 94 class ContentHandlerApp : public ApplicationImplBase { |
| 96 public: | 95 public: |
| 97 ContentHandlerApp() {} | 96 ContentHandlerApp() {} |
| 98 ~ContentHandlerApp() override {} | 97 ~ContentHandlerApp() override {} |
| 99 | 98 |
| 100 void Initialize(ApplicationImpl* app) override {} | 99 bool OnAcceptConnection(ServiceProviderImpl* service_provider_impl) override { |
| 101 | |
| 102 bool ConfigureIncomingConnection( | |
| 103 ServiceProviderImpl* service_provider_impl) override { | |
| 104 service_provider_impl->AddService<ContentHandler>( | 100 service_provider_impl->AddService<ContentHandler>( |
| 105 [](const ConnectionContext& connection_context, | 101 [](const ConnectionContext& connection_context, |
| 106 InterfaceRequest<ContentHandler> content_handler_request) { | 102 InterfaceRequest<ContentHandler> content_handler_request) { |
| 107 new ContentHandlerImpl(content_handler_request.Pass()); | 103 new ContentHandlerImpl(content_handler_request.Pass()); |
| 108 }); | 104 }); |
| 109 return true; | 105 return true; |
| 110 } | 106 } |
| 111 | 107 |
| 112 private: | 108 private: |
| 113 MOJO_DISALLOW_COPY_AND_ASSIGN(ContentHandlerApp); | 109 MOJO_DISALLOW_COPY_AND_ASSIGN(ContentHandlerApp); |
| 114 }; | 110 }; |
| 115 | 111 |
| 116 } // namespace examples | 112 } // namespace examples |
| 117 } // namespace mojo | 113 } // namespace mojo |
| 118 | 114 |
| 119 MojoResult MojoMain(MojoHandle application_request) { | 115 MojoResult MojoMain(MojoHandle application_request) { |
| 120 mojo::ApplicationRunner runner( | 116 mojo::examples::ContentHandlerApp content_handler_app; |
| 121 std::unique_ptr<mojo::examples::ContentHandlerApp>( | 117 return mojo::RunMainApplication(application_request, &content_handler_app); |
| 122 new mojo::examples::ContentHandlerApp())); | |
| 123 return runner.Run(application_request); | |
| 124 } | 118 } |
| OLD | NEW |