OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_ | |
6 #define MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_ | |
7 | |
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/public/interfaces/content_handler/content_handler.mojom. h" | |
12 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | |
13 | |
14 namespace mojo { | |
15 | |
16 class ContentHandlerFactory : public InterfaceFactory<ContentHandler> { | |
17 public: | |
18 class HandledApplicationHolder { | |
19 public: | |
20 virtual ~HandledApplicationHolder() {} | |
21 }; | |
22 | |
23 class Delegate { | |
24 public: | |
25 virtual ~Delegate() {} | |
26 // Implement this method to create the Application for the given | |
27 // content. The application will be run on its own thread, and the returned | |
Aaron Boodman
2014/10/31 16:40:46
Nit: Clarify in this comment that this method is a
qsr
2014/10/31 17:22:32
Done.
| |
28 // value will be kept alive until the application ends. | |
29 virtual scoped_ptr<HandledApplicationHolder> CreateApplication( | |
30 ShellPtr shell, | |
31 URLResponsePtr response) = 0; | |
32 }; | |
33 | |
34 explicit ContentHandlerFactory(Delegate* delegate); | |
35 virtual ~ContentHandlerFactory(); | |
36 | |
37 private: | |
38 // From InterfaceFactory: | |
39 virtual void Create(ApplicationConnection* connection, | |
40 InterfaceRequest<ContentHandler> request) override; | |
41 | |
42 Delegate* delegate_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(ContentHandlerFactory); | |
45 }; | |
46 | |
47 template <class A> | |
48 class HandledApplicationHolderImpl | |
49 : public ContentHandlerFactory::HandledApplicationHolder { | |
50 public: | |
51 explicit HandledApplicationHolderImpl(A* value) : value_(value) {} | |
52 | |
53 private: | |
54 scoped_ptr<A> value_; | |
55 }; | |
56 | |
57 template <class A> | |
58 scoped_ptr<ContentHandlerFactory::HandledApplicationHolder> | |
59 make_handled_factory_holder(A* value) { | |
60 return make_scoped_ptr(new HandledApplicationHolderImpl<A>(value)); | |
61 } | |
62 | |
63 } // namespace mojo | |
64 | |
65 #endif // MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_ | |
OLD | NEW |