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

Side by Side Diff: components/view_manager/view_manager_app.cc

Issue 1344573002: Mandoline: Rename components/view_manager to components/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 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
(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 #include "components/view_manager/view_manager_app.h"
6
7 #include "base/command_line.h"
8 #include "base/stl_util.h"
9 #include "components/view_manager/client_connection.h"
10 #include "components/view_manager/connection_manager.h"
11 #include "components/view_manager/gles2/gpu_impl.h"
12 #include "components/view_manager/public/cpp/args.h"
13 #include "components/view_manager/surfaces/surfaces_scheduler.h"
14 #include "components/view_manager/view_tree_host_connection.h"
15 #include "components/view_manager/view_tree_host_impl.h"
16 #include "components/view_manager/view_tree_impl.h"
17 #include "mojo/application/public/cpp/application_connection.h"
18 #include "mojo/application/public/cpp/application_impl.h"
19 #include "mojo/application/public/cpp/application_runner.h"
20 #include "mojo/common/tracing_impl.h"
21 #include "third_party/mojo/src/mojo/public/c/system/main.h"
22 #include "ui/events/event_switches.h"
23 #include "ui/events/platform/platform_event_source.h"
24 #include "ui/gl/gl_surface.h"
25 #include "ui/gl/test/gl_surface_test_support.h"
26
27 #if defined(USE_X11)
28 #include <X11/Xlib.h>
29 #include "ui/platform_window/x11/x11_window.h"
30 #endif
31
32 using mojo::ApplicationConnection;
33 using mojo::ApplicationImpl;
34 using mojo::Gpu;
35 using mojo::InterfaceRequest;
36 using mojo::ViewTreeHostFactory;
37
38 namespace view_manager {
39
40 ViewManagerApp::ViewManagerApp()
41 : app_impl_(nullptr),
42 is_headless_(false) {
43 }
44
45 ViewManagerApp::~ViewManagerApp() {
46 if (gpu_state_)
47 gpu_state_->StopControlThread();
48 // Destroy |connection_manager_| first, since it depends on |event_source_|.
49 connection_manager_.reset();
50 }
51
52 void ViewManagerApp::Initialize(ApplicationImpl* app) {
53 app_impl_ = app;
54 tracing_.Initialize(app);
55 surfaces_state_ = new surfaces::SurfacesState;
56
57 #if !defined(OS_ANDROID)
58 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
59 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig);
60 if (!is_headless_) {
61 #if defined(USE_X11)
62 if (command_line->HasSwitch(mojo::kUseX11TestConfig)) {
63 XInitThreads();
64 ui::test::SetUseOverrideRedirectWindowByDefault(true);
65 }
66 #endif
67 gfx::GLSurface::InitializeOneOff();
68 event_source_ = ui::PlatformEventSource::CreateDefault();
69 }
70 #endif
71
72 if (!gpu_state_.get())
73 gpu_state_ = new gles2::GpuState;
74 connection_manager_.reset(new ConnectionManager(this, surfaces_state_));
75 }
76
77 bool ViewManagerApp::ConfigureIncomingConnection(
78 ApplicationConnection* connection) {
79 // ViewManager
80 connection->AddService<ViewTreeHostFactory>(this);
81 // GPU
82 connection->AddService<Gpu>(this);
83 return true;
84 }
85
86 void ViewManagerApp::OnNoMoreRootConnections() {
87 app_impl_->Quit();
88 }
89
90 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView(
91 ConnectionManager* connection_manager,
92 mojo::InterfaceRequest<mojo::ViewTree> tree_request,
93 mojo::ConnectionSpecificId creator_id,
94 mojo::URLRequestPtr request,
95 const ViewId& root_id) {
96 mojo::ViewTreeClientPtr client;
97 app_impl_->ConnectToService(request.Pass(), &client);
98
99 scoped_ptr<ViewTreeImpl> service(
100 new ViewTreeImpl(connection_manager, creator_id, root_id));
101 return new DefaultClientConnection(service.Pass(), connection_manager,
102 tree_request.Pass(), client.Pass());
103 }
104
105 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView(
106 ConnectionManager* connection_manager,
107 mojo::InterfaceRequest<mojo::ViewTree> tree_request,
108 mojo::ConnectionSpecificId creator_id,
109 const ViewId& root_id,
110 mojo::ViewTreeClientPtr client) {
111 scoped_ptr<ViewTreeImpl> service(
112 new ViewTreeImpl(connection_manager, creator_id, root_id));
113 return new DefaultClientConnection(service.Pass(), connection_manager,
114 tree_request.Pass(),
115 client.Pass());
116 }
117
118 void ViewManagerApp::Create(ApplicationConnection* connection,
119 InterfaceRequest<ViewTreeHostFactory> request) {
120 factory_bindings_.AddBinding(this, request.Pass());
121 }
122
123 void ViewManagerApp::Create(
124 mojo::ApplicationConnection* connection,
125 mojo::InterfaceRequest<Gpu> request) {
126 if (!gpu_state_.get())
127 gpu_state_ = new gles2::GpuState;
128 new gles2::GpuImpl(request.Pass(), gpu_state_);
129 }
130
131 void ViewManagerApp::CreateViewTreeHost(
132 mojo::InterfaceRequest<mojo::ViewTreeHost> host,
133 mojo::ViewTreeHostClientPtr host_client,
134 mojo::ViewTreeClientPtr tree_client) {
135 DCHECK(connection_manager_.get());
136
137 // TODO(fsamuel): We need to make sure that only the window manager can create
138 // new roots.
139 ViewTreeHostImpl* host_impl = new ViewTreeHostImpl(
140 host_client.Pass(), connection_manager_.get(), is_headless_, app_impl_,
141 gpu_state_, surfaces_state_);
142
143 // ViewTreeHostConnection manages its own lifetime.
144 host_impl->Init(new ViewTreeHostConnectionImpl(
145 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(),
146 connection_manager_.get()));
147 }
148
149 } // namespace view_manager
OLDNEW
« no previous file with comments | « components/view_manager/view_manager_app.h ('k') | components/view_manager/view_manager_client_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698