| OLD | NEW |
| 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 "components/view_manager/view_manager_app.h" | 5 #include "components/mus/view_manager_app.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "components/view_manager/client_connection.h" | 9 #include "components/mus/client_connection.h" |
| 10 #include "components/view_manager/connection_manager.h" | 10 #include "components/mus/connection_manager.h" |
| 11 #include "components/view_manager/gles2/gpu_impl.h" | 11 #include "components/mus/gles2/gpu_impl.h" |
| 12 #include "components/view_manager/public/cpp/args.h" | 12 #include "components/mus/public/cpp/args.h" |
| 13 #include "components/view_manager/surfaces/surfaces_scheduler.h" | 13 #include "components/mus/surfaces/surfaces_scheduler.h" |
| 14 #include "components/view_manager/view_tree_host_connection.h" | 14 #include "components/mus/view_tree_host_connection.h" |
| 15 #include "components/view_manager/view_tree_host_impl.h" | 15 #include "components/mus/view_tree_host_impl.h" |
| 16 #include "components/view_manager/view_tree_impl.h" | 16 #include "components/mus/view_tree_impl.h" |
| 17 #include "mojo/application/public/cpp/application_connection.h" | 17 #include "mojo/application/public/cpp/application_connection.h" |
| 18 #include "mojo/application/public/cpp/application_impl.h" | 18 #include "mojo/application/public/cpp/application_impl.h" |
| 19 #include "mojo/application/public/cpp/application_runner.h" | 19 #include "mojo/application/public/cpp/application_runner.h" |
| 20 #include "mojo/common/tracing_impl.h" | 20 #include "mojo/common/tracing_impl.h" |
| 21 #include "third_party/mojo/src/mojo/public/c/system/main.h" | 21 #include "third_party/mojo/src/mojo/public/c/system/main.h" |
| 22 #include "ui/events/event_switches.h" | 22 #include "ui/events/event_switches.h" |
| 23 #include "ui/events/platform/platform_event_source.h" | 23 #include "ui/events/platform/platform_event_source.h" |
| 24 #include "ui/gl/gl_surface.h" | 24 #include "ui/gl/gl_surface.h" |
| 25 #include "ui/gl/test/gl_surface_test_support.h" | 25 #include "ui/gl/test/gl_surface_test_support.h" |
| 26 | 26 |
| 27 #if defined(USE_X11) | 27 #if defined(USE_X11) |
| 28 #include <X11/Xlib.h> | 28 #include <X11/Xlib.h> |
| 29 #include "ui/platform_window/x11/x11_window.h" | 29 #include "ui/platform_window/x11/x11_window.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 using mojo::ApplicationConnection; | 32 using mojo::ApplicationConnection; |
| 33 using mojo::ApplicationImpl; | 33 using mojo::ApplicationImpl; |
| 34 using mojo::Gpu; | 34 using mojo::Gpu; |
| 35 using mojo::InterfaceRequest; | 35 using mojo::InterfaceRequest; |
| 36 using mojo::ViewTreeHostFactory; | 36 using mojo::ViewTreeHostFactory; |
| 37 | 37 |
| 38 namespace view_manager { | 38 namespace view_manager { |
| 39 | 39 |
| 40 ViewManagerApp::ViewManagerApp() | 40 ViewManagerApp::ViewManagerApp() : app_impl_(nullptr), is_headless_(false) {} |
| 41 : app_impl_(nullptr), | |
| 42 is_headless_(false) { | |
| 43 } | |
| 44 | 41 |
| 45 ViewManagerApp::~ViewManagerApp() { | 42 ViewManagerApp::~ViewManagerApp() { |
| 46 if (gpu_state_) | 43 if (gpu_state_) |
| 47 gpu_state_->StopControlThread(); | 44 gpu_state_->StopControlThread(); |
| 48 // Destroy |connection_manager_| first, since it depends on |event_source_|. | 45 // Destroy |connection_manager_| first, since it depends on |event_source_|. |
| 49 connection_manager_.reset(); | 46 connection_manager_.reset(); |
| 50 } | 47 } |
| 51 | 48 |
| 52 void ViewManagerApp::Initialize(ApplicationImpl* app) { | 49 void ViewManagerApp::Initialize(ApplicationImpl* app) { |
| 53 app_impl_ = app; | 50 app_impl_ = app; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 101 |
| 105 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( | 102 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( |
| 106 ConnectionManager* connection_manager, | 103 ConnectionManager* connection_manager, |
| 107 mojo::InterfaceRequest<mojo::ViewTree> tree_request, | 104 mojo::InterfaceRequest<mojo::ViewTree> tree_request, |
| 108 mojo::ConnectionSpecificId creator_id, | 105 mojo::ConnectionSpecificId creator_id, |
| 109 const ViewId& root_id, | 106 const ViewId& root_id, |
| 110 mojo::ViewTreeClientPtr client) { | 107 mojo::ViewTreeClientPtr client) { |
| 111 scoped_ptr<ViewTreeImpl> service( | 108 scoped_ptr<ViewTreeImpl> service( |
| 112 new ViewTreeImpl(connection_manager, creator_id, root_id)); | 109 new ViewTreeImpl(connection_manager, creator_id, root_id)); |
| 113 return new DefaultClientConnection(service.Pass(), connection_manager, | 110 return new DefaultClientConnection(service.Pass(), connection_manager, |
| 114 tree_request.Pass(), | 111 tree_request.Pass(), client.Pass()); |
| 115 client.Pass()); | |
| 116 } | 112 } |
| 117 | 113 |
| 118 void ViewManagerApp::Create(ApplicationConnection* connection, | 114 void ViewManagerApp::Create(ApplicationConnection* connection, |
| 119 InterfaceRequest<ViewTreeHostFactory> request) { | 115 InterfaceRequest<ViewTreeHostFactory> request) { |
| 120 factory_bindings_.AddBinding(this, request.Pass()); | 116 factory_bindings_.AddBinding(this, request.Pass()); |
| 121 } | 117 } |
| 122 | 118 |
| 123 void ViewManagerApp::Create( | 119 void ViewManagerApp::Create(mojo::ApplicationConnection* connection, |
| 124 mojo::ApplicationConnection* connection, | 120 mojo::InterfaceRequest<Gpu> request) { |
| 125 mojo::InterfaceRequest<Gpu> request) { | |
| 126 if (!gpu_state_.get()) | 121 if (!gpu_state_.get()) |
| 127 gpu_state_ = new gles2::GpuState; | 122 gpu_state_ = new gles2::GpuState; |
| 128 new gles2::GpuImpl(request.Pass(), gpu_state_); | 123 new gles2::GpuImpl(request.Pass(), gpu_state_); |
| 129 } | 124 } |
| 130 | 125 |
| 131 void ViewManagerApp::CreateViewTreeHost( | 126 void ViewManagerApp::CreateViewTreeHost( |
| 132 mojo::InterfaceRequest<mojo::ViewTreeHost> host, | 127 mojo::InterfaceRequest<mojo::ViewTreeHost> host, |
| 133 mojo::ViewTreeHostClientPtr host_client, | 128 mojo::ViewTreeHostClientPtr host_client, |
| 134 mojo::ViewTreeClientPtr tree_client) { | 129 mojo::ViewTreeClientPtr tree_client) { |
| 135 DCHECK(connection_manager_.get()); | 130 DCHECK(connection_manager_.get()); |
| 136 | 131 |
| 137 // TODO(fsamuel): We need to make sure that only the window manager can create | 132 // TODO(fsamuel): We need to make sure that only the window manager can create |
| 138 // new roots. | 133 // new roots. |
| 139 ViewTreeHostImpl* host_impl = new ViewTreeHostImpl( | 134 ViewTreeHostImpl* host_impl = new ViewTreeHostImpl( |
| 140 host_client.Pass(), connection_manager_.get(), is_headless_, app_impl_, | 135 host_client.Pass(), connection_manager_.get(), is_headless_, app_impl_, |
| 141 gpu_state_, surfaces_state_); | 136 gpu_state_, surfaces_state_); |
| 142 | 137 |
| 143 // ViewTreeHostConnection manages its own lifetime. | 138 // ViewTreeHostConnection manages its own lifetime. |
| 144 host_impl->Init(new ViewTreeHostConnectionImpl( | 139 host_impl->Init(new ViewTreeHostConnectionImpl( |
| 145 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(), | 140 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(), |
| 146 connection_manager_.get())); | 141 connection_manager_.get())); |
| 147 } | 142 } |
| 148 | 143 |
| 149 } // namespace view_manager | 144 } // namespace view_manager |
| OLD | NEW |