OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chromecast/crash/cast_crash_reporter_client.h" | |
6 | |
7 #include "base/time/time.h" | |
8 #include "components/crash/app/breakpad_linux.h" | |
9 #include "content/public/common/content_switches.h" | |
10 | |
11 namespace chromecast { | |
12 | |
13 namespace { | |
14 | |
15 char* g_process_type = NULL; | |
16 uint64_t g_process_start_time = 0; | |
17 | |
18 } // namespace | |
19 | |
20 // static | |
21 void CastCrashReporterClient::InitCrashReporter( | |
22 const std::string& process_type) { | |
23 g_process_start_time = (base::TimeTicks::Now() - | |
24 base::TimeTicks()).InMilliseconds(); | |
25 | |
26 // Save the process type (leaked). | |
27 // Note: "browser" process is identified by empty process type string. | |
28 const std::string& named_process_type( | |
29 process_type.empty() ? "browser" : process_type); | |
30 const size_t process_type_len = named_process_type.size() + 1; | |
31 g_process_type = new char[process_type_len]; | |
32 strncpy(g_process_type, named_process_type.c_str(), process_type_len); | |
33 | |
34 // Start up breakpad for this process, if applicable. | |
35 breakpad::InitCrashReporter(process_type); | |
36 } | |
37 | |
38 // static | |
39 char* CastCrashReporterClient::GetProcessType() { | |
40 return g_process_type; | |
41 } | |
42 | |
43 // static | |
44 uint64_t CastCrashReporterClient::GetProcessStartTime() { | |
45 return g_process_start_time; | |
46 } | |
47 | |
48 CastCrashReporterClient::CastCrashReporterClient() {} | |
49 CastCrashReporterClient::~CastCrashReporterClient() {} | |
50 | |
51 bool CastCrashReporterClient::EnableBreakpadForProcess( | |
52 const std::string& process_type) { | |
53 return process_type == switches::kRendererProcess || | |
54 process_type == switches::kZygoteProcess || | |
55 process_type == switches::kGpuProcess; | |
56 } | |
57 | |
58 } // namespace chromecast | |
OLD | NEW |