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

Side by Side Diff: components/arc/crash_collector/arc_crash_collector_bridge.cc

Issue 2133503002: arc: Revamp the ArcBridgeService interface (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: More rebasing Created 4 years, 5 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
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 "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
18 const char kCrashReporterPath[] = "/sbin/crash_reporter"; 17 const char kCrashReporterPath[] = "/sbin/crash_reporter";
19
20 } 18 }
21 19
22 namespace arc { 20 namespace arc {
23 21
24 ArcCrashCollectorBridge::ArcCrashCollectorBridge(ArcBridgeService* bridge) 22 ArcCrashCollectorBridge::ArcCrashCollectorBridge(ArcBridgeService* bridge)
25 : ArcService(bridge), binding_(this) { 23 : ArcService(bridge), binding_(this) {
26 arc_bridge_service()->AddObserver(this); 24 arc_bridge_service()->crash_collector()->AddObserver(this);
27 } 25 }
28 26
29 ArcCrashCollectorBridge::~ArcCrashCollectorBridge() { 27 ArcCrashCollectorBridge::~ArcCrashCollectorBridge() {
30 arc_bridge_service()->RemoveObserver(this); 28 arc_bridge_service()->crash_collector()->RemoveObserver(this);
31 } 29 }
32 30
33 void ArcCrashCollectorBridge::OnCrashCollectorInstanceReady() { 31 void ArcCrashCollectorBridge::OnInstanceReady() {
34 mojom::CrashCollectorHostPtr host_ptr; 32 mojom::CrashCollectorHostPtr host_ptr;
35 binding_.Bind(mojo::GetProxy(&host_ptr)); 33 binding_.Bind(mojo::GetProxy(&host_ptr));
36 arc_bridge_service()->crash_collector_instance()->Init(std::move(host_ptr)); 34 arc_bridge_service()->crash_collector()->instance()->Init(
35 std::move(host_ptr));
37 } 36 }
38 37
39 void ArcCrashCollectorBridge::DumpCrash(const mojo::String& type, 38 void ArcCrashCollectorBridge::DumpCrash(const mojo::String& type,
40 mojo::ScopedHandle pipe) { 39 mojo::ScopedHandle pipe) {
41 mojo::edk::ScopedPlatformHandle handle; 40 mojo::edk::ScopedPlatformHandle handle;
42 mojo::edk::PassWrappedPlatformHandle(pipe.get().value(), &handle); 41 mojo::edk::PassWrappedPlatformHandle(pipe.get().value(), &handle);
43 42
44 base::FileHandleMappingVector fd_map = { 43 base::FileHandleMappingVector fd_map = {
45 std::make_pair(handle.get().handle, STDIN_FILENO) 44 std::make_pair(handle.get().handle, STDIN_FILENO)};
46 };
47 45
48 base::LaunchOptions options; 46 base::LaunchOptions options;
49 options.fds_to_remap = &fd_map; 47 options.fds_to_remap = &fd_map;
50 48
51 auto process = base::LaunchProcess({ 49 auto process =
52 kCrashReporterPath, 50 base::LaunchProcess({kCrashReporterPath, "--arc_java_crash=" + type.get(),
53 "--arc_java_crash=" + type.get(), 51 "--arc_device=" + device_, "--arc_board=" + board_,
54 "--arc_device=" + device_, 52 "--arc_cpu_abi=" + cpu_abi_},
55 "--arc_board=" + board_, 53 options);
56 "--arc_cpu_abi=" + cpu_abi_
57 }, options);
58 54
59 int exit_code; 55 int exit_code;
60 if (!process.WaitForExit(&exit_code)) { 56 if (!process.WaitForExit(&exit_code)) {
61 LOG(ERROR) << "Failed to wait for " << kCrashReporterPath; 57 LOG(ERROR) << "Failed to wait for " << kCrashReporterPath;
62 } else if (exit_code != EX_OK) { 58 } else if (exit_code != EX_OK) {
63 LOG(ERROR) << kCrashReporterPath << " failed with exit code " << exit_code; 59 LOG(ERROR) << kCrashReporterPath << " failed with exit code " << exit_code;
64 } 60 }
65 } 61 }
66 62
67 void ArcCrashCollectorBridge::SetBuildProperties(const mojo::String& device, 63 void ArcCrashCollectorBridge::SetBuildProperties(const mojo::String& device,
68 const mojo::String& board, 64 const mojo::String& board,
69 const mojo::String& cpu_abi) { 65 const mojo::String& cpu_abi) {
70 device_ = device.get(); 66 device_ = device.get();
71 board_ = board.get(); 67 board_ = board.get();
72 cpu_abi_ = cpu_abi.get(); 68 cpu_abi_ = cpu_abi.get();
73 } 69 }
74 70
75 } // namespace arc 71 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/crash_collector/arc_crash_collector_bridge.h ('k') | components/arc/ime/arc_ime_bridge_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698