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" | |
13 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
14 #include "extensions/browser/api/storage/settings_storage_factory.h" | 13 #include "extensions/browser/api/storage/settings_storage_factory.h" |
15 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h" | 14 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h" |
16 #include "extensions/browser/api/storage/weak_unlimited_settings_storage.h" | 15 #include "extensions/browser/api/storage/weak_unlimited_settings_storage.h" |
17 #include "extensions/browser/value_store/value_store.h" | 16 #include "extensions/browser/value_store/value_store.h" |
18 #include "extensions/common/api/storage.h" | 17 #include "extensions/common/api/storage.h" |
19 #include "extensions/common/constants.h" | 18 #include "extensions/common/constants.h" |
20 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
21 #include "extensions/common/permissions/api_permission.h" | 20 #include "extensions/common/permissions/api_permission.h" |
22 #include "extensions/common/permissions/permissions_data.h" | 21 #include "extensions/common/permissions/permissions_data.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 if (iter != storage_map_.end()) | 85 if (iter != storage_map_.end()) |
87 return iter->second.get(); | 86 return iter->second.get(); |
88 | 87 |
89 const base::FilePath& file_path = | 88 const base::FilePath& file_path = |
90 extension->is_app() ? app_base_path_ : extension_base_path_; | 89 extension->is_app() ? app_base_path_ : extension_base_path_; |
91 linked_ptr<SettingsStorageQuotaEnforcer> storage( | 90 linked_ptr<SettingsStorageQuotaEnforcer> storage( |
92 new SettingsStorageQuotaEnforcer( | 91 new SettingsStorageQuotaEnforcer( |
93 quota_, storage_factory_->Create(file_path, extension->id()))); | 92 quota_, storage_factory_->Create(file_path, extension->id()))); |
94 DCHECK(storage.get()); | 93 DCHECK(storage.get()); |
95 | 94 |
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 | |
105 storage_map_[extension->id()] = storage; | 95 storage_map_[extension->id()] = storage; |
106 return storage.get(); | 96 return storage.get(); |
107 } | 97 } |
108 | 98 |
109 } // namespace extensions | 99 } // namespace extensions |
OLD | NEW |