Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / mojo / public / cpp / application / lib / mojo_main_standalone.cc
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 "mojo/public/cpp/application/application_delegate.h"
6 #include "mojo/public/cpp/application/application_impl.h"
7 #include "mojo/public/cpp/environment/environment.h"
8 #include "mojo/public/cpp/utility/run_loop.h"
9
10 extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain(
11     MojoHandle shell_handle) {
12   mojo::Environment env;
13   mojo::ApplicationDelegate* delegate = NULL;
14   {
15     // We have to shut down the RunLoop before destroying the
16     // ApplicationDelegate.
17     mojo::RunLoop loop;
18     delegate = mojo::ApplicationDelegate::Create();
19     {
20       mojo::ApplicationImpl app(delegate);
21       app.BindShell(shell_handle);
22       loop.Run();
23     }
24   }
25   delete delegate;
26
27   return MOJO_RESULT_OK;
28 }