Chromium Code Reviews

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

Issue 1995853002: Remove ApplicationRunner::{Get,Set}DefaultLogger(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « mojo/public/cpp/application/application_runner.h ('k') | mojo/services/log/cpp/log_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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" 10 #include "mojo/public/cpp/environment/environment.h"
11 #include "mojo/public/cpp/environment/logging.h"
12 #include "mojo/public/cpp/utility/run_loop.h" 11 #include "mojo/public/cpp/utility/run_loop.h"
13 12
14 namespace mojo { 13 namespace mojo {
15 namespace { 14 namespace {
16 bool g_running = false; 15 bool g_running = false;
17 } // namespace 16 } // namespace
18 17
19 // static 18 // static
20 void ApplicationImplBase::Terminate() { 19 void ApplicationImplBase::Terminate() {
21 RunLoop::current()->Quit(); 20 RunLoop::current()->Quit();
22 } 21 }
23 22
24 ApplicationRunner::ApplicationRunner( 23 ApplicationRunner::ApplicationRunner(
25 std::unique_ptr<ApplicationDelegate> delegate) 24 std::unique_ptr<ApplicationDelegate> delegate)
26 : delegate_(std::move(delegate)) {} 25 : delegate_(std::move(delegate)) {}
27 26
28 ApplicationRunner::~ApplicationRunner() { 27 ApplicationRunner::~ApplicationRunner() {
29 assert(!delegate_); 28 assert(!delegate_);
30 } 29 }
31 30
32 // static
33 void ApplicationRunner::SetDefaultLogger(const MojoLogger* logger) {
34 MOJO_DCHECK(g_running);
35 Environment::SetDefaultLogger(logger);
36 }
37
38 // static
39 const MojoLogger* ApplicationRunner::GetDefaultLogger() {
40 MOJO_DCHECK(g_running);
41 return Environment::GetDefaultLogger();
42 }
43
44 MojoResult ApplicationRunner::Run(MojoHandle app_request_handle) { 31 MojoResult ApplicationRunner::Run(MojoHandle app_request_handle) {
45 MOJO_DCHECK(!g_running) 32 MOJO_DCHECK(!g_running)
46 << "Another ApplicationRunner::Run() is already running!"; 33 << "Another ApplicationRunner::Run() is already running!";
47 34
48 g_running = true; 35 g_running = true;
49 Environment env; 36 Environment env;
50 { 37 {
51 RunLoop loop; 38 RunLoop loop;
52 ApplicationImpl app(delegate_.get(), 39 ApplicationImpl app(delegate_.get(),
53 InterfaceRequest<Application>(MakeScopedHandle( 40 InterfaceRequest<Application>(MakeScopedHandle(
54 MessagePipeHandle(app_request_handle)))); 41 MessagePipeHandle(app_request_handle))));
55 loop.Run(); 42 loop.Run();
56 } 43 }
57 44
58 delegate_.reset(); 45 delegate_.reset();
59 46
60 g_running = false; 47 g_running = false;
61 48
62 return MOJO_RESULT_OK; 49 return MOJO_RESULT_OK;
63 } 50 }
64 51
65 } // namespace mojo 52 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/application_runner.h ('k') | mojo/services/log/cpp/log_client.h » ('j') | no next file with comments »

Powered by Google App Engine