| Index: services/view_manager/view_manager_app.cc
|
| diff --git a/services/view_manager/view_manager_app.cc b/services/view_manager/view_manager_app.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d4965aac904b8c46018eaed37bad03784a13025b
|
| --- /dev/null
|
| +++ b/services/view_manager/view_manager_app.cc
|
| @@ -0,0 +1,58 @@
|
| +// Copyright 2014 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 "services/view_manager/view_manager_app.h"
|
| +
|
| +#include "base/trace_event/trace_event.h"
|
| +#include "mojo/application/application_runner_chromium.h"
|
| +#include "mojo/common/tracing_impl.h"
|
| +#include "mojo/public/c/system/main.h"
|
| +#include "mojo/public/cpp/application/application_connection.h"
|
| +#include "mojo/public/cpp/application/application_impl.h"
|
| +#include "services/view_manager/view_manager_root_connection.h"
|
| +
|
| +using mojo::ApplicationConnection;
|
| +using mojo::ApplicationImpl;
|
| +using mojo::InterfaceRequest;
|
| +using mojo::ViewManagerService;
|
| +using mojo::WindowManagerInternalClient;
|
| +
|
| +namespace view_manager {
|
| +
|
| +ViewManagerApp::ViewManagerApp() : app_impl_(nullptr) {}
|
| +
|
| +ViewManagerApp::~ViewManagerApp() {}
|
| +
|
| +void ViewManagerApp::Initialize(ApplicationImpl* app) {
|
| + app_impl_ = app;
|
| + tracing_.Initialize(app);
|
| + TRACE_EVENT0("view_manager", __func__);
|
| +}
|
| +
|
| +bool ViewManagerApp::ConfigureIncomingConnection(
|
| + ApplicationConnection* connection) {
|
| + TRACE_EVENT0("view_manager", __func__);
|
| + // We keep a raw pointer in active_root_connections_ in order to be able to
|
| + // close the ViewManagerApp when all outstanding ViewManagerRootConnections
|
| + // are closed. ViewManagerRootConnection manages its own lifetime.
|
| + ViewManagerRootConnection* root_connection =
|
| + new ViewManagerRootConnection(app_impl_, this);
|
| + if (root_connection->Init(connection)) {
|
| + active_root_connections_.insert(root_connection);
|
| + return true;
|
| + } else {
|
| + return false;
|
| + }
|
| +}
|
| +
|
| +void ViewManagerApp::OnCloseViewManagerRootConnection(
|
| + ViewManagerRootConnection* view_manager_root_connection) {
|
| + active_root_connections_.erase(view_manager_root_connection);
|
| +
|
| + if (active_root_connections_.size() == 0) {
|
| + ApplicationImpl::Terminate();
|
| + }
|
| +}
|
| +
|
| +} // namespace view_manager
|
|
|