OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/run_application.h" | 5 #include "mojo/public/cpp/application/run_application.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/stack_trace.h" | 11 #include "base/debug/stack_trace.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/logging.h" |
13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
14 #include "base/threading/thread_local.h" | 15 #include "base/threading/thread_local.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 #include "mojo/application/run_application_options_chromium.h" | 17 #include "mojo/application/run_application_options_chromium.h" |
17 #include "mojo/message_pump/message_pump_mojo.h" | 18 #include "mojo/message_pump/message_pump_mojo.h" |
18 #include "mojo/public/cpp/application/application_impl_base.h" | 19 #include "mojo/public/cpp/application/application_impl_base.h" |
19 #include "mojo/public/cpp/system/message_pipe.h" | 20 #include "mojo/public/cpp/system/message_pipe.h" |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
22 | 23 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 g_current_result_holder.Pointer()->Set(nullptr); | 67 g_current_result_holder.Pointer()->Set(nullptr); |
67 | 68 |
68 // TODO(vtl): We'd like to enable the following assertion, but we quit the | 69 // TODO(vtl): We'd like to enable the following assertion, but we quit the |
69 // current message loop directly in various places. | 70 // current message loop directly in various places. |
70 // DCHECK(result_holder.is_set); | 71 // DCHECK(result_holder.is_set); |
71 | 72 |
72 return result_holder.result; | 73 return result_holder.result; |
73 } | 74 } |
74 | 75 |
75 void TerminateApplication(MojoResult result) { | 76 void TerminateApplication(MojoResult result) { |
76 DCHECK(base::MessageLoop::current()->is_running()); | 77 // TODO(vtl): Rather than asserting |...->is_running()|, just assert that we |
| 78 // have one, since we may be called during message loop teardown. (The |
| 79 // HandleWatcher is notified of the message loop's pending destruction, and |
| 80 // triggers connection errors.) I should think about this some more. |
| 81 DCHECK(base::MessageLoop::current()); |
| 82 if (!base::MessageLoop::current()->is_running()) { |
| 83 DLOG(WARNING) << "TerminateApplication() with message loop not running"; |
| 84 return; |
| 85 } |
77 base::MessageLoop::current()->Quit(); | 86 base::MessageLoop::current()->Quit(); |
78 | 87 |
79 ResultHolder* result_holder = g_current_result_holder.Pointer()->Get(); | 88 ResultHolder* result_holder = g_current_result_holder.Pointer()->Get(); |
80 DCHECK(result_holder); | 89 DCHECK(result_holder); |
81 result_holder->result = result; | 90 result_holder->result = result; |
82 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) | 91 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
83 DCHECK(!result_holder->is_set); | 92 DCHECK(!result_holder->is_set); |
84 result_holder->is_set = true; | 93 result_holder->is_set = true; |
85 #endif | 94 #endif |
86 } | 95 } |
87 | 96 |
88 } // namespace mojo | 97 } // namespace mojo |
OLD | NEW |