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

Unified Diff: components/native_viewport/native_viewport_application_delegate.cc

Issue 1135703004: core_services: add native_viewport_service on non-android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/native_viewport/native_viewport_application_delegate.cc
diff --git a/components/native_viewport/native_viewport_application_delegate.cc b/components/native_viewport/native_viewport_application_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4f247c7a5c55a20feedee52352257dc7d6b7d56a
--- /dev/null
+++ b/components/native_viewport/native_viewport_application_delegate.cc
@@ -0,0 +1,61 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/native_viewport/native_viewport_application_delegate.h"
+
+#include "base/command_line.h"
+#include "components/native_viewport/native_viewport_impl.h"
+#include "components/native_viewport/public/cpp/args.h"
+#include "mojo/application/public/cpp/application_connection.h"
+#include "mojo/application/public/cpp/application_impl.h"
+#include "ui/events/event_switches.h"
+#include "ui/gl/gl_surface.h"
+
+namespace native_viewport {
+
+NativeViewportApplicationDelegate::NativeViewportApplicationDelegate()
+ : is_headless_(false) {
+}
+
+NativeViewportApplicationDelegate::~NativeViewportApplicationDelegate() {
+}
+
+void NativeViewportApplicationDelegate::Initialize(
+ mojo::ApplicationImpl* application) {
+ tracing_.Initialize(application);
+
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig);
+ if (!is_headless_) {
+ if (command_line->HasSwitch(mojo::kUseTestConfig))
+ gfx::GLSurface::InitializeOneOffForTests();
+ else
+ gfx::GLSurface::InitializeOneOff();
+ }
+}
+
+bool NativeViewportApplicationDelegate::ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) {
+ connection->AddService<mojo::NativeViewport>(this);
+ connection->AddService<mojo::Gpu>(this);
+ return true;
+}
+
+void NativeViewportApplicationDelegate::Create(
+ mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<mojo::NativeViewport> request) {
+ if (!gpu_state_.get())
+ gpu_state_ = new gles2::GpuState;
+ new NativeViewportImpl(is_headless_, gpu_state_, request.Pass());
+}
+
+void NativeViewportApplicationDelegate::Create(
+ mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<mojo::Gpu> request) {
+ if (!gpu_state_.get())
+ gpu_state_ = new gles2::GpuState;
+ new gles2::GpuImpl(request.Pass(), gpu_state_);
+}
+
+} // namespace native_viewport
« no previous file with comments | « components/native_viewport/native_viewport_application_delegate.h ('k') | mandoline/app/core_services_initialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698