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

Side by Side Diff: services/service_manager/runner/child/test_native_main.cc

Issue 2566663004: Revert of Build services as standalone executables (Closed)
Patch Set: Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "services/service_manager/runner/child/test_native_main.h"
6
7 #include <utility>
8
9 #include "base/debug/stack_trace.h"
10 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/process/launch.h"
13 #include "base/run_loop.h"
14 #include "base/threading/thread.h"
15 #include "build/build_config.h"
16 #include "mojo/edk/embedder/embedder.h"
17 #include "mojo/edk/embedder/process_delegate.h"
18 #include "services/service_manager/public/cpp/service.h"
19 #include "services/service_manager/public/cpp/service_context.h"
20 #include "services/service_manager/runner/common/client_util.h"
21 #include "services/service_manager/runner/init.h"
22
23 namespace service_manager {
24 namespace {
25
26 class ProcessDelegate : public mojo::edk::ProcessDelegate {
27 public:
28 ProcessDelegate() {}
29 ~ProcessDelegate() override {}
30
31 private:
32 void OnShutdownComplete() override {}
33
34 DISALLOW_COPY_AND_ASSIGN(ProcessDelegate);
35 };
36
37 } // namespace
38
39 int TestNativeMain(std::unique_ptr<service_manager::Service> service) {
40 service_manager::WaitForDebuggerIfNecessary();
41
42 #if !defined(OFFICIAL_BUILD)
43 base::debug::EnableInProcessStackDumping();
44 #if defined(OS_WIN)
45 base::RouteStdioToConsole(false);
46 #endif
47 #endif
48
49 {
50 mojo::edk::Init();
51
52 ProcessDelegate process_delegate;
53 base::Thread io_thread("io_thread");
54 base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0);
55 CHECK(io_thread.StartWithOptions(io_thread_options));
56
57 mojo::edk::InitIPCSupport(&process_delegate, io_thread.task_runner());
58 mojo::edk::SetParentPipeHandleFromCommandLine();
59
60 base::MessageLoop loop;
61 service_manager::ServiceContext context(
62 std::move(service),
63 service_manager::GetServiceRequestFromCommandLine());
64 base::RunLoop().Run();
65 mojo::edk::ShutdownIPCSupport();
66 }
67
68 return 0;
69 }
70
71 } // namespace service_manager
OLDNEW
« no previous file with comments | « services/service_manager/runner/child/test_native_main.h ('k') | services/service_manager/runner/host/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698