| OLD | NEW |
| 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 "components/arc/crash_collector/arc_crash_collector_bridge.h" | 5 #include "components/arc/crash_collector/arc_crash_collector_bridge.h" |
| 6 | 6 |
| 7 #include <sysexits.h> | 7 #include <sysexits.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 ArcCrashCollectorBridge::ArcCrashCollectorBridge(ArcBridgeService* bridge) | 24 ArcCrashCollectorBridge::ArcCrashCollectorBridge(ArcBridgeService* bridge) |
| 25 : ArcService(bridge), binding_(this) { | 25 : ArcService(bridge), binding_(this) { |
| 26 arc_bridge_service()->AddObserver(this); | 26 arc_bridge_service()->AddObserver(this); |
| 27 } | 27 } |
| 28 | 28 |
| 29 ArcCrashCollectorBridge::~ArcCrashCollectorBridge() { | 29 ArcCrashCollectorBridge::~ArcCrashCollectorBridge() { |
| 30 arc_bridge_service()->RemoveObserver(this); | 30 arc_bridge_service()->RemoveObserver(this); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void ArcCrashCollectorBridge::OnCrashCollectorInstanceReady() { | 33 void ArcCrashCollectorBridge::OnCrashCollectorInstanceReady() { |
| 34 CrashCollectorHostPtr host_ptr; | 34 mojom::CrashCollectorHostPtr host_ptr; |
| 35 binding_.Bind(mojo::GetProxy(&host_ptr)); | 35 binding_.Bind(mojo::GetProxy(&host_ptr)); |
| 36 arc_bridge_service()->crash_collector_instance()->Init(std::move(host_ptr)); | 36 arc_bridge_service()->crash_collector_instance()->Init(std::move(host_ptr)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void ArcCrashCollectorBridge::DumpCrash(const mojo::String& type, | 39 void ArcCrashCollectorBridge::DumpCrash(const mojo::String& type, |
| 40 mojo::ScopedHandle pipe) { | 40 mojo::ScopedHandle pipe) { |
| 41 mojo::edk::ScopedPlatformHandle handle; | 41 mojo::edk::ScopedPlatformHandle handle; |
| 42 mojo::edk::PassWrappedPlatformHandle(pipe.get().value(), &handle); | 42 mojo::edk::PassWrappedPlatformHandle(pipe.get().value(), &handle); |
| 43 | 43 |
| 44 base::FileHandleMappingVector fd_map = { | 44 base::FileHandleMappingVector fd_map = { |
| 45 std::make_pair(handle.get().handle, STDIN_FILENO) | 45 std::make_pair(handle.get().handle, STDIN_FILENO) |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 base::LaunchOptions options; | 48 base::LaunchOptions options; |
| 49 options.fds_to_remap = &fd_map; | 49 options.fds_to_remap = &fd_map; |
| 50 | 50 |
| 51 const auto flag = "--arc_java_crash=" + type.get(); | 51 const auto flag = "--arc_java_crash=" + type.get(); |
| 52 auto process = base::LaunchProcess({ kCrashReporterPath, flag }, options); | 52 auto process = base::LaunchProcess({ kCrashReporterPath, flag }, options); |
| 53 | 53 |
| 54 int exit_code; | 54 int exit_code; |
| 55 if (!process.WaitForExit(&exit_code)) { | 55 if (!process.WaitForExit(&exit_code)) { |
| 56 LOG(ERROR) << "Failed to wait for " << kCrashReporterPath; | 56 LOG(ERROR) << "Failed to wait for " << kCrashReporterPath; |
| 57 } else if (exit_code != EX_OK) { | 57 } else if (exit_code != EX_OK) { |
| 58 LOG(ERROR) << kCrashReporterPath << " failed with exit code " << exit_code; | 58 LOG(ERROR) << kCrashReporterPath << " failed with exit code " << exit_code; |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace arc | 62 } // namespace arc |
| OLD | NEW |