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 17 matching lines...) Expand all Loading... |
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 CHECK(instance_); |
33 return instance_; | 33 return instance_; |
34 } | 34 } |
35 | 35 |
36 CrashDumpManager::CrashDumpManager(const base::FilePath& crash_dump_dir) | 36 CrashDumpManager::CrashDumpManager(const base::FilePath& crash_dump_dir) |
37 : crash_dump_dir_(crash_dump_dir) { | 37 : crash_dump_dir_(crash_dump_dir) { |
38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 38 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
39 DCHECK(!instance_); | 39 DCHECK(!instance_); |
40 | 40 |
41 instance_ = this; | 41 instance_ = this; |
42 | 42 |
43 notification_registrar_.Add(this, | 43 notification_registrar_.Add(this, |
44 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 44 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
45 content::NotificationService::AllSources()); | 45 content::NotificationService::AllSources()); |
46 notification_registrar_.Add(this, | 46 notification_registrar_.Add(this, |
47 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 47 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
48 content::NotificationService::AllSources()); | 48 content::NotificationService::AllSources()); |
(...skipping 27 matching lines...) Expand all Loading... |
76 base::AutoLock auto_lock(child_process_id_to_minidump_path_lock_); | 76 base::AutoLock auto_lock(child_process_id_to_minidump_path_lock_); |
77 DCHECK(!ContainsKey(child_process_id_to_minidump_path_, child_process_id)); | 77 DCHECK(!ContainsKey(child_process_id_to_minidump_path_, child_process_id)); |
78 child_process_id_to_minidump_path_[child_process_id] = minidump_path; | 78 child_process_id_to_minidump_path_[child_process_id] = minidump_path; |
79 } | 79 } |
80 return minidump_file.Pass(); | 80 return minidump_file.Pass(); |
81 } | 81 } |
82 | 82 |
83 // static | 83 // static |
84 void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path, | 84 void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path, |
85 base::ProcessHandle pid) { | 85 base::ProcessHandle pid) { |
86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 86 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
87 CHECK(instance_); | 87 CHECK(instance_); |
88 int64 file_size = 0; | 88 int64 file_size = 0; |
89 int r = base::GetFileSize(minidump_path, &file_size); | 89 int r = base::GetFileSize(minidump_path, &file_size); |
90 DCHECK(r) << "Failed to retrieve size for minidump " | 90 DCHECK(r) << "Failed to retrieve size for minidump " |
91 << minidump_path.value(); | 91 << minidump_path.value(); |
92 | 92 |
93 if (file_size == 0) { | 93 if (file_size == 0) { |
94 // Empty minidump, this process did not crash. Just remove the file. | 94 // Empty minidump, this process did not crash. Just remove the file. |
95 r = base::DeleteFile(minidump_path, false); | 95 r = base::DeleteFile(minidump_path, false); |
96 DCHECK(r) << "Failed to delete temporary minidump file " | 96 DCHECK(r) << "Failed to delete temporary minidump file " |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 164 } |
165 minidump_path = iter->second; | 165 minidump_path = iter->second; |
166 child_process_id_to_minidump_path_.erase(iter); | 166 child_process_id_to_minidump_path_.erase(iter); |
167 } | 167 } |
168 BrowserThread::PostTask( | 168 BrowserThread::PostTask( |
169 BrowserThread::FILE, FROM_HERE, | 169 BrowserThread::FILE, FROM_HERE, |
170 base::Bind(&CrashDumpManager::ProcessMinidump, minidump_path, pid)); | 170 base::Bind(&CrashDumpManager::ProcessMinidump, minidump_path, pid)); |
171 } | 171 } |
172 | 172 |
173 } // namespace breakpad | 173 } // namespace breakpad |
OLD | NEW |