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

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

Issue 688693004: alternate shape for content handler boilerplate (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 80 cols 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 | « examples/pdf_viewer/pdf_viewer.cc ('k') | mojo/application/content_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_APPLICATION_CONTENT_HANDLER_H_ 5 #ifndef MOJO_APPLICATION_CONTENT_HANDLER_H_
6 #define MOJO_APPLICATION_CONTENT_HANDLER_H_ 6 #define MOJO_APPLICATION_CONTENT_HANDLER_H_
7 7
8 #include "base/callback.h"
9 #include "mojo/public/c/system/core.h" 8 #include "mojo/public/c/system/core.h"
10 #include "mojo/public/cpp/application/application_delegate.h" 9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/interface_factory.h"
11 #include "mojo/public/cpp/bindings/callback.h"
11 #include "mojo/public/interfaces/application/application.mojom.h" 12 #include "mojo/public/interfaces/application/application.mojom.h"
12 #include "mojo/public/interfaces/application/shell.mojom.h" 13 #include "mojo/public/interfaces/application/shell.mojom.h"
14 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom. h"
13 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" 15 #include "mojo/services/public/interfaces/network/url_loader.mojom.h"
14 16
15 namespace mojo { 17 namespace mojo {
16 18
17 class ContentHandlerDelegate : public ApplicationDelegate { 19 class ContentHandlerFactory : public InterfaceFactory<ContentHandler> {
18 public: 20 public:
19 ContentHandlerDelegate() {} 21 class Delegate {
20 // Implement this method to create the ApplicationDelegate for the given 22 public:
21 // content. The application will be run on its own thread. 23 virtual ~Delegate() {}
22 virtual scoped_ptr<mojo::InterfaceImpl<mojo::Application>> CreateApplication( 24 virtual ApplicationDelegate* CreateApplication(URLResponsePtr response) = 0;
23 ShellPtr shell, 25 };
24 URLResponsePtr response) = 0; 26
27 ContentHandlerFactory(Delegate* delegate);
28 virtual ~ContentHandlerFactory();
29
30 virtual void Create(ApplicationConnection* connection,
31 InterfaceRequest<ContentHandler> request) override;
25 32
26 private: 33 private:
27 DISALLOW_COPY_AND_ASSIGN(ContentHandlerDelegate); 34 Delegate* delegate_;
28 }; 35 };
29 36
30 // A utility for running a chromium based mojo Application that expose a content
31 // handler. The typical use case is to use when writing your MojoMain:
32 //
33 // MojoResult MojoMain(MojoHandle shell_handle) {
34 // return mojo::ContentHandlerRunner::Run(shell_handle,
35 // make_scoped_ptr(new MyDelegate));
36 // }
37 class ContentHandlerRunner {
38 public:
39 static MojoResult Run(MojoHandle shell_handle,
40 scoped_ptr<ContentHandlerDelegate> delegate);
41
42 private:
43 ContentHandlerRunner() {}
44 };
45 37
46 } // namespace mojo 38 } // namespace mojo
47 39
48 #endif // MOJO_APPLICATION_CONTENT_HANDLER_H_ 40 #endif // MOJO_APPLICATION_CONTENT_HANDLER_H_
OLDNEW
« no previous file with comments | « examples/pdf_viewer/pdf_viewer.cc ('k') | mojo/application/content_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698