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

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

Issue 1565343003: Move mojo/application/public -> mojo/shell/public (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fetcher
Patch Set: . Created 4 years, 11 months 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_PUBLIC_CPP_CONTENT_HANDLER_FACTORY_H_
6 #define MOJO_APPLICATION_PUBLIC_CPP_CONTENT_HANDLER_FACTORY_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "mojo/application/public/cpp/interface_factory.h"
11 #include "mojo/application/public/interfaces/content_handler.mojom.h"
12 #include "mojo/application/public/interfaces/shell.mojom.h"
13 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
14
15 namespace mojo {
16
17 class ContentHandlerFactory : public InterfaceFactory<ContentHandler> {
18 public:
19 class HandledApplicationHolder {
20 public:
21 virtual ~HandledApplicationHolder() {}
22 };
23
24 class Delegate {
25 public:
26 virtual ~Delegate() {}
27 // Implement this method to create the Application. This method will be
28 // called on a new thread. Leaving this method will quit the application.
29 virtual void RunApplication(
30 InterfaceRequest<Application> application_request,
31 URLResponsePtr response) = 0;
32 };
33
34 class ManagedDelegate : public Delegate {
35 public:
36 ~ManagedDelegate() override {}
37 // Implement this method to create the Application for the given content.
38 // This method will be called on a new thread. The application will be run
39 // on this new thread, and the returned value will be kept alive until the
40 // application ends.
41 virtual scoped_ptr<HandledApplicationHolder> CreateApplication(
42 InterfaceRequest<Application> application_request,
43 URLResponsePtr response) = 0;
44
45 private:
46 void RunApplication(InterfaceRequest<Application> application_request,
47 URLResponsePtr response) override;
48 };
49
50 explicit ContentHandlerFactory(Delegate* delegate);
51 ~ContentHandlerFactory() override;
52
53 private:
54 // From InterfaceFactory:
55 void Create(ApplicationConnection* connection,
56 InterfaceRequest<ContentHandler> request) override;
57
58 Delegate* delegate_;
59
60 DISALLOW_COPY_AND_ASSIGN(ContentHandlerFactory);
61 };
62
63 template <class A>
64 class HandledApplicationHolderImpl
65 : public ContentHandlerFactory::HandledApplicationHolder {
66 public:
67 explicit HandledApplicationHolderImpl(A* value) : value_(value) {}
68
69 private:
70 scoped_ptr<A> value_;
71 };
72
73 template <class A>
74 scoped_ptr<ContentHandlerFactory::HandledApplicationHolder>
75 make_handled_factory_holder(A* value) {
76 return make_scoped_ptr(new HandledApplicationHolderImpl<A>(value));
77 }
78
79 } // namespace mojo
80
81 #endif // MOJO_APPLICATION_PUBLIC_CPP_CONTENT_HANDLER_FACTORY_H_
OLDNEW
« no previous file with comments | « mojo/application/public/cpp/connect.h ('k') | mojo/application/public/cpp/initialize_base_and_icu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698