OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/crash/browser/crash_dump_manager_android.h" | 5 #include "components/crash/browser/crash_dump_manager_android.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 | 22 |
23 using content::BrowserThread; | 23 using content::BrowserThread; |
24 | 24 |
25 namespace breakpad { | 25 namespace breakpad { |
26 | 26 |
27 // static | 27 // static |
28 CrashDumpManager* CrashDumpManager::instance_ = NULL; | 28 CrashDumpManager* CrashDumpManager::instance_ = NULL; |
29 | 29 |
30 // static | 30 // static |
31 CrashDumpManager* CrashDumpManager::GetInstance() { | 31 CrashDumpManager* CrashDumpManager::GetInstance() { |
32 CHECK(instance_); | |
32 return instance_; | 33 return instance_; |
33 } | 34 } |
34 | 35 |
35 CrashDumpManager::CrashDumpManager(const base::FilePath& crash_dump_dir) | 36 CrashDumpManager::CrashDumpManager(const base::FilePath& crash_dump_dir) |
36 : crash_dump_dir_(crash_dump_dir) { | 37 : crash_dump_dir_(crash_dump_dir) { |
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
38 DCHECK(!instance_); | 39 CHECK(!instance_); |
Lei Zhang
2015/01/31 01:14:22
I haven't looked very hard, but are you worried th
cjhopman
2015/01/31 01:20:48
Thinking about it a bit, I think this one could pr
| |
39 | 40 |
40 instance_ = this; | 41 instance_ = this; |
41 | 42 |
42 notification_registrar_.Add(this, | 43 notification_registrar_.Add(this, |
43 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 44 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
44 content::NotificationService::AllSources()); | 45 content::NotificationService::AllSources()); |
45 notification_registrar_.Add(this, | 46 notification_registrar_.Add(this, |
46 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 47 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
47 content::NotificationService::AllSources()); | 48 content::NotificationService::AllSources()); |
48 | 49 |
(...skipping 27 matching lines...) Expand all Loading... | |
76 DCHECK(!ContainsKey(child_process_id_to_minidump_path_, child_process_id)); | 77 DCHECK(!ContainsKey(child_process_id_to_minidump_path_, child_process_id)); |
77 child_process_id_to_minidump_path_[child_process_id] = minidump_path; | 78 child_process_id_to_minidump_path_[child_process_id] = minidump_path; |
78 } | 79 } |
79 return minidump_file.Pass(); | 80 return minidump_file.Pass(); |
80 } | 81 } |
81 | 82 |
82 // static | 83 // static |
83 void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path, | 84 void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path, |
84 base::ProcessHandle pid) { | 85 base::ProcessHandle pid) { |
85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
87 CHECK(instance_); | |
86 int64 file_size = 0; | 88 int64 file_size = 0; |
87 int r = base::GetFileSize(minidump_path, &file_size); | 89 int r = base::GetFileSize(minidump_path, &file_size); |
88 DCHECK(r) << "Failed to retrieve size for minidump " | 90 DCHECK(r) << "Failed to retrieve size for minidump " |
89 << minidump_path.value(); | 91 << minidump_path.value(); |
90 | 92 |
91 if (file_size == 0) { | 93 if (file_size == 0) { |
92 // Empty minidump, this process did not crash. Just remove the file. | 94 // Empty minidump, this process did not crash. Just remove the file. |
93 r = base::DeleteFile(minidump_path, false); | 95 r = base::DeleteFile(minidump_path, false); |
94 DCHECK(r) << "Failed to delete temporary minidump file " | 96 DCHECK(r) << "Failed to delete temporary minidump file " |
95 << minidump_path.value(); | 97 << minidump_path.value(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 } | 164 } |
163 minidump_path = iter->second; | 165 minidump_path = iter->second; |
164 child_process_id_to_minidump_path_.erase(iter); | 166 child_process_id_to_minidump_path_.erase(iter); |
165 } | 167 } |
166 BrowserThread::PostTask( | 168 BrowserThread::PostTask( |
167 BrowserThread::FILE, FROM_HERE, | 169 BrowserThread::FILE, FROM_HERE, |
168 base::Bind(&CrashDumpManager::ProcessMinidump, minidump_path, pid)); | 170 base::Bind(&CrashDumpManager::ProcessMinidump, minidump_path, pid)); |
169 } | 171 } |
170 | 172 |
171 } // namespace breakpad | 173 } // namespace breakpad |
OLD | NEW |