Commit b67c05fc authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Add metrics for OffTheRecord profile destruction.

Metrics are added to measure different code paths in off-the-record
profile destruction, specifically when destruction is delayed due to
delayed RPHs.

Bug: 1033903
Change-Id: Ibc8c82c3f8c4d569c34e57aad1b508eff9eb32c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440625Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814111}
parent c5adcd0e
...@@ -33,6 +33,7 @@ class ChromeZoomLevelPrefs; ...@@ -33,6 +33,7 @@ class ChromeZoomLevelPrefs;
class ExtensionSpecialStoragePolicy; class ExtensionSpecialStoragePolicy;
class PrefService; class PrefService;
class PrefStore; class PrefStore;
class ProfileDestroyer;
class ProfileKey; class ProfileKey;
class TestingProfile; class TestingProfile;
...@@ -146,6 +147,7 @@ class Profile : public content::BrowserContext { ...@@ -146,6 +147,7 @@ class Profile : public content::BrowserContext {
#endif #endif
private: private:
friend class ProfileDestroyer;
friend std::ostream& operator<<(std::ostream& out, friend std::ostream& operator<<(std::ostream& out,
const OTRProfileID& profile_id); const OTRProfileID& profile_id);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/location.h" #include "base/location.h"
#include "base/metrics/histogram_macros.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
...@@ -25,6 +26,15 @@ const int64_t kTimerDelaySeconds = 5; ...@@ -25,6 +26,15 @@ const int64_t kTimerDelaySeconds = 5;
const int64_t kTimerDelaySeconds = 1; const int64_t kTimerDelaySeconds = 1;
#endif #endif
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class ProfileDestructionType {
kImmediately = 0,
kDelayed = 1,
kDelayedAndCrashed = 2,
kMaxValue = kDelayedAndCrashed,
};
} // namespace } // namespace
ProfileDestroyer::DestroyerSet* ProfileDestroyer::pending_destroyers_ = nullptr; ProfileDestroyer::DestroyerSet* ProfileDestroyer::pending_destroyers_ = nullptr;
...@@ -38,8 +48,6 @@ void ProfileDestroyer::DestroyProfileWhenAppropriate(Profile* const profile) { ...@@ -38,8 +48,6 @@ void ProfileDestroyer::DestroyProfileWhenAppropriate(Profile* const profile) {
DCHECK(profile); DCHECK(profile);
profile->MaybeSendDestroyedNotification(); profile->MaybeSendDestroyedNotification();
// TODO(https://crbug.com/1033903): If regular profile has OTRs and they have
// hosts, create a |ProfileDestroyer| instead.
if (!profile->IsOffTheRecord()) { if (!profile->IsOffTheRecord()) {
DestroyRegularProfileNow(profile); DestroyRegularProfileNow(profile);
return; return;
...@@ -63,8 +71,9 @@ void ProfileDestroyer::DestroyProfileWhenAppropriate(Profile* const profile) { ...@@ -63,8 +71,9 @@ void ProfileDestroyer::DestroyProfileWhenAppropriate(Profile* const profile) {
void ProfileDestroyer::DestroyOffTheRecordProfileNow(Profile* const profile) { void ProfileDestroyer::DestroyOffTheRecordProfileNow(Profile* const profile) {
DCHECK(profile); DCHECK(profile);
DCHECK(profile->IsOffTheRecord()); DCHECK(profile->IsOffTheRecord());
TRACE_EVENT1("shutdown", "ProfileDestroyer::DestroyOffTheRecordProfileNow", TRACE_EVENT2("shutdown", "ProfileDestroyer::DestroyOffTheRecordProfileNow",
"profile", profile); "profile", profile, "OTRProfileID",
profile->GetOTRProfileID().ToString());
if (ResetPendingDestroyers(profile)) { if (ResetPendingDestroyers(profile)) {
// We want to signal this in debug builds so that we don't lose sight of // We want to signal this in debug builds so that we don't lose sight of
// these potential leaks, but we handle it in release so that we don't // these potential leaks, but we handle it in release so that we don't
...@@ -73,6 +82,8 @@ void ProfileDestroyer::DestroyOffTheRecordProfileNow(Profile* const profile) { ...@@ -73,6 +82,8 @@ void ProfileDestroyer::DestroyOffTheRecordProfileNow(Profile* const profile) {
} }
DCHECK(profile->GetOriginalProfile()); DCHECK(profile->GetOriginalProfile());
profile->GetOriginalProfile()->DestroyOffTheRecordProfile(profile); profile->GetOriginalProfile()->DestroyOffTheRecordProfile(profile);
UMA_HISTOGRAM_ENUMERATION("Profile.Destroyer.OffTheRecord",
ProfileDestructionType::kImmediately);
} }
// static // static
...@@ -157,8 +168,8 @@ ProfileDestroyer::ProfileDestroyer(Profile* const profile, HostSet* hosts) ...@@ -157,8 +168,8 @@ ProfileDestroyer::ProfileDestroyer(Profile* const profile, HostSet* hosts)
} }
ProfileDestroyer::~ProfileDestroyer() { ProfileDestroyer::~ProfileDestroyer() {
TRACE_EVENT1("shutdown", "ProfileDestroyer::~ProfileDestroyer", "profile", TRACE_EVENT2("shutdown", "ProfileDestroyer::~ProfileDestroyer", "profile",
profile_); profile_, "remaining_hosts", num_hosts_);
// Check again, in case other render hosts were added while we were // Check again, in case other render hosts were added while we were
// waiting for the previous ones to go away... // waiting for the previous ones to go away...
...@@ -168,6 +179,10 @@ ProfileDestroyer::~ProfileDestroyer() { ...@@ -168,6 +179,10 @@ ProfileDestroyer::~ProfileDestroyer() {
// Don't wait for pending registrations, if any, these hosts are buggy. // Don't wait for pending registrations, if any, these hosts are buggy.
// Note: this can happen, but if so, it's better to crash here than wait // Note: this can happen, but if so, it's better to crash here than wait
// for the host to dereference a deleted Profile. http://crbug.com/248625 // for the host to dereference a deleted Profile. http://crbug.com/248625
UMA_HISTOGRAM_ENUMERATION("Profile.Destroyer.OffTheRecord",
num_hosts_
? ProfileDestructionType::kDelayedAndCrashed
: ProfileDestructionType::kDelayed);
CHECK_EQ(0U, num_hosts_) << "Some render process hosts were not " CHECK_EQ(0U, num_hosts_) << "Some render process hosts were not "
<< "destroyed early enough!"; << "destroyed early enough!";
DCHECK(pending_destroyers_ != NULL); DCHECK(pending_destroyers_ != NULL);
......
...@@ -59737,6 +59737,12 @@ https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf ...@@ -59737,6 +59737,12 @@ https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf
</int> </int>
</enum> </enum>
<enum name="ProfileDestructionType">
<int value="0" label="Immediately"/>
<int value="1" label="Delayed"/>
<int value="2" label="Delayed and Crashed"/>
</enum>
<enum name="ProfileErrorType"> <enum name="ProfileErrorType">
<int value="0" label="History error"/> <int value="0" label="History error"/>
<int value="1" label="Preferences error"/> <int value="1" label="Preferences error"/>
...@@ -152,6 +152,17 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -152,6 +152,17 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram name="Profile.Destroyer.OffTheRecord" enum="ProfileDestructionType"
expires_after="M95">
<owner>rhalavati@chromium.org</owner>
<owner>chrome-privacy-core@google.com</owner>
<summary>
Track if the off-the-record profile was immidiately destroyed when asked to
be destroyed, or was scheduled for a delayed destruction, and possibly was
not destroyed properly after the delay and was crashed.
</summary>
</histogram>
<histogram name="Profile.DiceUI.GaiaAccountsStale" enum="BooleanStale" <histogram name="Profile.DiceUI.GaiaAccountsStale" enum="BooleanStale"
expires_after="M80"> expires_after="M80">
<owner>msarda@chromium.org</owner> <owner>msarda@chromium.org</owner>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment