| 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 #ifndef MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_ | 5 #ifndef MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_ |
| 6 #define MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_ | 6 #define MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "mojo/public/cpp/application/interface_factory.h" | 9 #include "mojo/public/cpp/application/interface_factory.h" |
| 10 #include "mojo/public/interfaces/application/shell.mojom.h" | 10 #include "mojo/public/interfaces/application/shell.mojom.h" |
| 11 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.
h" | 11 #include "mojo/services/content_handler/public/interfaces/content_handler.mojom.
h" |
| 12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mojo { |
| 15 | 15 |
| 16 class ContentHandlerFactory : public InterfaceFactory<ContentHandler> { | 16 class ContentHandlerFactory : public InterfaceFactory<ContentHandler> { |
| 17 public: | 17 public: |
| 18 class HandledApplicationHolder { | 18 class HandledApplicationHolder { |
| 19 public: | 19 public: |
| 20 virtual ~HandledApplicationHolder() {} | 20 virtual ~HandledApplicationHolder() {} |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 class Delegate { | 23 class Delegate { |
| 24 public: | 24 public: |
| 25 virtual ~Delegate() {} | 25 virtual ~Delegate() {} |
| 26 // Implement this method to create the Application. This method will be | 26 // Implement this method to create the Application. This method will be |
| 27 // called on a new thread. Leaving this method will quit the application. | 27 // called on a new thread. Leaving this method will quit the application. |
| 28 virtual void RunApplication(ShellPtr shell, URLResponsePtr response) = 0; | 28 virtual void RunApplication( |
| 29 InterfaceRequest<Application> application_request, |
| 30 URLResponsePtr response) = 0; |
| 29 }; | 31 }; |
| 30 | 32 |
| 31 class ManagedDelegate : public Delegate { | 33 class ManagedDelegate : public Delegate { |
| 32 public: | 34 public: |
| 33 virtual ~ManagedDelegate() {} | 35 virtual ~ManagedDelegate() {} |
| 34 // Implement this method to create the Application for the given content. | 36 // Implement this method to create the Application for the given content. |
| 35 // This method will be called on a new thread. The application will be run | 37 // This method will be called on a new thread. The application will be run |
| 36 // on this new thread, and the returned value will be kept alive until the | 38 // on this new thread, and the returned value will be kept alive until the |
| 37 // application ends. | 39 // application ends. |
| 38 virtual scoped_ptr<HandledApplicationHolder> CreateApplication( | 40 virtual scoped_ptr<HandledApplicationHolder> CreateApplication( |
| 39 ShellPtr shell, | 41 InterfaceRequest<Application> application_request, |
| 40 URLResponsePtr response) = 0; | 42 URLResponsePtr response) = 0; |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 void RunApplication(ShellPtr shell, URLResponsePtr response) override; | 45 void RunApplication(InterfaceRequest<Application> application_request, |
| 46 URLResponsePtr response) override; |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 explicit ContentHandlerFactory(Delegate* delegate); | 49 explicit ContentHandlerFactory(Delegate* delegate); |
| 47 virtual ~ContentHandlerFactory(); | 50 virtual ~ContentHandlerFactory(); |
| 48 | 51 |
| 49 private: | 52 private: |
| 50 // From InterfaceFactory: | 53 // From InterfaceFactory: |
| 51 void Create(ApplicationConnection* connection, | 54 void Create(ApplicationConnection* connection, |
| 52 InterfaceRequest<ContentHandler> request) override; | 55 InterfaceRequest<ContentHandler> request) override; |
| 53 | 56 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 68 | 71 |
| 69 template <class A> | 72 template <class A> |
| 70 scoped_ptr<ContentHandlerFactory::HandledApplicationHolder> | 73 scoped_ptr<ContentHandlerFactory::HandledApplicationHolder> |
| 71 make_handled_factory_holder(A* value) { | 74 make_handled_factory_holder(A* value) { |
| 72 return make_scoped_ptr(new HandledApplicationHolderImpl<A>(value)); | 75 return make_scoped_ptr(new HandledApplicationHolderImpl<A>(value)); |
| 73 } | 76 } |
| 74 | 77 |
| 75 } // namespace mojo | 78 } // namespace mojo |
| 76 | 79 |
| 77 #endif // MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_ | 80 #endif // MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_ |
| OLD | NEW |