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

Side by Side Diff: chrome/app/mash/mash_runner.cc

Issue 2655943002: Bake chrome mash catalog into MashRunner (Closed)
Patch Set: Created 3 years, 11 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 | « chrome/app/mash/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/app/mash/mash_runner.h" 5 #include "chrome/app/mash/mash_runner.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "ui/base/ui_base_switches.h" 54 #include "ui/base/ui_base_switches.h"
55 55
56 #if defined(OS_CHROMEOS) 56 #if defined(OS_CHROMEOS)
57 #include "base/debug/leak_annotations.h" 57 #include "base/debug/leak_annotations.h"
58 #include "chrome/app/mash/mash_crash_reporter_client.h" 58 #include "chrome/app/mash/mash_crash_reporter_client.h"
59 #include "components/crash/content/app/breakpad_linux.h" // nogncheck 59 #include "components/crash/content/app/breakpad_linux.h" // nogncheck
60 #endif 60 #endif
61 61
62 using service_manager::mojom::ServiceFactory; 62 using service_manager::mojom::ServiceFactory;
63 63
64 // Defined externally by the ":catalog_cpp_source" target.
65 extern const char kChromeMashCatalogContents[];
66
64 namespace { 67 namespace {
65 68
66 // kProcessType used to identify child processes. 69 // kProcessType used to identify child processes.
67 const char* kMashChild = "mash-child"; 70 const char* kMashChild = "mash-child";
68 71
69 const char kChromeMashServiceName[] = "chrome_mash"; 72 const char kChromeMashServiceName[] = "chrome_mash";
70 73
71 const base::FilePath::CharType kChromeMashCatalogFilename[] =
72 FILE_PATH_LITERAL("chrome_mash_catalog.json");
73
74 bool IsChild() { 74 bool IsChild() {
75 return base::CommandLine::ForCurrentProcess()->HasSwitch( 75 return base::CommandLine::ForCurrentProcess()->HasSwitch(
76 switches::kProcessType) && 76 switches::kProcessType) &&
77 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 77 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
78 switches::kProcessType) == kMashChild; 78 switches::kProcessType) == kMashChild;
79 } 79 }
80 80
81 void InitializeResources() { 81 void InitializeResources() {
82 ui::RegisterPathProvider(); 82 ui::RegisterPathProvider();
83 const std::string locale = 83 const std::string locale =
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 mojo::edk::Init(); 171 mojo::edk::Init();
172 172
173 base::Thread ipc_thread("IPC thread"); 173 base::Thread ipc_thread("IPC thread");
174 ipc_thread.StartWithOptions( 174 ipc_thread.StartWithOptions(
175 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 175 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
176 mojo::edk::ScopedIPCSupport ipc_support( 176 mojo::edk::ScopedIPCSupport ipc_support(
177 ipc_thread.task_runner(), 177 ipc_thread.task_runner(),
178 mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST); 178 mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST);
179 179
180 std::string catalog_contents;
181 base::FilePath exe_path;
182 base::PathService::Get(base::DIR_EXE, &exe_path);
183 base::FilePath catalog_path = exe_path.Append(kChromeMashCatalogFilename);
184 bool result = base::ReadFileToString(catalog_path, &catalog_contents);
185 DCHECK(result);
186 std::unique_ptr<base::Value> manifest_value = 180 std::unique_ptr<base::Value> manifest_value =
187 base::JSONReader::Read(catalog_contents); 181 base::JSONReader::Read(kChromeMashCatalogContents);
188 DCHECK(manifest_value); 182 DCHECK(manifest_value);
189 183
190 // TODO(sky): refactor BackgroundServiceManager so can supply own context, we 184 // TODO(sky): refactor BackgroundServiceManager so can supply own context, we
191 // shouldn't we using context as it has a lot of stuff we don't really want 185 // shouldn't we using context as it has a lot of stuff we don't really want
192 // in chrome. 186 // in chrome.
193 ServiceProcessLauncherDelegateImpl service_process_launcher_delegate; 187 ServiceProcessLauncherDelegateImpl service_process_launcher_delegate;
194 service_manager::BackgroundServiceManager background_service_manager( 188 service_manager::BackgroundServiceManager background_service_manager(
195 &service_process_launcher_delegate, std::move(manifest_value)); 189 &service_process_launcher_delegate, std::move(manifest_value));
196 service_manager::mojom::ServicePtr service; 190 service_manager::mojom::ServicePtr service;
197 context_.reset(new service_manager::ServiceContext( 191 context_.reset(new service_manager::ServiceContext(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { 278 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) {
285 return; 279 return;
286 } 280 }
287 281
288 // Include the pid as logging may not have been initialized yet (the pid 282 // Include the pid as logging may not have been initialized yet (the pid
289 // printed out by logging is wrong). 283 // printed out by logging is wrong).
290 LOG(WARNING) << "waiting for debugger to attach for service " << service_name 284 LOG(WARNING) << "waiting for debugger to attach for service " << service_name
291 << " pid=" << base::Process::Current().Pid(); 285 << " pid=" << base::Process::Current().Pid();
292 base::debug::WaitForDebugger(120, true); 286 base::debug::WaitForDebugger(120, true);
293 } 287 }
OLDNEW
« no previous file with comments | « chrome/app/mash/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698