Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Side by Side Diff: extensions/browser/api/storage/local_value_store_cache.cc

Issue 595683002: Gather metrics on hosted app unlimitedStorage usage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/storage/local_value_store_cache.h" 5 #include "extensions/browser/api/storage/local_value_store_cache.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/metrics/histogram.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 #include "extensions/browser/api/storage/settings_storage_factory.h" 14 #include "extensions/browser/api/storage/settings_storage_factory.h"
14 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h" 15 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h"
15 #include "extensions/browser/api/storage/weak_unlimited_settings_storage.h" 16 #include "extensions/browser/api/storage/weak_unlimited_settings_storage.h"
16 #include "extensions/browser/value_store/value_store.h" 17 #include "extensions/browser/value_store/value_store.h"
17 #include "extensions/common/api/storage.h" 18 #include "extensions/common/api/storage.h"
18 #include "extensions/common/constants.h" 19 #include "extensions/common/constants.h"
19 #include "extensions/common/extension.h" 20 #include "extensions/common/extension.h"
20 #include "extensions/common/permissions/api_permission.h" 21 #include "extensions/common/permissions/api_permission.h"
21 #include "extensions/common/permissions/permissions_data.h" 22 #include "extensions/common/permissions/permissions_data.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 StorageMap::iterator iter = storage_map_.find(extension->id()); 85 StorageMap::iterator iter = storage_map_.find(extension->id());
85 if (iter != storage_map_.end()) 86 if (iter != storage_map_.end())
86 return iter->second.get(); 87 return iter->second.get();
87 88
88 const base::FilePath& file_path = 89 const base::FilePath& file_path =
89 extension->is_app() ? app_base_path_ : extension_base_path_; 90 extension->is_app() ? app_base_path_ : extension_base_path_;
90 linked_ptr<SettingsStorageQuotaEnforcer> storage( 91 linked_ptr<SettingsStorageQuotaEnforcer> storage(
91 new SettingsStorageQuotaEnforcer( 92 new SettingsStorageQuotaEnforcer(
92 quota_, storage_factory_->Create(file_path, extension->id()))); 93 quota_, storage_factory_->Create(file_path, extension->id())));
93 DCHECK(storage.get()); 94 DCHECK(storage.get());
95
96 if (extension->permissions_data()->HasAPIPermission(
97 APIPermission::kUnlimitedStorage) &&
98 extension->is_hosted_app()) {
99 // We're interested in the amount of space hosted apps are using. Record it
100 // the first time we load the storage for the extension.
101 UMA_HISTOGRAM_MEMORY_KB("Extensions.HostedAppUnlimitedStorageUsage",
102 storage->GetBytesInUse());
103 }
104
94 storage_map_[extension->id()] = storage; 105 storage_map_[extension->id()] = storage;
95 return storage.get(); 106 return storage.get();
96 } 107 }
97 108
98 } // namespace extensions 109 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698