refactor: eliminate duplicate code exposing process APIs (#15824)

This commit is contained in:
Milan Burda 2018-11-28 17:08:17 +01:00 committed by Shelley Vohr
parent d7d4b8638d
commit 07f8f5f95a
4 changed files with 40 additions and 37 deletions

View file

@ -147,29 +147,13 @@ void AtomSandboxedRendererClient::InitializeBindings(
mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate);
b.Set("process", process);
process.SetMethod("crash", AtomBindings::Crash);
process.SetMethod("hang", AtomBindings::Hang);
process.SetMethod("getHeapStatistics", &AtomBindings::GetHeapStatistics);
process.SetMethod("getSystemMemoryInfo", &AtomBindings::GetSystemMemoryInfo);
process.SetMethod(
"getCPUUsage",
base::Bind(&AtomBindings::GetCPUUsage, base::Unretained(metrics_.get())));
process.SetMethod("getIOCounters", &AtomBindings::GetIOCounters);
AtomBindings::BindProcess(isolate, &process, metrics_.get());
process.Set("argv", base::CommandLine::ForCurrentProcess()->argv());
process.SetReadOnly("pid", base::GetCurrentProcId());
process.SetReadOnly("sandboxed", true);
process.SetReadOnly("type", "renderer");
#if defined(MAS_BUILD)
process.SetReadOnly("mas", true);
#endif
#if defined(OS_WIN)
if (IsRunningInDesktopBridge())
process.SetReadOnly("windowsStore", true);
#endif
// Pass in CLI flags needed to setup the renderer
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kGuestInstanceID))