| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <iostream> | 9 #include <iostream> |
| 10 | 10 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 96 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 97 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), | 97 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), |
| 98 base::trace_event::TraceLog::RECORDING_MODE); | 98 base::trace_event::TraceLog::RECORDING_MODE); |
| 99 } | 99 } |
| 100 | 100 |
| 101 // We want the runner::Context to outlive the MessageLoop so that pipes are | 101 // We want the runner::Context to outlive the MessageLoop so that pipes are |
| 102 // all gracefully closed / error-out before we try to shut the Context down. | 102 // all gracefully closed / error-out before we try to shut the Context down. |
| 103 base::FilePath shell_dir; | 103 base::FilePath shell_dir; |
| 104 PathService::Get(base::DIR_MODULE, &shell_dir); | 104 PathService::Get(base::DIR_MODULE, &shell_dir); |
| 105 mojo::runner::Context shell_context(shell_dir); | 105 mojo::runner::Context shell_context(shell_dir); |
| 106 InitCoreServicesForContext(&shell_context); | |
| 107 { | 106 { |
| 108 base::MessageLoop message_loop; | 107 base::MessageLoop message_loop; |
| 109 if (!shell_context.Init()) { | 108 if (!shell_context.Init()) { |
| 110 return 0; | 109 return 0; |
| 111 } | 110 } |
| 111 InitCoreServicesForContext(&shell_context); |
| 112 if (g_tracing) { | 112 if (g_tracing) { |
| 113 message_loop.PostDelayedTask(FROM_HERE, | 113 message_loop.PostDelayedTask(FROM_HERE, |
| 114 base::Bind(StopTracingAndFlushToDisk), | 114 base::Bind(StopTracingAndFlushToDisk), |
| 115 base::TimeDelta::FromSeconds(5)); | 115 base::TimeDelta::FromSeconds(5)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 message_loop.PostTask(FROM_HERE, | 118 message_loop.PostTask(FROM_HERE, |
| 119 base::Bind(&mojo::runner::Context::Run, | 119 base::Bind(&mojo::runner::Context::Run, |
| 120 base::Unretained(&shell_context), | 120 base::Unretained(&shell_context), |
| 121 GURL("mojo:desktop_ui"))); | 121 GURL("mojo:desktop_ui"))); |
| 122 message_loop.Run(); | 122 message_loop.Run(); |
| 123 | 123 |
| 124 // Must be called before |message_loop| is destroyed. | 124 // Must be called before |message_loop| is destroyed. |
| 125 shell_context.Shutdown(); | 125 shell_context.Shutdown(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 if (g_tracing) | 128 if (g_tracing) |
| 129 StopTracingAndFlushToDisk(); | 129 StopTracingAndFlushToDisk(); |
| 130 return 0; | 130 return 0; |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace mandoline | 133 } // namespace mandoline |
| OLD | NEW |