Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // in KB the first time we load the storage for the extension. | |
| 101 UMA_HISTOGRAM_COUNTS_100("Extensions.HostedAppUnlimitedStorageUsage", | |
|
Mark P
2014/09/23 17:12:58
Are you sure you don't want one of the _MEMORY_ hi
Devlin
2014/09/23 20:58:03
Oh, didn't know those existed. Done. (To confirm
Mark P
2014/09/23 22:07:51
Looking at the code, it appears the answer is yes,
| |
| 102 storage->GetBytesInUse() / 1024); | |
| 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 |
| OLD | NEW |