| 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/mus/view_manager_app.h" | 5 #include "components/mus/mus_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/mus/client_connection.h" | 9 #include "components/mus/client_connection.h" |
| 10 #include "components/mus/connection_manager.h" | 10 #include "components/mus/connection_manager.h" |
| 11 #include "components/mus/gles2/gpu_impl.h" | 11 #include "components/mus/gles2/gpu_impl.h" |
| 12 #include "components/mus/public/cpp/args.h" | 12 #include "components/mus/public/cpp/args.h" |
| 13 #include "components/mus/surfaces/surfaces_scheduler.h" | 13 #include "components/mus/surfaces/surfaces_scheduler.h" |
| 14 #include "components/mus/view_tree_host_connection.h" | 14 #include "components/mus/view_tree_host_connection.h" |
| 15 #include "components/mus/view_tree_host_impl.h" | 15 #include "components/mus/view_tree_host_impl.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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 mus { |
| 39 | 39 |
| 40 ViewManagerApp::ViewManagerApp() : app_impl_(nullptr), is_headless_(false) {} | 40 MandolineUIServicesApp::MandolineUIServicesApp() |
| 41 : app_impl_(nullptr), is_headless_(false) {} |
| 41 | 42 |
| 42 ViewManagerApp::~ViewManagerApp() { | 43 MandolineUIServicesApp::~MandolineUIServicesApp() { |
| 43 if (gpu_state_) | 44 if (gpu_state_) |
| 44 gpu_state_->StopControlThread(); | 45 gpu_state_->StopControlThread(); |
| 45 // Destroy |connection_manager_| first, since it depends on |event_source_|. | 46 // Destroy |connection_manager_| first, since it depends on |event_source_|. |
| 46 connection_manager_.reset(); | 47 connection_manager_.reset(); |
| 47 } | 48 } |
| 48 | 49 |
| 49 void ViewManagerApp::Initialize(ApplicationImpl* app) { | 50 void MandolineUIServicesApp::Initialize(ApplicationImpl* app) { |
| 50 app_impl_ = app; | 51 app_impl_ = app; |
| 51 tracing_.Initialize(app); | 52 tracing_.Initialize(app); |
| 52 surfaces_state_ = new surfaces::SurfacesState; | 53 surfaces_state_ = new SurfacesState; |
| 53 | 54 |
| 54 #if !defined(OS_ANDROID) | 55 #if !defined(OS_ANDROID) |
| 55 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 56 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 56 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig); | 57 is_headless_ = command_line->HasSwitch(kUseHeadlessConfig); |
| 57 if (!is_headless_) { | 58 if (!is_headless_) { |
| 58 #if defined(USE_X11) | 59 #if defined(USE_X11) |
| 59 if (command_line->HasSwitch(mojo::kUseX11TestConfig)) { | 60 if (command_line->HasSwitch(kUseX11TestConfig)) { |
| 60 XInitThreads(); | 61 XInitThreads(); |
| 61 ui::test::SetUseOverrideRedirectWindowByDefault(true); | 62 ui::test::SetUseOverrideRedirectWindowByDefault(true); |
| 62 } | 63 } |
| 63 #endif | 64 #endif |
| 64 gfx::GLSurface::InitializeOneOff(); | 65 gfx::GLSurface::InitializeOneOff(); |
| 65 event_source_ = ui::PlatformEventSource::CreateDefault(); | 66 event_source_ = ui::PlatformEventSource::CreateDefault(); |
| 66 } | 67 } |
| 67 #endif | 68 #endif |
| 68 | 69 |
| 69 if (!gpu_state_.get()) | 70 if (!gpu_state_.get()) |
| 70 gpu_state_ = new gles2::GpuState; | 71 gpu_state_ = new GpuState; |
| 71 connection_manager_.reset(new ConnectionManager(this, surfaces_state_)); | 72 connection_manager_.reset(new ConnectionManager(this, surfaces_state_)); |
| 72 } | 73 } |
| 73 | 74 |
| 74 bool ViewManagerApp::ConfigureIncomingConnection( | 75 bool MandolineUIServicesApp::ConfigureIncomingConnection( |
| 75 ApplicationConnection* connection) { | 76 ApplicationConnection* connection) { |
| 76 // ViewManager | 77 // MandolineUIServices |
| 77 connection->AddService<ViewTreeHostFactory>(this); | 78 connection->AddService<ViewTreeHostFactory>(this); |
| 78 // GPU | 79 // GPU |
| 79 connection->AddService<Gpu>(this); | 80 connection->AddService<Gpu>(this); |
| 80 return true; | 81 return true; |
| 81 } | 82 } |
| 82 | 83 |
| 83 void ViewManagerApp::OnNoMoreRootConnections() { | 84 void MandolineUIServicesApp::OnNoMoreRootConnections() { |
| 84 app_impl_->Quit(); | 85 app_impl_->Quit(); |
| 85 } | 86 } |
| 86 | 87 |
| 87 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( | 88 ClientConnection* MandolineUIServicesApp::CreateClientConnectionForEmbedAtView( |
| 88 ConnectionManager* connection_manager, | 89 ConnectionManager* connection_manager, |
| 89 mojo::InterfaceRequest<mojo::ViewTree> tree_request, | 90 mojo::InterfaceRequest<mojo::ViewTree> tree_request, |
| 90 mojo::ConnectionSpecificId creator_id, | 91 ConnectionSpecificId creator_id, |
| 91 mojo::URLRequestPtr request, | 92 mojo::URLRequestPtr request, |
| 92 const ViewId& root_id, | 93 const ViewId& root_id, |
| 93 uint32_t policy_bitmask) { | 94 uint32_t policy_bitmask) { |
| 94 mojo::ViewTreeClientPtr client; | 95 mojo::ViewTreeClientPtr client; |
| 95 app_impl_->ConnectToService(request.Pass(), &client); | 96 app_impl_->ConnectToService(request.Pass(), &client); |
| 96 | 97 |
| 97 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl( | 98 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl( |
| 98 connection_manager, creator_id, root_id, policy_bitmask)); | 99 connection_manager, creator_id, root_id, policy_bitmask)); |
| 99 return new DefaultClientConnection(service.Pass(), connection_manager, | 100 return new DefaultClientConnection(service.Pass(), connection_manager, |
| 100 tree_request.Pass(), client.Pass()); | 101 tree_request.Pass(), client.Pass()); |
| 101 } | 102 } |
| 102 | 103 |
| 103 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( | 104 ClientConnection* MandolineUIServicesApp::CreateClientConnectionForEmbedAtView( |
| 104 ConnectionManager* connection_manager, | 105 ConnectionManager* connection_manager, |
| 105 mojo::InterfaceRequest<mojo::ViewTree> tree_request, | 106 mojo::InterfaceRequest<mojo::ViewTree> tree_request, |
| 106 mojo::ConnectionSpecificId creator_id, | 107 ConnectionSpecificId creator_id, |
| 107 const ViewId& root_id, | 108 const ViewId& root_id, |
| 108 uint32_t policy_bitmask, | 109 uint32_t policy_bitmask, |
| 109 mojo::ViewTreeClientPtr client) { | 110 mojo::ViewTreeClientPtr client) { |
| 110 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl( | 111 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl( |
| 111 connection_manager, creator_id, root_id, policy_bitmask)); | 112 connection_manager, creator_id, root_id, policy_bitmask)); |
| 112 return new DefaultClientConnection(service.Pass(), connection_manager, | 113 return new DefaultClientConnection(service.Pass(), connection_manager, |
| 113 tree_request.Pass(), client.Pass()); | 114 tree_request.Pass(), client.Pass()); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void ViewManagerApp::Create(ApplicationConnection* connection, | 117 void MandolineUIServicesApp::Create( |
| 117 InterfaceRequest<ViewTreeHostFactory> request) { | 118 ApplicationConnection* connection, |
| 119 InterfaceRequest<ViewTreeHostFactory> request) { |
| 118 factory_bindings_.AddBinding(this, request.Pass()); | 120 factory_bindings_.AddBinding(this, request.Pass()); |
| 119 } | 121 } |
| 120 | 122 |
| 121 void ViewManagerApp::Create(mojo::ApplicationConnection* connection, | 123 void MandolineUIServicesApp::Create(mojo::ApplicationConnection* connection, |
| 122 mojo::InterfaceRequest<Gpu> request) { | 124 mojo::InterfaceRequest<Gpu> request) { |
| 123 if (!gpu_state_.get()) | 125 if (!gpu_state_.get()) |
| 124 gpu_state_ = new gles2::GpuState; | 126 gpu_state_ = new GpuState; |
| 125 new gles2::GpuImpl(request.Pass(), gpu_state_); | 127 new GpuImpl(request.Pass(), gpu_state_); |
| 126 } | 128 } |
| 127 | 129 |
| 128 void ViewManagerApp::CreateViewTreeHost( | 130 void MandolineUIServicesApp::CreateViewTreeHost( |
| 129 mojo::InterfaceRequest<mojo::ViewTreeHost> host, | 131 mojo::InterfaceRequest<mojo::ViewTreeHost> host, |
| 130 mojo::ViewTreeHostClientPtr host_client, | 132 mojo::ViewTreeHostClientPtr host_client, |
| 131 mojo::ViewTreeClientPtr tree_client) { | 133 mojo::ViewTreeClientPtr tree_client) { |
| 132 DCHECK(connection_manager_.get()); | 134 DCHECK(connection_manager_.get()); |
| 133 | 135 |
| 134 // TODO(fsamuel): We need to make sure that only the window manager can create | 136 // TODO(fsamuel): We need to make sure that only the window manager can create |
| 135 // new roots. | 137 // new roots. |
| 136 ViewTreeHostImpl* host_impl = new ViewTreeHostImpl( | 138 ViewTreeHostImpl* host_impl = new ViewTreeHostImpl( |
| 137 host_client.Pass(), connection_manager_.get(), is_headless_, app_impl_, | 139 host_client.Pass(), connection_manager_.get(), is_headless_, app_impl_, |
| 138 gpu_state_, surfaces_state_); | 140 gpu_state_, surfaces_state_); |
| 139 | 141 |
| 140 // ViewTreeHostConnection manages its own lifetime. | 142 // ViewTreeHostConnection manages its own lifetime. |
| 141 host_impl->Init(new ViewTreeHostConnectionImpl( | 143 host_impl->Init(new ViewTreeHostConnectionImpl( |
| 142 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(), | 144 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(), |
| 143 connection_manager_.get())); | 145 connection_manager_.get())); |
| 144 } | 146 } |
| 145 | 147 |
| 146 } // namespace view_manager | 148 } // namespace mus |
| OLD | NEW |