Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: mojo/public/cpp/application/lib/application_runner_chromium.cc

Issue 441853002: mojo: first take on removing mojo_main_{chromium,standalone}. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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_runner_chromium.h"
6
7 #include "base/at_exit.h"
8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h"
10 #include "mojo/public/cpp/application/application_delegate.h"
11 #include "mojo/public/cpp/application/application_impl.h"
12
13 namespace mojo {
14
15 // static
16 void ApplicationImpl::Terminate() {
17 if (base::MessageLoop::current()->is_running())
18 base::MessageLoop::current()->Quit();
19 }
20
21 ApplicationRunnerChromium::ApplicationRunnerChromium()
22 : loop_type_(base::MessageLoop::TYPE_DEFAULT) {}
23
24 ApplicationRunnerChromium::~ApplicationRunnerChromium() {}
25
26 void ApplicationRunnerChromium::take_delegate(
27 scoped_ptr<ApplicationDelegate> delegate) {
28 DCHECK(!delegate_);
29 DCHECK(delegate);
30 delegate_ = delegate.Pass();
31 }
32
33 void ApplicationRunnerChromium::set_loop_type(base::MessageLoop::Type type) {
34 DCHECK_EQ(base::MessageLoop::TYPE_DEFAULT, loop_type_);
35 loop_type_ = type;
36 }
37
38 MojoResult ApplicationRunnerChromium::Run(MojoHandle shell_handle) {
39 base::CommandLine::Init(0, NULL);
40 #if !defined(COMPONENT_BUILD)
41 base::AtExitManager at_exit;
42 #endif
43
44 {
45 base::MessageLoop loop(loop_type_);
46 ApplicationImpl impl(delegate_.get(),
47 MakeScopedHandle(MessagePipeHandle(shell_handle)));
48 loop.Run();
49 }
50 delegate_.reset();
51 return MOJO_RESULT_OK;
52 }
53
54 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698