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

Side by Side Diff: components/mus/mus_app.cc

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

Powered by Google App Engine
This is Rietveld 408576698