Roll src/third_party/skia 43315bb:4b195e5
[chromium-blink-merge.git] / mojo / runner / android / native_viewport_application_loader.cc
blob55979c7665df287ee3b27194ec3ac2bcf7d9e4ad
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.
5 #include "mojo/runner/android/native_viewport_application_loader.h"
7 #include "components/view_manager/gles2/gpu_state.h"
8 #include "components/view_manager/native_viewport/native_viewport_impl.h"
9 #include "mojo/application/public/cpp/application_impl.h"
11 namespace mojo {
12 namespace runner {
14 NativeViewportApplicationLoader::NativeViewportApplicationLoader() {
17 NativeViewportApplicationLoader::~NativeViewportApplicationLoader() {
20 void NativeViewportApplicationLoader::Load(
21 const GURL& url,
22 InterfaceRequest<Application> application_request) {
23 DCHECK(application_request.is_pending());
24 app_.reset(new ApplicationImpl(this, application_request.Pass()));
27 bool NativeViewportApplicationLoader::ConfigureIncomingConnection(
28 ApplicationConnection* connection) {
29 connection->AddService<NativeViewport>(this);
30 connection->AddService<Gpu>(this);
31 return true;
34 void NativeViewportApplicationLoader::Create(
35 ApplicationConnection* connection,
36 InterfaceRequest<NativeViewport> request) {
37 if (!gpu_state_)
38 gpu_state_ = new gles2::GpuState;
39 // Pass a null AppRefCount because on Android the NativeViewPort app must
40 // live on the main thread and we don't want to exit that when all the native
41 // viewports are gone.
42 new native_viewport::NativeViewportImpl(
43 false, gpu_state_, request.Pass(),
44 make_scoped_ptr<mojo::AppRefCount>(nullptr));
47 void NativeViewportApplicationLoader::Create(ApplicationConnection* connection,
48 InterfaceRequest<Gpu> request) {
49 if (!gpu_state_)
50 gpu_state_ = new gles2::GpuState;
51 new gles2::GpuImpl(request.Pass(), gpu_state_);
54 } // namespace runner
55 } // namespace mojo