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

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

Issue 1997473005: Remove requirement that mojo::Environment be instantiated. (Closed) Base URL: https://github.com/domokit/mojo.git@work797_no_utility_tls
Patch Set: SetDefaultAsyncWaiter Created 4 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/cpp/application/application_runner.h" 5 #include "mojo/public/cpp/application/application_runner.h"
6 6
7 #include "mojo/public/cpp/application/application_delegate.h" 7 #include "mojo/public/cpp/application/application_delegate.h"
8 #include "mojo/public/cpp/application/application_impl.h" 8 #include "mojo/public/cpp/application/application_impl.h"
9 #include "mojo/public/cpp/application/application_impl_base.h" 9 #include "mojo/public/cpp/application/application_impl_base.h"
10 #include "mojo/public/cpp/environment/environment.h"
11 #include "mojo/public/cpp/utility/run_loop.h" 10 #include "mojo/public/cpp/utility/run_loop.h"
12 11
13 namespace mojo { 12 namespace mojo {
14 namespace { 13 namespace {
15 bool g_running = false; 14 bool g_running = false;
16 } // namespace 15 } // namespace
17 16
18 // static 17 // static
19 void ApplicationImplBase::Terminate() { 18 void ApplicationImplBase::Terminate() {
20 RunLoop::current()->Quit(); 19 RunLoop::current()->Quit();
21 } 20 }
22 21
23 ApplicationRunner::ApplicationRunner( 22 ApplicationRunner::ApplicationRunner(
24 std::unique_ptr<ApplicationDelegate> delegate) 23 std::unique_ptr<ApplicationDelegate> delegate)
25 : delegate_(std::move(delegate)) {} 24 : delegate_(std::move(delegate)) {}
26 25
27 ApplicationRunner::~ApplicationRunner() { 26 ApplicationRunner::~ApplicationRunner() {
28 assert(!delegate_); 27 assert(!delegate_);
29 } 28 }
30 29
31 MojoResult ApplicationRunner::Run(MojoHandle app_request_handle) { 30 MojoResult ApplicationRunner::Run(MojoHandle app_request_handle) {
32 MOJO_DCHECK(!g_running) 31 MOJO_DCHECK(!g_running)
33 << "Another ApplicationRunner::Run() is already running!"; 32 << "Another ApplicationRunner::Run() is already running!";
34 33
35 g_running = true; 34 g_running = true;
36 Environment env;
37 { 35 {
38 RunLoop loop; 36 RunLoop loop;
39 ApplicationImpl app(delegate_.get(), 37 ApplicationImpl app(delegate_.get(),
40 InterfaceRequest<Application>(MakeScopedHandle( 38 InterfaceRequest<Application>(MakeScopedHandle(
41 MessagePipeHandle(app_request_handle)))); 39 MessagePipeHandle(app_request_handle))));
42 loop.Run(); 40 loop.Run();
43 } 41 }
44 42
45 delegate_.reset(); 43 delegate_.reset();
46 44
47 g_running = false; 45 g_running = false;
48 46
49 return MOJO_RESULT_OK; 47 return MOJO_RESULT_OK;
50 } 48 }
51 49
52 } // namespace mojo 50 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/environment/environment.cc ('k') | mojo/public/cpp/application/lib/application_test_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698