Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Record to UMA when a durable origin is passed over for eviction.
Browse files Browse the repository at this point in the history
BUG=521075

Review URL: https://codereview.chromium.org/1305383002

Cr-Commit-Position: refs/heads/master@{#345798}
  • Loading branch information
davidsgrogan authored and Commit bot committed Aug 27, 2015
1 parent 18d1a7f commit ebddb0b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
41 changes: 36 additions & 5 deletions storage/browser/quota/quota_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/metrics/histogram_macros.h"
#include "sql/connection.h"
#include "sql/meta_table.h"
#include "sql/statement.h"
Expand All @@ -35,6 +36,24 @@ bool VerifyValidQuotaConfig(const char* key) {

const int kCommitIntervalMs = 30000;

enum OriginType {
// This enum is logged to UMA so only append to it - don't change
// the meaning of the existing values.
OTHER = 0,
NONE = 1,
GOOGLE_DURABLE = 2,
NON_GOOGLE_DURABLE = 3,
GOOGLE_UNLIMITED_EXTENSION = 4,
NON_GOOGLE_UNLIMITED_EXTENSION = 5,
IN_USE = 6,

MAX_ORIGIN_TYPE
};

void HistogramOriginType(const OriginType& entry) {
UMA_HISTOGRAM_ENUMERATION("Quota.LRUOriginTypes", entry, MAX_ORIGIN_TYPE);
}

} // anonymous namespace

// static
Expand Down Expand Up @@ -340,16 +359,28 @@ bool QuotaDatabase::GetLRUOrigin(

while (statement.Step()) {
GURL url(statement.ColumnString(0));
if (exceptions.find(url) != exceptions.end())
continue;
if (special_storage_policy &&
(special_storage_policy->IsStorageDurable(url) ||
special_storage_policy->IsStorageUnlimited(url)))
if (exceptions.find(url) != exceptions.end()) {
HistogramOriginType(IN_USE);
continue;
}
if (special_storage_policy) {
bool is_google = url.DomainIs("google.com");
if (special_storage_policy->IsStorageDurable(url)) {
HistogramOriginType(is_google ? GOOGLE_DURABLE : NON_GOOGLE_DURABLE);
continue;
}
if (special_storage_policy->IsStorageUnlimited(url)) {
HistogramOriginType(is_google ? GOOGLE_UNLIMITED_EXTENSION
: NON_GOOGLE_UNLIMITED_EXTENSION);
continue;
}
}
HistogramOriginType(OTHER);
*origin = url;
return true;
}

HistogramOriginType(NONE);
*origin = GURL();
return statement.Succeeded();
}
Expand Down
18 changes: 18 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35253,6 +35253,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<summary>Initial quota for global temporary storage.</summary>
</histogram>

<histogram name="Quota.LRUOriginTypes" enum="QuotaOriginTypes">
<owner>[email protected]</owner>
<summary>
Types of origins that are initially selected for eviction via LRU. Some of
these types are exempt from eviction.
</summary>
</histogram>

<histogram name="Quota.NumberOfEvictedOriginsPerRound">
<owner>[email protected]</owner>
<summary>Number of evicted origins per round.</summary>
Expand Down Expand Up @@ -69059,6 +69067,16 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="5" label="NOTIFY_FACTORY_OF_SESSION_CLOSED"/>
</enum>

<enum name="QuotaOriginTypes" type="int">
<int value="0" label="Other"/>
<int value="1" label="None"/>
<int value="2" label="google.com durable"/>
<int value="3" label="non-google.com durable"/>
<int value="4" label="google.com unlimitedStorage app/ext"/>
<int value="5" label="non-google.com unlimitedStorage app/ext"/>
<int value="6" label="In use"/>
</enum>

<enum name="RapporDiscardReason" type="int">
<int value="0" label="Upload Success"/>
<int value="1" label="Upload Rejected"/>
Expand Down

0 comments on commit ebddb0b

Please sign in to comment.