| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/memory/scoped_ptr.h" | |
| 7 #include "mojo/application/content_handler_factory.h" | 6 #include "mojo/application/content_handler_factory.h" |
| 8 #include "mojo/environment/scoped_chromium_init.h" | 7 #include "mojo/environment/scoped_chromium_init.h" |
| 9 #include "mojo/public/c/system/main.h" | 8 #include "mojo/public/c/system/main.h" |
| 10 #include "mojo/public/cpp/application/application_impl_base.h" | 9 #include "mojo/public/cpp/application/application_impl_base.h" |
| 11 #include "mojo/public/cpp/application/run_application.h" | 10 #include "mojo/public/cpp/application/run_application.h" |
| 12 #include "mojo/public/cpp/application/service_provider_impl.h" | 11 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 13 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" | 12 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" |
| 14 | 13 |
| 15 namespace mojo { | 14 namespace mojo { |
| 16 namespace examples { | 15 namespace examples { |
| 17 | 16 |
| 18 class RecursiveContentHandler : public ApplicationImplBase, | 17 class RecursiveContentHandler : public ApplicationImplBase, |
| 19 public ContentHandlerFactory::ManagedDelegate { | 18 public ContentHandlerFactory::ManagedDelegate { |
| 20 public: | 19 public: |
| 21 RecursiveContentHandler() {} | 20 RecursiveContentHandler() {} |
| 22 | 21 |
| 23 private: | 22 private: |
| 24 // Overridden from ApplicationImplBase: | 23 // Overridden from ApplicationImplBase: |
| 25 bool OnAcceptConnection(ServiceProviderImpl* service_provider_impl) override { | 24 bool OnAcceptConnection(ServiceProviderImpl* service_provider_impl) override { |
| 26 service_provider_impl->AddService<ContentHandler>( | 25 service_provider_impl->AddService<ContentHandler>( |
| 27 ContentHandlerFactory::GetInterfaceRequestHandler(this)); | 26 ContentHandlerFactory::GetInterfaceRequestHandler(this)); |
| 28 return true; | 27 return true; |
| 29 } | 28 } |
| 30 | 29 |
| 31 // Overridden from ContentHandlerFactory::ManagedDelegate: | 30 // Overridden from ContentHandlerFactory::ManagedDelegate: |
| 32 scoped_ptr<ContentHandlerFactory::HandledApplicationHolder> | 31 std::unique_ptr<ContentHandlerFactory::HandledApplicationHolder> |
| 33 CreateApplication(InterfaceRequest<Application> application_request, | 32 CreateApplication(InterfaceRequest<Application> application_request, |
| 34 URLResponsePtr response) override { | 33 URLResponsePtr response) override { |
| 35 LOG(INFO) << "RecursiveContentHandler called with url: " << response->url; | 34 LOG(INFO) << "RecursiveContentHandler called with url: " << response->url; |
| 36 auto app = new RecursiveContentHandler(); | 35 auto app = new RecursiveContentHandler(); |
| 37 app->Bind(application_request.Pass()); | 36 app->Bind(application_request.Pass()); |
| 38 return make_handled_factory_holder(app); | 37 return make_handled_factory_holder(app); |
| 39 } | 38 } |
| 40 | 39 |
| 41 DISALLOW_COPY_AND_ASSIGN(RecursiveContentHandler); | 40 DISALLOW_COPY_AND_ASSIGN(RecursiveContentHandler); |
| 42 }; | 41 }; |
| 43 | 42 |
| 44 } // namespace examples | 43 } // namespace examples |
| 45 } // namespace mojo | 44 } // namespace mojo |
| 46 | 45 |
| 47 MojoResult MojoMain(MojoHandle application_request) { | 46 MojoResult MojoMain(MojoHandle application_request) { |
| 48 mojo::ScopedChromiumInit init; | 47 mojo::ScopedChromiumInit init; |
| 49 mojo::examples::RecursiveContentHandler recursive_content_handler; | 48 mojo::examples::RecursiveContentHandler recursive_content_handler; |
| 50 return mojo::RunApplication(application_request, &recursive_content_handler); | 49 return mojo::RunApplication(application_request, &recursive_content_handler); |
| 51 } | 50 } |
| OLD | NEW |