[Chromoting] Remove check for out/Release dir in build-webapp.py
[chromium-blink-merge.git] / mojo / application / content_handler_factory.h
blobaabba6f53a81e16f938a2be447160b605a0e2a54
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
3 // found in the LICENSE file.
5 #ifndef MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_
6 #define MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "mojo/public/cpp/application/interface_factory.h"
10 #include "mojo/public/interfaces/application/shell.mojom.h"
11 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
12 #include "third_party/mojo_services/src/content_handler/public/interfaces/content_handler.mojom.h"
14 namespace mojo {
16 class ContentHandlerFactory : public InterfaceFactory<ContentHandler> {
17 public:
18 class HandledApplicationHolder {
19 public:
20 virtual ~HandledApplicationHolder() {}
23 class Delegate {
24 public:
25 virtual ~Delegate() {}
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.
28 virtual void RunApplication(
29 InterfaceRequest<Application> application_request,
30 URLResponsePtr response) = 0;
33 class ManagedDelegate : public Delegate {
34 public:
35 ~ManagedDelegate() override {}
36 // Implement this method to create the Application for the given content.
37 // This method will be called on a new thread. The application will be run
38 // on this new thread, and the returned value will be kept alive until the
39 // application ends.
40 virtual scoped_ptr<HandledApplicationHolder> CreateApplication(
41 InterfaceRequest<Application> application_request,
42 URLResponsePtr response) = 0;
44 private:
45 void RunApplication(InterfaceRequest<Application> application_request,
46 URLResponsePtr response) override;
49 explicit ContentHandlerFactory(Delegate* delegate);
50 ~ContentHandlerFactory() override;
52 private:
53 // From InterfaceFactory:
54 void Create(ApplicationConnection* connection,
55 InterfaceRequest<ContentHandler> request) override;
57 Delegate* delegate_;
59 DISALLOW_COPY_AND_ASSIGN(ContentHandlerFactory);
62 template <class A>
63 class HandledApplicationHolderImpl
64 : public ContentHandlerFactory::HandledApplicationHolder {
65 public:
66 explicit HandledApplicationHolderImpl(A* value) : value_(value) {}
68 private:
69 scoped_ptr<A> value_;
72 template <class A>
73 scoped_ptr<ContentHandlerFactory::HandledApplicationHolder>
74 make_handled_factory_holder(A* value) {
75 return make_scoped_ptr(new HandledApplicationHolderImpl<A>(value));
78 } // namespace mojo
80 #endif // MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_