Index: components/crash/content/browser/crash_dump_manager_android.cc |
diff --git a/components/crash/content/browser/crash_dump_manager_android.cc b/components/crash/content/browser/crash_dump_manager_android.cc |
index 62e77ad6206c83c83177a64c9d00c3ecc84ff122..cdf67113f92f001b8efb79ffc1ba130cea53ad64 100644 |
--- a/components/crash/content/browser/crash_dump_manager_android.cc |
+++ b/components/crash/content/browser/crash_dump_manager_android.cc |
@@ -4,10 +4,12 @@ |
#include "components/crash/content/browser/crash_dump_manager_android.h" |
+#include "base/android/application_status_listener.h" |
#include "base/bind.h" |
#include "base/files/file_util.h" |
#include "base/format_macros.h" |
#include "base/logging.h" |
+#include "base/metrics/histogram_macros.h" |
#include "base/posix/global_descriptors.h" |
#include "base/process/process.h" |
#include "base/rand_util.h" |
@@ -82,7 +84,8 @@ base::File CrashDumpManager::CreateMinidumpFile(int child_process_id) { |
// static |
void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path, |
- base::ProcessHandle pid) { |
+ base::ProcessHandle pid, |
+ bool recordExitStatus) { |
DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
CHECK(instance_); |
int64 file_size = 0; |
@@ -90,6 +93,18 @@ void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path, |
DCHECK(r) << "Failed to retrieve size for minidump " |
<< minidump_path.value(); |
+ if (recordExitStatus) { |
no sievers
2015/11/17 22:28:53
nit: style here and elsewhere in C++ code - |recor
Peter Wen
2015/11/18 22:00:53
Done.
|
+ int exitStatus = ExitStatus::COUNT; |
no sievers
2015/11/17 22:28:53
nit: no need to init since it's if-else.
Peter Wen
2015/11/18 22:00:53
Done.
|
+ if (file_size == 0) { |
+ exitStatus = ExitStatus::EMPTY_MINIDUMP; |
+ } else { |
+ exitStatus = ExitStatus::VALID_MINIDUMP; |
+ } |
+ UMA_HISTOGRAM_ENUMERATION("Tab.RendererDetailedExitStatus", |
no sievers
2015/11/17 22:28:53
nit: since this is also called for other process t
Peter Wen
2015/11/18 22:00:53
Done.
|
+ exitStatus, |
+ ExitStatus::COUNT); |
+ } |
+ |
if (file_size == 0) { |
// Empty minidump, this process did not crash. Just remove the file. |
r = base::DeleteFile(minidump_path, false); |
@@ -122,13 +137,13 @@ void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path, |
void CrashDumpManager::BrowserChildProcessHostDisconnected( |
const content::ChildProcessData& data) { |
- OnChildExit(data.id, data.handle); |
+ OnChildExit(data.id, data.handle, /* recordExitStatus */ false); |
} |
void CrashDumpManager::BrowserChildProcessCrashed( |
const content::ChildProcessData& data, |
int exit_code) { |
- OnChildExit(data.id, data.handle); |
+ OnChildExit(data.id, data.handle, /* recordExitStatus */ false); |
} |
void CrashDumpManager::Observe(int type, |
@@ -142,7 +157,17 @@ void CrashDumpManager::Observe(int type, |
case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { |
content::RenderProcessHost* rph = |
content::Source<content::RenderProcessHost>(source).ptr(); |
- OnChildExit(rph->GetID(), rph->GetHandle()); |
+ content::RenderProcessHost::RendererClosedDetails* process_details = |
+ content::Details<content::RenderProcessHost::RendererClosedDetails>( |
+ details).ptr(); |
+ bool recordExitStatus = false; |
+ // Only record OOM protected renderers that die while the app is in the |
+ // foreground. This matches with conditions in TabWebContentsObserver. |
+ if (process_details->status == base::TERMINATION_STATUS_OOM_PROTECTED && |
+ base::android::ApplicationStatusListener::HasVisibleActivities()) { |
+ recordExitStatus = true; |
+ } |
+ OnChildExit(rph->GetID(), rph->GetHandle(), recordExitStatus); |
break; |
} |
default: |
@@ -152,7 +177,8 @@ void CrashDumpManager::Observe(int type, |
} |
void CrashDumpManager::OnChildExit(int child_process_id, |
- base::ProcessHandle pid) { |
+ base::ProcessHandle pid, |
+ bool recordExitStatus) { |
base::FilePath minidump_path; |
{ |
base::AutoLock auto_lock(child_process_id_to_minidump_path_lock_); |
@@ -168,7 +194,10 @@ void CrashDumpManager::OnChildExit(int child_process_id, |
} |
BrowserThread::PostTask( |
BrowserThread::FILE, FROM_HERE, |
- base::Bind(&CrashDumpManager::ProcessMinidump, minidump_path, pid)); |
+ base::Bind(&CrashDumpManager::ProcessMinidump, |
+ minidump_path, |
+ pid, |
+ recordExitStatus)); |
} |
} // namespace breakpad |