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> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/process/launch.h" | 13 #include "base/process/launch.h" |
14 #include "mojo/edk/embedder/embedder.h" | 14 #include "mojo/edk/embedder/embedder.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 const char kCrashReporterPath[] = "/sbin/crash_reporter"; | 18 const char kCrashReporterPath[] = "/sbin/crash_reporter"; |
hidehiko
2016/07/11 05:24:53
nit: if the below empty line is removed, should we
Luis Héctor Chávez
2016/07/11 17:13:34
Sure. I just ran a replacement script + `git cl fo
| |
19 | |
20 } | 19 } |
21 | 20 |
22 namespace arc { | 21 namespace arc { |
23 | 22 |
24 ArcCrashCollectorBridge::ArcCrashCollectorBridge(ArcBridgeService* bridge) | 23 ArcCrashCollectorBridge::ArcCrashCollectorBridge(ArcBridgeService* bridge) |
25 : ArcService(bridge), binding_(this) { | 24 : ArcService(bridge), binding_(this) { |
26 arc_bridge_service()->AddObserver(this); | 25 arc_bridge_service()->crash_collector()->AddObserver(this); |
27 } | 26 } |
28 | 27 |
29 ArcCrashCollectorBridge::~ArcCrashCollectorBridge() { | 28 ArcCrashCollectorBridge::~ArcCrashCollectorBridge() { |
30 arc_bridge_service()->RemoveObserver(this); | 29 arc_bridge_service()->crash_collector()->RemoveObserver(this); |
31 } | 30 } |
32 | 31 |
33 void ArcCrashCollectorBridge::OnCrashCollectorInstanceReady() { | 32 void ArcCrashCollectorBridge::OnInstanceReady( |
33 mojom::CrashCollectorInstance* crash_collector_instance, | |
34 uint32_t version) { | |
34 mojom::CrashCollectorHostPtr host_ptr; | 35 mojom::CrashCollectorHostPtr host_ptr; |
35 binding_.Bind(mojo::GetProxy(&host_ptr)); | 36 binding_.Bind(mojo::GetProxy(&host_ptr)); |
36 arc_bridge_service()->crash_collector_instance()->Init(std::move(host_ptr)); | 37 crash_collector_instance->Init(std::move(host_ptr)); |
37 } | 38 } |
38 | 39 |
39 void ArcCrashCollectorBridge::DumpCrash(const mojo::String& type, | 40 void ArcCrashCollectorBridge::DumpCrash(const mojo::String& type, |
40 mojo::ScopedHandle pipe) { | 41 mojo::ScopedHandle pipe) { |
41 mojo::edk::ScopedPlatformHandle handle; | 42 mojo::edk::ScopedPlatformHandle handle; |
42 mojo::edk::PassWrappedPlatformHandle(pipe.get().value(), &handle); | 43 mojo::edk::PassWrappedPlatformHandle(pipe.get().value(), &handle); |
43 | 44 |
44 base::FileHandleMappingVector fd_map = { | 45 base::FileHandleMappingVector fd_map = { |
45 std::make_pair(handle.get().handle, STDIN_FILENO) | 46 std::make_pair(handle.get().handle, STDIN_FILENO)}; |
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 auto process = base::LaunchProcess({ | 51 auto process = |
52 kCrashReporterPath, | 52 base::LaunchProcess({kCrashReporterPath, "--arc_java_crash=" + type.get(), |
53 "--arc_java_crash=" + type.get(), | 53 "--arc_device=" + device_, "--arc_board=" + board_, |
54 "--arc_device=" + device_, | 54 "--arc_cpu_abi=" + cpu_abi_}, |
55 "--arc_board=" + board_, | 55 options); |
56 "--arc_cpu_abi=" + cpu_abi_ | |
57 }, options); | |
58 | 56 |
59 int exit_code; | 57 int exit_code; |
60 if (!process.WaitForExit(&exit_code)) { | 58 if (!process.WaitForExit(&exit_code)) { |
61 LOG(ERROR) << "Failed to wait for " << kCrashReporterPath; | 59 LOG(ERROR) << "Failed to wait for " << kCrashReporterPath; |
62 } else if (exit_code != EX_OK) { | 60 } else if (exit_code != EX_OK) { |
63 LOG(ERROR) << kCrashReporterPath << " failed with exit code " << exit_code; | 61 LOG(ERROR) << kCrashReporterPath << " failed with exit code " << exit_code; |
64 } | 62 } |
65 } | 63 } |
66 | 64 |
67 void ArcCrashCollectorBridge::SetBuildProperties(const mojo::String& device, | 65 void ArcCrashCollectorBridge::SetBuildProperties(const mojo::String& device, |
68 const mojo::String& board, | 66 const mojo::String& board, |
69 const mojo::String& cpu_abi) { | 67 const mojo::String& cpu_abi) { |
70 device_ = device.get(); | 68 device_ = device.get(); |
71 board_ = board.get(); | 69 board_ = board.get(); |
72 cpu_abi_ = cpu_abi.get(); | 70 cpu_abi_ = cpu_abi.get(); |
73 } | 71 } |
74 | 72 |
75 } // namespace arc | 73 } // namespace arc |
OLD | NEW |