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

Side by Side Diff: mojo/services/html_viewer/html_viewer.cc

Issue 558343004: Compositor bindings for mojo html_viewer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo_view_manager_surface
Patch Set: Add missing m/s/p/cpp/v_m -> m/s/p/cpp/surfaces dep in GN Created 6 years, 3 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
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 #include "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/threading/thread.h"
6 #include "mojo/public/c/system/main.h" 7 #include "mojo/public/c/system/main.h"
7 #include "mojo/public/cpp/application/application_connection.h" 8 #include "mojo/public/cpp/application/application_connection.h"
8 #include "mojo/public/cpp/application/application_delegate.h" 9 #include "mojo/public/cpp/application/application_delegate.h"
9 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
10 #include "mojo/public/cpp/application/application_runner_chromium.h" 11 #include "mojo/public/cpp/application/application_runner_chromium.h"
11 #include "mojo/public/cpp/application/interface_factory_impl.h" 12 #include "mojo/public/cpp/application/interface_factory_impl.h"
12 #include "mojo/services/html_viewer/blink_platform_impl.h" 13 #include "mojo/services/html_viewer/blink_platform_impl.h"
13 #include "mojo/services/html_viewer/html_document_view.h" 14 #include "mojo/services/html_viewer/html_document_view.h"
14 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom. h" 15 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom. h"
15 #include "third_party/WebKit/public/web/WebKit.h" 16 #include "third_party/WebKit/public/web/WebKit.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 19
19 class HTMLViewer; 20 class HTMLViewer;
20 21
21 class ContentHandlerImpl : public InterfaceImpl<ContentHandler> { 22 class ContentHandlerImpl : public InterfaceImpl<ContentHandler> {
22 public: 23 public:
23 explicit ContentHandlerImpl(Shell* shell) : shell_(shell) {} 24 ContentHandlerImpl(Shell* shell,
25 scoped_refptr<base::MessageLoopProxy> compositor_thread)
26 : shell_(shell), compositor_thread_(compositor_thread) {}
24 virtual ~ContentHandlerImpl() {} 27 virtual ~ContentHandlerImpl() {}
25 28
26 private: 29 private:
27 // Overridden from ContentHandler: 30 // Overridden from ContentHandler:
28 virtual void OnConnect( 31 virtual void OnConnect(
29 const mojo::String& url, 32 const mojo::String& url,
30 URLResponsePtr response, 33 URLResponsePtr response,
31 InterfaceRequest<ServiceProvider> service_provider_request) OVERRIDE { 34 InterfaceRequest<ServiceProvider> service_provider_request) OVERRIDE {
32 new HTMLDocumentView( 35 new HTMLDocumentView(response.Pass(),
33 response.Pass(), service_provider_request.Pass(), shell_); 36 service_provider_request.Pass(),
37 shell_,
38 compositor_thread_);
34 } 39 }
35 40
36 Shell* shell_; 41 Shell* shell_;
42 scoped_refptr<base::MessageLoopProxy> compositor_thread_;
37 43
38 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); 44 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl);
39 }; 45 };
40 46
41 class HTMLViewer : public ApplicationDelegate { 47 class HTMLViewer : public ApplicationDelegate,
48 public InterfaceFactory<ContentHandler> {
42 public: 49 public:
43 HTMLViewer() {} 50 HTMLViewer() : compositor_thread_("compositor thread") {}
44 51
45 virtual ~HTMLViewer() { blink::shutdown(); } 52 virtual ~HTMLViewer() { blink::shutdown(); }
46 53
47 private: 54 private:
48 // Overridden from ApplicationDelegate: 55 // Overridden from ApplicationDelegate:
49 virtual void Initialize(ApplicationImpl* app) OVERRIDE { 56 virtual void Initialize(ApplicationImpl* app) OVERRIDE {
50 content_handler_factory_.reset( 57 shell_ = app->shell();
51 new InterfaceFactoryImplWithContext<ContentHandlerImpl, Shell>(
52 app->shell()));
53 blink_platform_impl_.reset(new BlinkPlatformImpl(app)); 58 blink_platform_impl_.reset(new BlinkPlatformImpl(app));
54 blink::initialize(blink_platform_impl_.get()); 59 blink::initialize(blink_platform_impl_.get());
60 compositor_thread_.Start();
55 } 61 }
56 62
57 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) 63 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
58 OVERRIDE { 64 OVERRIDE {
59 connection->AddService(content_handler_factory_.get()); 65 connection->AddService(this);
60 return true; 66 return true;
61 } 67 }
62 68
69 // Overridden from InterfaceFactory<ContentHandler>
70 virtual void Create(ApplicationConnection* connection,
71 InterfaceRequest<ContentHandler> request) OVERRIDE {
72 BindToRequest(
73 new ContentHandlerImpl(shell_, compositor_thread_.message_loop_proxy()),
74 &request);
75 }
76
63 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_; 77 scoped_ptr<BlinkPlatformImpl> blink_platform_impl_;
64 scoped_ptr<InterfaceFactoryImplWithContext<ContentHandlerImpl, Shell> > 78 Shell* shell_;
65 content_handler_factory_; 79 base::Thread compositor_thread_;
66 80
67 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); 81 DISALLOW_COPY_AND_ASSIGN(HTMLViewer);
68 }; 82 };
69 83
70 } // namespace mojo 84 } // namespace mojo
71 85
72 MojoResult MojoMain(MojoHandle shell_handle) { 86 MojoResult MojoMain(MojoHandle shell_handle) {
73 mojo::ApplicationRunnerChromium runner(new mojo::HTMLViewer); 87 mojo::ApplicationRunnerChromium runner(new mojo::HTMLViewer);
74 return runner.Run(shell_handle); 88 return runner.Run(shell_handle);
75 } 89 }
OLDNEW
« no previous file with comments | « mojo/services/html_viewer/html_document_view.cc ('k') | mojo/services/html_viewer/weblayertreeview_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698