Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/metrics/ios_stability_metrics_provider.h" | 5 #include "ios/chrome/browser/metrics/ios_stability_metrics_provider.h" |
| 6 | 6 |
| 7 #include <Foundation/Foundation.h> | 7 #include <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 IOSStabilityMetricsProvider::~IOSStabilityMetricsProvider() { | 32 IOSStabilityMetricsProvider::~IOSStabilityMetricsProvider() { |
| 33 } | 33 } |
| 34 | 34 |
| 35 bool IOSStabilityMetricsProvider::HasInitialStabilityMetrics() { | 35 bool IOSStabilityMetricsProvider::HasInitialStabilityMetrics() { |
| 36 return true; | 36 return true; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void IOSStabilityMetricsProvider::ProvideInitialStabilityMetrics( | 39 void IOSStabilityMetricsProvider::ProvideInitialStabilityMetrics( |
| 40 metrics::SystemProfileProto* system_profile_proto) { | 40 metrics::SystemProfileProto* system_profile_proto) { |
| 41 // If this is the first launch after an upgrade, existing crash reports | |
| 42 // may have been deleted before this code runs, so log this case in its | |
| 43 // own bucket. | |
| 44 if (IsFirstLaunchAfterUpgrade()) { | |
| 45 LogShutdownType(FIRST_LAUNCH_AFTER_UPGRADE); | |
| 46 return; | |
| 47 } | |
| 48 | |
| 49 // If the last app lifetime did not end with a crash, then log it as a | 41 // If the last app lifetime did not end with a crash, then log it as a |
| 50 // normal shutdown while in the background. | 42 // normal shutdown while in the background. |
| 51 if (metrics_service_->WasLastShutdownClean()) { | 43 if (metrics_service_->WasLastShutdownClean()) { |
| 52 LogShutdownType(SHUTDOWN_IN_BACKGROUND); | 44 LogShutdownType(SHUTDOWN_IN_BACKGROUND); |
| 53 return; | 45 return; |
| 54 } | 46 } |
| 55 | 47 |
| 48 // If this is the first launch after an upgrade, existing crash reports | |
| 49 // may have been deleted before this code runs, so log this case in its | |
| 50 // own bucket. | |
| 51 if (IsFirstLaunchAfterUpgrade()) { | |
|
stuartmorgan
2015/07/21 20:16:24
I realized after suggesting just flipping these th
lpromero
2015/07/21 22:12:07
That's indeed to be checked. I will check that tom
Olivier
2015/07/22 16:54:19
If the WasLastShutdownClean is not reliable after
stuartmorgan
2015/07/28 22:27:43
The comment for this block is still true AFAICT. M
Olivier
2015/07/29 08:01:27
Even if we clean the reports, we can keep track th
| |
| 52 LogShutdownType(SHUTDOWN_IN_FOREGROUND_UNKNOWN_LOG_STATE); | |
| 53 return; | |
| 54 } | |
| 55 | |
| 56 // If the last app lifetime ended in a crash, log the type of crash. | 56 // If the last app lifetime ended in a crash, log the type of crash. |
| 57 MobileSessionShutdownType shutdown_type; | 57 MobileSessionShutdownType shutdown_type; |
| 58 const bool with_crash_log = | 58 const bool with_crash_log = |
| 59 HasUploadedCrashReportsInBackground() || HasCrashLogs(); | 59 HasUploadedCrashReportsInBackground() || HasCrashLogs(); |
| 60 if (ReceivedMemoryWarningBeforeLastShutdown()) { | 60 if (ReceivedMemoryWarningBeforeLastShutdown()) { |
| 61 if (with_crash_log) { | 61 if (with_crash_log) { |
| 62 shutdown_type = SHUTDOWN_IN_FOREGROUND_WITH_CRASH_LOG_WITH_MEMORY_WARNING; | 62 shutdown_type = SHUTDOWN_IN_FOREGROUND_WITH_CRASH_LOG_WITH_MEMORY_WARNING; |
| 63 } else { | 63 } else { |
| 64 shutdown_type = SHUTDOWN_IN_FOREGROUND_NO_CRASH_LOG_WITH_MEMORY_WARNING; | 64 shutdown_type = SHUTDOWN_IN_FOREGROUND_NO_CRASH_LOG_WITH_MEMORY_WARNING; |
| 65 } | 65 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool IOSStabilityMetricsProvider::HasUploadedCrashReportsInBackground() { | 84 bool IOSStabilityMetricsProvider::HasUploadedCrashReportsInBackground() { |
| 85 return [CrashReportBackgroundUploader hasUploadedCrashReportsInBackground]; | 85 return [CrashReportBackgroundUploader hasUploadedCrashReportsInBackground]; |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool IOSStabilityMetricsProvider::ReceivedMemoryWarningBeforeLastShutdown() { | 88 bool IOSStabilityMetricsProvider::ReceivedMemoryWarningBeforeLastShutdown() { |
| 89 return [[PreviousSessionInfo sharedInstance] | 89 return [[PreviousSessionInfo sharedInstance] |
| 90 didSeeMemoryWarningShortlyBeforeTerminating]; | 90 didSeeMemoryWarningShortlyBeforeTerminating]; |
| 91 } | 91 } |
| OLD | NEW |