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

Side by Side Diff: mash/runner/main.cc

Issue 2573283002: Use a static catalog manifest for the standalone Mash runner (Closed)
Patch Set: . Created 3 years, 12 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
« no previous file with comments | « mash/runner/BUILD.gn ('k') | services/catalog/catalog.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <memory>
6 #include <string>
7 #include <utility>
8
9 #include "base/at_exit.h"
10 #include "base/base_paths.h"
11 #include "base/bind.h"
12 #include "base/debug/debugger.h"
13 #include "base/debug/stack_trace.h"
14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h"
16 #include "base/i18n/icu_util.h"
17 #include "base/json/json_reader.h"
18 #include "base/memory/ptr_util.h"
19 #include "base/message_loop/message_loop.h"
20 #include "base/path_service.h"
21 #include "base/process/launch.h"
22 #include "base/run_loop.h"
23 #include "base/threading/platform_thread.h"
24 #include "build/build_config.h"
25 #include "services/service_manager/runner/init.h"
26 #include "services/service_manager/standalone/context.h"
27 #include "services/service_manager/switches.h"
28
29 namespace {
30
31 const base::FilePath::CharType kMashCatalogFilename[] =
32 FILE_PATH_LITERAL("mash_catalog.json");
33
34 } // namespace
35
36 int main(int argc, char** argv) {
37 base::CommandLine::Init(argc, argv);
38
39 base::AtExitManager at_exit;
40 service_manager::InitializeLogging();
41 service_manager::WaitForDebuggerIfNecessary();
42
43 #if !defined(OFFICIAL_BUILD) && defined(OS_WIN)
44 base::RouteStdioToConsole(false);
45 #endif
46
47 #if !defined(OFFICIAL_BUILD)
48 base::debug::EnableInProcessStackDumping();
49 #endif
50 base::PlatformThread::SetName("service_manager");
51
52 std::string catalog_contents;
53 base::FilePath exe_path;
54 base::PathService::Get(base::DIR_EXE, &exe_path);
55 base::FilePath catalog_path = exe_path.Append(kMashCatalogFilename);
56 DCHECK(base::ReadFileToString(catalog_path, &catalog_contents));
57 std::unique_ptr<base::Value> manifest_value =
58 base::JSONReader::Read(catalog_contents);
59 DCHECK(manifest_value);
60
61 auto params = base::MakeUnique<service_manager::Context::InitParams>();
62 params->static_catalog = std::move(manifest_value);
63
64 #if defined(OS_WIN) && defined(COMPONENT_BUILD)
65 // In Windows component builds, ensure that loaded service binaries always
66 // search this exe's dir for DLLs.
67 SetDllDirectory(exe_path.value().c_str());
68 #endif
69
70 // We want the Context to outlive the MessageLoop so that pipes are all
71 // gracefully closed / error-out before we try to shut the Context down.
72 service_manager::Context service_manager_context;
73 {
74 base::MessageLoop message_loop;
75 base::i18n::InitializeICU();
76 service_manager_context.Init(std::move(params));
77
78 message_loop.task_runner()->PostTask(
79 FROM_HERE,
80 base::Bind(&service_manager::Context::RunCommandLineApplication,
81 base::Unretained(&service_manager_context)));
82
83 base::RunLoop().Run();
84
85 // Must be called before |message_loop| is destroyed.
86 service_manager_context.Shutdown();
87 }
88
89 return 0;
90 }
OLDNEW
« no previous file with comments | « mash/runner/BUILD.gn ('k') | services/catalog/catalog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698