summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 21:56:53 +0000
committerdpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 21:56:53 +0000
commit923c8ec934dc20bce26ed44620b439f97574c9b8 (patch)
treebedfb4f58ec7fbc83adce17190544c2e65be3133
parent4b25dacdfcd4d5bbc05166a959b59c4be4531399 (diff)
downloadchromium_src-923c8ec934dc20bce26ed44620b439f97574c9b8.zip
chromium_src-923c8ec934dc20bce26ed44620b439f97574c9b8.tar.gz
chromium_src-923c8ec934dc20bce26ed44620b439f97574c9b8.tar.bz2
Add UMA stats for ExtensionCache
Reported metrics: - number of extensions in cache - size of cache on disk BUG=316371 TEST=manual Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=247760 Review URL: https://codereview.chromium.org/148013004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248046 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/updater/extension_cache_impl.cc10
-rw-r--r--chrome/browser/extensions/updater/local_extension_cache.cc21
-rw-r--r--chrome/browser/extensions/updater/local_extension_cache.h12
-rw-r--r--tools/metrics/histograms/histograms.xml14
4 files changed, 50 insertions, 7 deletions
diff --git a/chrome/browser/extensions/updater/extension_cache_impl.cc b/chrome/browser/extensions/updater/extension_cache_impl.cc
index ddf0cd2..53addd5 100644
--- a/chrome/browser/extensions/updater/extension_cache_impl.cc
+++ b/chrome/browser/extensions/updater/extension_cache_impl.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/memory/singleton.h"
+#include "base/metrics/histogram.h"
#include "base/sequenced_task_runner.h"
#include "base/stl_util.h"
#include "base/threading/sequenced_worker_pool.h"
@@ -104,6 +105,15 @@ void ExtensionCacheImpl::OnCacheInitialized() {
it->Run();
}
init_callbacks_.clear();
+
+ uint64 cache_size = 0;
+ size_t extensions_count = 0;
+ if (cache_->GetStatistics(&cache_size, &extensions_count)) {
+ UMA_HISTOGRAM_COUNTS_100("Extensions.ExtensionCacheCount",
+ extensions_count);
+ UMA_HISTOGRAM_MEMORY_MB("Extensions.ExtensionCacheSize",
+ cache_size / (1024 * 1024));
+ }
}
void ExtensionCacheImpl::Observe(int type,
diff --git a/chrome/browser/extensions/updater/local_extension_cache.cc b/chrome/browser/extensions/updater/local_extension_cache.cc
index 7411805..b88e802 100644
--- a/chrome/browser/extensions/updater/local_extension_cache.cc
+++ b/chrome/browser/extensions/updater/local_extension_cache.cc
@@ -29,7 +29,7 @@ const char LocalExtensionCache::kCacheReadyFlagFileName[] = ".initialized";
LocalExtensionCache::LocalExtensionCache(
const base::FilePath& cache_dir,
- size_t max_cache_size,
+ uint64 max_cache_size,
const base::TimeDelta& max_cache_age,
const scoped_refptr<base::SequencedTaskRunner>& backend_task_runner)
: cache_dir_(cache_dir),
@@ -151,6 +151,21 @@ bool LocalExtensionCache::RemoveExtension(const std::string& id) {
return true;
}
+bool LocalExtensionCache::GetStatistics(uint64* cache_size,
+ size_t* extensions_count) {
+ if (state_ != kReady)
+ return false;
+
+ *cache_size = 0;
+ for (CacheMap::iterator it = cached_extensions_.begin();
+ it != cached_extensions_.end(); ++it) {
+ *cache_size += it->second.size;
+ }
+ *extensions_count = cached_extensions_.size();
+
+ return true;
+}
+
void LocalExtensionCache::SetCacheStatusPollingDelayForTests(
const base::TimeDelta& delay) {
cache_status_polling_delay_ = delay;
@@ -425,7 +440,7 @@ void LocalExtensionCache::CleanUp() {
std::vector<CacheMap::iterator> items;
items.reserve(cached_extensions_.size());
- size_t total_size = 0;
+ uint64_t total_size = 0;
for (CacheMap::iterator it = cached_extensions_.begin();
it != cached_extensions_.end(); ++it) {
items.push_back(it);
@@ -447,7 +462,7 @@ void LocalExtensionCache::CleanUp() {
LocalExtensionCache::CacheItemInfo::CacheItemInfo(
const std::string& version,
const base::Time& last_used,
- const size_t size,
+ uint64 size,
const base::FilePath& file_path)
: version(version), last_used(last_used), size(size), file_path(file_path) {
}
diff --git a/chrome/browser/extensions/updater/local_extension_cache.h b/chrome/browser/extensions/updater/local_extension_cache.h
index 604b670..63652ba 100644
--- a/chrome/browser/extensions/updater/local_extension_cache.h
+++ b/chrome/browser/extensions/updater/local_extension_cache.h
@@ -32,7 +32,7 @@ class LocalExtensionCache {
// means that all unused cache items will be removed on Shutdown.
// All file I/O is done via the |backend_task_runner|.
LocalExtensionCache(const base::FilePath& cache_dir,
- size_t max_cache_size,
+ uint64 max_cache_size,
const base::TimeDelta& max_cache_age,
const scoped_refptr<base::SequencedTaskRunner>&
backend_task_runner);
@@ -73,6 +73,10 @@ class LocalExtensionCache {
// removed from disk too.
bool RemoveExtension(const std::string& id);
+ // Return cache statistics. Returns |false| if cache is not ready.
+ bool GetStatistics(uint64* cache_size,
+ size_t* extensions_count);
+
bool is_ready() const { return state_ == kReady; }
bool is_uninitialized() const { return state_ == kUninitialized; }
bool is_shutdown() const { return state_ == kShutdown; }
@@ -84,12 +88,12 @@ class LocalExtensionCache {
struct CacheItemInfo {
std::string version;
base::Time last_used;
- int64 size;
+ uint64 size;
base::FilePath file_path;
CacheItemInfo(const std::string& version,
const base::Time& last_used,
- const size_t size,
+ uint64 size,
const base::FilePath& file_path);
};
typedef std::map<std::string, CacheItemInfo> CacheMap;
@@ -175,7 +179,7 @@ class LocalExtensionCache {
base::FilePath cache_dir_;
// Maximum size of cache dir on disk.
- size_t max_cache_size_;
+ uint64 max_cache_size_;
// Minimal age of unused item in cache, items prior to this age will be
// deleted on shutdown.
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index f07e767..a71c41a 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -4432,6 +4432,20 @@ other types of suffix sets.
<summary>The time for an extension's event page to load.</summary>
</histogram>
+<histogram name="Extensions.ExtensionCacheCount">
+ <summary>
+ Number of cached extensions on disk. Reported on Chrome OS during user
+ session start.
+ </summary>
+</histogram>
+
+<histogram name="Extensions.ExtensionCacheSize" units="MB">
+ <summary>
+ Total size of .crx files in cache on disk. Reported on Chrome OS during user
+ session start.
+ </summary>
+</histogram>
+
<histogram name="Extensions.ExtensionInstalled">
<summary>An extension has been installed.</summary>
</histogram>