summaryrefslogtreecommitdiffstats
path: root/mojo/services/view_manager/main.cc
blob: 7754a1ee8bee7e7f65eabb0a4f25caa35e34f82f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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 "base/at_exit.h"
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "mojo/public/cpp/shell/application.h"
#include "mojo/services/view_manager/root_node_manager.h"
#include "mojo/services/view_manager/view_manager_connection.h"

#if defined(WIN32)
#if !defined(CDECL)
#define CDECL __cdecl)
#endif
#define VIEW_MANAGER_EXPORT __declspec(dllexport)
#else
#define CDECL
#define VIEW_MANAGER_EXPORT __attribute__((visibility("default")))
#endif

extern "C" VIEW_MANAGER_EXPORT MojoResult CDECL MojoMain(
    MojoHandle shell_handle) {
  CommandLine::Init(0, NULL);
  base::AtExitManager at_exit;
  base::MessageLoop loop;
  mojo::Application app(shell_handle);
  mojo::services::view_manager::RootNodeManager root_node_manager(app.shell());
  app.AddServiceConnector(
      new mojo::ServiceConnector<
          mojo::services::view_manager::ViewManagerConnection,
          mojo::services::view_manager::RootNodeManager>(&root_node_manager));
  loop.Run();

  return MOJO_RESULT_OK;
}