Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: mojo/application/content_handler_factory.h

Issue 687273002: mojo: Update content handler API (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Add missing comment Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/application/BUILD.gn ('k') | mojo/application/content_handler_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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. This method will be called on a new thread. The application will
28 // be run on this new thread, and the returned
29 // value will be kept alive until the application ends.
30 virtual scoped_ptr<HandledApplicationHolder> CreateApplication(
31 ShellPtr shell,
32 URLResponsePtr response) = 0;
33 };
34
35 explicit ContentHandlerFactory(Delegate* delegate);
36 virtual ~ContentHandlerFactory();
37
38 private:
39 // From InterfaceFactory:
40 virtual void Create(ApplicationConnection* connection,
41 InterfaceRequest<ContentHandler> request) override;
42
43 Delegate* delegate_;
44
45 DISALLOW_COPY_AND_ASSIGN(ContentHandlerFactory);
46 };
47
48 template <class A>
49 class HandledApplicationHolderImpl
50 : public ContentHandlerFactory::HandledApplicationHolder {
51 public:
52 explicit HandledApplicationHolderImpl(A* value) : value_(value) {}
53
54 private:
55 scoped_ptr<A> value_;
56 };
57
58 template <class A>
59 scoped_ptr<ContentHandlerFactory::HandledApplicationHolder>
60 make_handled_factory_holder(A* value) {
61 return make_scoped_ptr(new HandledApplicationHolderImpl<A>(value));
62 }
63
64 } // namespace mojo
65
66 #endif // MOJO_APPLICATION_CONTENT_HANDLER_FACTORY_H_
OLDNEW
« no previous file with comments | « mojo/application/BUILD.gn ('k') | mojo/application/content_handler_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698