Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / mojo / public / cpp / application / lib / mojo_main_chromium.cc
index cda7cd0..d8c5e3f 100644 (file)
@@ -5,19 +5,25 @@
 #include "base/at_exit.h"
 #include "base/command_line.h"
 #include "base/message_loop/message_loop.h"
-#include "mojo/public/cpp/application/application.h"
+#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/cpp/application/application_impl.h"
 
 extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain(
-    MojoHandle service_provider_handle) {
+    MojoHandle shell_handle) {
   base::CommandLine::Init(0, NULL);
+#if !defined(COMPONENT_BUILD)
   base::AtExitManager at_exit;
-  base::MessageLoop loop;
-
-  scoped_ptr<mojo::Application> app(mojo::Application::Create());
-  app->BindServiceProvider(
-      mojo::MakeScopedHandle(mojo::MessagePipeHandle(service_provider_handle)));
-  app->Initialize();
-  loop.Run();
+#endif
+  scoped_ptr<mojo::ApplicationDelegate> delegate;
+  {
+    // We have to shut down the MessageLoop before destroying the
+    // ApplicationDelegate.
+    base::MessageLoop loop;
+    delegate.reset(mojo::ApplicationDelegate::Create());
+    mojo::ApplicationImpl app(delegate.get());
+    app.BindShell(shell_handle);
+    loop.Run();
+  }
 
   return MOJO_RESULT_OK;
 }