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

Side by Side Diff: services/native_viewport/app_delegate.cc

Issue 2011383002: Get rid of {Run,Terminate}MainApplication(), and more ApplicationDelegate conversion. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 4 years, 6 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 | « services/native_viewport/app_delegate.h ('k') | services/native_viewport/main.cc » ('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 "services/native_viewport/app_delegate.h"
6
7 #include <vector>
8
9 #include "gpu/config/gpu_util.h"
10
11 namespace native_viewport {
12
13 NativeViewportAppDelegate::NativeViewportAppDelegate() : is_headless_(false) {}
14
15 NativeViewportAppDelegate::~NativeViewportAppDelegate() {}
16
17 void NativeViewportAppDelegate::InitLogging(
18 mojo::ApplicationImpl* application) {
19 std::vector<const char*> args;
20 for (auto& a : application->args()) {
21 args.push_back(a.c_str());
22 }
23
24 base::CommandLine::Reset();
25 base::CommandLine::Init(args.size(), args.data());
26
27 logging::LoggingSettings settings;
28 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
29 logging::InitLogging(settings);
30 }
31
32 void NativeViewportAppDelegate::Initialize(mojo::ApplicationImpl* application) {
33 application_ = application;
34
35 InitLogging(application);
36 tracing_.Initialize(application->shell(), &application->args());
37
38 // Apply the switch for kTouchEvents to CommandLine (if set). This allows
39 // redirecting the mouse to a touch device on X for testing.
40 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
41 const std::string touch_event_string("--" +
42 std::string(switches::kTouchDevices));
43 auto touch_iter = std::find(application->args().begin(),
44 application->args().end(), touch_event_string);
45 if (touch_iter != application->args().end() &&
46 ++touch_iter != application->args().end()) {
47 command_line->AppendSwitchASCII(touch_event_string, *touch_iter);
48 }
49
50 gpu::ApplyGpuDriverBugWorkarounds(command_line);
51
52 if (application->HasArg(mojo::kUseTestConfig))
53 gfx::GLSurface::InitializeOneOffForTests();
54 else if (application->HasArg(mojo::kUseOSMesa))
55 gfx::GLSurface::InitializeOneOff(gfx::kGLImplementationOSMesaGL);
56 else
57 gfx::GLSurface::InitializeOneOff();
58
59 is_headless_ = application->HasArg(mojo::kUseHeadlessConfig);
60 }
61
62 bool NativeViewportAppDelegate::ConfigureIncomingConnection(
63 mojo::ServiceProviderImpl* service_provider_impl) {
64 service_provider_impl->AddService<mojo::NativeViewport>([this](
65 const mojo::ConnectionContext& connection_context,
66 mojo::InterfaceRequest<mojo::NativeViewport> native_viewport_request) {
67 if (!gpu_state_.get())
68 gpu_state_ = new gles2::GpuState();
69 new NativeViewportImpl(application_->shell(), is_headless_, gpu_state_,
70 native_viewport_request.Pass());
71 });
72
73 service_provider_impl->AddService<mojo::Gpu>(
74 [this](const mojo::ConnectionContext& connection_context,
75 mojo::InterfaceRequest<mojo::Gpu> gpu_request) {
76 if (!gpu_state_.get())
77 gpu_state_ = new gles2::GpuState();
78 new gles2::GpuImpl(gpu_request.Pass(), gpu_state_);
79 });
80
81 return true;
82 }
83
84 } // namespace native_viewport
OLDNEW
« no previous file with comments | « services/native_viewport/app_delegate.h ('k') | services/native_viewport/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698