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

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

Issue 687273002: mojo: Update content handler API (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review 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
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_H_
6 #define MOJO_APPLICATION_CONTENT_HANDLER_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 {
qsr 2014/10/31 12:10:44 I don't really like this, but I'm a little bit out
Aaron Boodman 2014/10/31 16:40:46 You could have apps be responsible for deleting th
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
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_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698