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

Side by Side Diff: chrome/browser/extensions/extension_storage_monitor.cc

Issue 2923663002: ExtensionStorageMonitor: use smaller, self-registering StorageObservers (Closed)
Patch Set: Remove lame comment. Created 3 years, 6 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
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 "chrome/browser/extensions/extension_storage_monitor.h" 5 #include "chrome/browser/extensions/extension_storage_monitor.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 27 matching lines...) Expand all
38 #include "ui/message_center/notifier_settings.h" 38 #include "ui/message_center/notifier_settings.h"
39 #include "ui/message_center/views/constants.h" 39 #include "ui/message_center/views/constants.h"
40 40
41 using content::BrowserThread; 41 using content::BrowserThread;
42 42
43 namespace extensions { 43 namespace extensions {
44 44
45 namespace { 45 namespace {
46 46
47 // The rate at which we would like to observe storage events. 47 // The rate at which we would like to observe storage events.
48 const int kStorageEventRateSec = 30; 48 constexpr base::TimeDelta kStorageEventRate = base::TimeDelta::FromSeconds(30);
49 49
50 // Set the thresholds for the first notification. Once a threshold is exceeded, 50 // Set the thresholds for the first notification. Once a threshold is exceeded,
51 // it will be doubled to throttle notifications. 51 // it will be doubled to throttle notifications.
52 const int64_t kMBytes = 1024 * 1024; 52 const int64_t kMBytes = 1024 * 1024;
53 const int64_t kExtensionInitialThreshold = 1000 * kMBytes; 53 const int64_t kExtensionInitialThreshold = 1000 * kMBytes;
54 54
55 // Notifications have an ID so that we can update them. 55 // Notifications have an ID so that we can update them.
56 const char kNotificationIdFormat[] = "ExtensionStorageMonitor-$1-$2"; 56 const char kNotificationIdFormat[] = "ExtensionStorageMonitor-$1-$2";
57 const char kSystemNotifierId[] = "ExtensionStorageMonitor"; 57 const char kSystemNotifierId[] = "ExtensionStorageMonitor";
58 58
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // Note we use COUNTS_100 (instead of PERCENT) because this can potentially 92 // Note we use COUNTS_100 (instead of PERCENT) because this can potentially
93 // exceed 100%. 93 // exceed 100%.
94 UMA_HISTOGRAM_COUNTS_100( 94 UMA_HISTOGRAM_COUNTS_100(
95 "Extensions.HostedAppUnlimitedStorageTemporaryStorageUsage", 95 "Extensions.HostedAppUnlimitedStorageTemporaryStorageUsage",
96 100.0 * usage / settings.per_host_quota); 96 100.0 * usage / settings.per_host_quota);
97 } 97 }
98 } 98 }
99 99
100 } // namespace 100 } // namespace
101 101
102 // StorageEventObserver monitors the storage usage of extensions and lives on 102 // SingleExtensionStorageObserver monitors the storage usage of one extension,
103 // the IO thread. When a threshold is exceeded, a message will be posted to the 103 // and lives on the IO thread. When a threshold is exceeded, a message will be
104 // UI thread, which displays the notification. 104 // posted to the ExtensionStorageMonitor on the UI thread, which displays the
105 class StorageEventObserver 105 // notification.
106 : public base::RefCountedThreadSafe<StorageEventObserver, 106 class SingleExtensionStorageObserver : public storage::StorageObserver {
107 BrowserThread::DeleteOnIOThread>,
108 public storage::StorageObserver {
109 public: 107 public:
110 explicit StorageEventObserver( 108 SingleExtensionStorageObserver(
111 base::WeakPtr<ExtensionStorageMonitor> storage_monitor) 109 ExtensionStorageMonitorIOHelper* io_helper,
112 : storage_monitor_(storage_monitor) { 110 const std::string& extension_id,
111 scoped_refptr<storage::QuotaManager> quota_manager,
112 const GURL& origin,
113 int64_t next_threshold,
114 base::TimeDelta rate,
115 bool should_uma)
116 : io_helper_(io_helper),
117 extension_id_(extension_id),
118 quota_manager_(std::move(quota_manager)),
119 next_threshold_(next_threshold),
120 should_uma_(should_uma) {
121 // We always observe persistent storage usage.
122 storage::StorageObserver::MonitorParams params(
123 storage::kStorageTypePersistent, origin, rate, false);
124 quota_manager_->AddStorageObserver(this, params);
125 if (should_uma) {
126 // And if this is for uma, we also observe temporary storage usage.
127 MonitorParams temporary_params(storage::kStorageTypeTemporary, origin,
128 rate, false);
129 quota_manager_->AddStorageObserver(this, temporary_params);
130 }
113 } 131 }
114 132
115 // Register as an observer for the extension's storage events. 133 ~SingleExtensionStorageObserver() override {
134 // This removes all our registrations.
135 quota_manager_->RemoveStorageObserver(this);
136 }
137
138 void set_next_threshold(int64_t next_threshold) {
139 next_threshold_ = next_threshold;
140 }
141
142 // storage::StorageObserver implementation.
143 void OnStorageEvent(const Event& event) override;
144
145 private:
146 // The IO thread helper that owns this instance.
147 ExtensionStorageMonitorIOHelper* const io_helper_;
148
149 // The extension associated with the origin under observation.
150 const std::string extension_id_;
151
152 // The quota manager being observed, corresponding to the extension's storage
153 // partition.
154 scoped_refptr<storage::QuotaManager> quota_manager_;
155
156 // If |next_threshold| is -1, it signifies that we should not enforce (and
157 // only track) storage for this extension.
158 int64_t next_threshold_;
159
160 const bool should_uma_;
161
162 DISALLOW_COPY_AND_ASSIGN(SingleExtensionStorageObserver);
163 };
164
165 // The IO thread part of ExtensionStorageMonitor. This class manages a flock of
166 // SingleExtensionStorageObserver instances, one for each tracked extension.
167 // This class is owned by, and reports back to, ExtensionStorageMonitor.
168 class ExtensionStorageMonitorIOHelper
169 : public base::RefCountedThreadSafe<ExtensionStorageMonitorIOHelper,
170 BrowserThread::DeleteOnIOThread> {
171 public:
172 explicit ExtensionStorageMonitorIOHelper(
173 base::WeakPtr<ExtensionStorageMonitor> extension_storage_monitor)
174 : extension_storage_monitor_(std::move(extension_storage_monitor)) {}
175
176 // Register a StorageObserver for the extension's storage events.
116 void StartObservingForExtension( 177 void StartObservingForExtension(
117 scoped_refptr<storage::QuotaManager> quota_manager, 178 scoped_refptr<storage::QuotaManager> quota_manager,
118 const std::string& extension_id, 179 const std::string& extension_id,
119 const GURL& site_url, 180 const GURL& site_url,
120 int64_t next_threshold, 181 int64_t next_threshold,
121 const base::TimeDelta& rate, 182 const base::TimeDelta& rate,
122 bool should_uma) { 183 bool should_uma) {
123 DCHECK_CURRENTLY_ON(BrowserThread::IO); 184 DCHECK_CURRENTLY_ON(BrowserThread::IO);
124 DCHECK(quota_manager.get()); 185 DCHECK(quota_manager.get());
125 186
126 GURL origin = site_url.GetOrigin(); 187 DCHECK(!FindObserver(extension_id));
127 StorageState& state = origin_state_map_[origin];
128 state.quota_manager = quota_manager;
129 state.extension_id = extension_id;
130 state.next_threshold = next_threshold;
131 state.should_uma = should_uma;
132 188
133 // We always observe persistent storage usage. 189 storage_observers_[extension_id] =
134 storage::StorageObserver::MonitorParams params( 190 base::MakeUnique<SingleExtensionStorageObserver>(
135 storage::kStorageTypePersistent, origin, rate, false); 191 this, extension_id, std::move(quota_manager), site_url.GetOrigin(),
136 quota_manager->AddStorageObserver(this, params); 192 next_threshold, rate, should_uma);
137 if (should_uma) {
138 // And if this is for uma, we also observe temporary storage usage.
139 MonitorParams temporary_params(
140 storage::kStorageTypeTemporary, origin, rate, false);
141 quota_manager->AddStorageObserver(this, temporary_params);
142 }
143 } 193 }
144 194
145 // Updates the threshold for an extension already being monitored. 195 // Updates the threshold for an extension already being monitored.
146 void UpdateThresholdForExtension(const std::string& extension_id, 196 void UpdateThresholdForExtension(const std::string& extension_id,
147 int64_t next_threshold) { 197 int64_t next_threshold) {
148 DCHECK_CURRENTLY_ON(BrowserThread::IO); 198 DCHECK_CURRENTLY_ON(BrowserThread::IO);
149 199
150 for (OriginStorageStateMap::iterator it = origin_state_map_.begin(); 200 // Note that |extension_id| may not be in the map, since some extensions may
151 it != origin_state_map_.end(); 201 // be exempt from monitoring.
152 ++it) { 202 SingleExtensionStorageObserver* observer = FindObserver(extension_id);
153 if (it->second.extension_id == extension_id) { 203 if (observer)
154 it->second.next_threshold = next_threshold; 204 observer->set_next_threshold(next_threshold);
155 break;
156 }
157 }
158 } 205 }
159 206
160 // Deregister as an observer for the extension's storage events. 207 // Deregister as an observer for the extension's storage events.
161 void StopObservingForExtension(const std::string& extension_id) { 208 void StopObservingForExtension(const std::string& extension_id) {
162 DCHECK_CURRENTLY_ON(BrowserThread::IO); 209 DCHECK_CURRENTLY_ON(BrowserThread::IO);
163 210
164 for (OriginStorageStateMap::iterator it = origin_state_map_.begin(); 211 // Note that |extension_id| may not be in the map, since some extensions may
165 it != origin_state_map_.end(); ) { 212 // be exempt from monitoring.
166 if (it->second.extension_id == extension_id) { 213 storage_observers_.erase(extension_id);
167 storage::StorageObserver::Filter filter( 214 }
168 storage::kStorageTypePersistent, it->first); 215
169 it->second.quota_manager->RemoveStorageObserverForFilter(this, filter); 216 base::WeakPtr<ExtensionStorageMonitor> extension_storage_monitor() {
170 // We also need to unregister temporary storage observation, if this was 217 return extension_storage_monitor_;
171 // being tracked for uma. 218 }
172 if (it->second.should_uma) { 219
173 storage::StorageObserver::Filter temporary_filter( 220 private:
174 storage::kStorageTypeTemporary, it->first); 221 friend class base::DeleteHelper<ExtensionStorageMonitorIOHelper>;
175 it->second.quota_manager->RemoveStorageObserverForFilter(this, 222 friend struct content::BrowserThread::DeleteOnThread<
176 filter); 223 content::BrowserThread::IO>;
177 } 224
178 origin_state_map_.erase(it++); 225 ~ExtensionStorageMonitorIOHelper() {}
179 } else { 226
180 ++it; 227 SingleExtensionStorageObserver* FindObserver(
181 } 228 const std::string& extension_id) {
229 auto it = storage_observers_.find(extension_id);
230 if (it != storage_observers_.end())
231 return it->second.get();
232 return nullptr;
233 }
234
235 // Keys are extension IDs. Values are self-registering StorageObservers.
236 std::map<std::string, std::unique_ptr<SingleExtensionStorageObserver>>
237 storage_observers_;
238
239 base::WeakPtr<ExtensionStorageMonitor> extension_storage_monitor_;
240
241 DISALLOW_COPY_AND_ASSIGN(ExtensionStorageMonitorIOHelper);
242 };
243
244 void SingleExtensionStorageObserver::OnStorageEvent(const Event& event) {
245 if (should_uma_) {
246 if (event.filter.storage_type == storage::kStorageTypePersistent) {
247 UMA_HISTOGRAM_MEMORY_KB(
248 "Extensions.HostedAppUnlimitedStoragePersistentStorageUsage",
249 event.usage);
250 } else {
251 // We can't use the quota in the event because it assumes unlimited
252 // storage.
253 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
254 base::BindOnce(&LogTemporaryStorageUsage,
255 quota_manager_, event.usage));
182 } 256 }
183 } 257 }
184 258
185 // Stop observing all storage events. Called during shutdown. 259 if (next_threshold_ != -1 && event.usage >= next_threshold_) {
186 void StopObserving() { 260 while (event.usage >= next_threshold_)
187 DCHECK_CURRENTLY_ON(BrowserThread::IO); 261 next_threshold_ *= 2;
188 262
189 for (OriginStorageStateMap::iterator it = origin_state_map_.begin(); 263 BrowserThread::PostTask(
190 it != origin_state_map_.end(); ++it) { 264 BrowserThread::UI, FROM_HERE,
191 it->second.quota_manager->RemoveStorageObserver(this); 265 base::BindOnce(&ExtensionStorageMonitor::OnStorageThresholdExceeded,
192 } 266 io_helper_->extension_storage_monitor(), extension_id_,
193 origin_state_map_.clear(); 267 next_threshold_, event.usage));
194 } 268 }
195 269 }
196 private:
197 friend class base::DeleteHelper<StorageEventObserver>;
198 friend struct content::BrowserThread::DeleteOnThread<
199 content::BrowserThread::IO>;
200
201 struct StorageState {
202 scoped_refptr<storage::QuotaManager> quota_manager;
203
204 std::string extension_id;
205
206 // If |next_threshold| is -1, it signifies that we should not enforce (and
207 // only track) storage for this extension.
208 int64_t next_threshold;
209
210 bool should_uma;
211
212 StorageState() : next_threshold(-1), should_uma(false) {}
213 };
214 typedef std::map<GURL, StorageState> OriginStorageStateMap;
215
216 ~StorageEventObserver() override {
217 DCHECK(origin_state_map_.empty());
218 StopObserving();
219 }
220
221 // storage::StorageObserver implementation.
222 void OnStorageEvent(const Event& event) override {
223 OriginStorageStateMap::iterator iter =
224 origin_state_map_.find(event.filter.origin);
225 if (iter == origin_state_map_.end())
226 return;
227 StorageState& state = iter->second;
228
229 if (state.should_uma) {
230 if (event.filter.storage_type == storage::kStorageTypePersistent) {
231 UMA_HISTOGRAM_MEMORY_KB(
232 "Extensions.HostedAppUnlimitedStoragePersistentStorageUsage",
233 event.usage);
234 } else {
235 // We can't use the quota in the event because it assumes unlimited
236 // storage.
237 BrowserThread::PostTask(
238 BrowserThread::IO, FROM_HERE,
239 base::BindOnce(&LogTemporaryStorageUsage, state.quota_manager,
240 event.usage));
241 }
242 }
243
244 if (state.next_threshold != -1 &&
245 event.usage >= state.next_threshold) {
246 while (event.usage >= state.next_threshold)
247 state.next_threshold *= 2;
248
249 BrowserThread::PostTask(
250 BrowserThread::UI, FROM_HERE,
251 base::BindOnce(&ExtensionStorageMonitor::OnStorageThresholdExceeded,
252 storage_monitor_, state.extension_id,
253 state.next_threshold, event.usage));
254 }
255 }
256
257 OriginStorageStateMap origin_state_map_;
258 base::WeakPtr<ExtensionStorageMonitor> storage_monitor_;
259 };
260 270
261 // ExtensionStorageMonitor 271 // ExtensionStorageMonitor
262 272
263 // static 273 // static
264 ExtensionStorageMonitor* ExtensionStorageMonitor::Get( 274 ExtensionStorageMonitor* ExtensionStorageMonitor::Get(
265 content::BrowserContext* context) { 275 content::BrowserContext* context) {
266 return ExtensionStorageMonitorFactory::GetForBrowserContext(context); 276 return ExtensionStorageMonitorFactory::GetForBrowserContext(context);
267 } 277 }
268 278
269 ExtensionStorageMonitor::ExtensionStorageMonitor( 279 ExtensionStorageMonitor::ExtensionStorageMonitor(
270 content::BrowserContext* context) 280 content::BrowserContext* context)
271 : enable_for_all_extensions_(false), 281 : enable_for_all_extensions_(false),
272 initial_extension_threshold_(kExtensionInitialThreshold), 282 initial_extension_threshold_(kExtensionInitialThreshold),
273 observer_rate_(base::TimeDelta::FromSeconds(kStorageEventRateSec)), 283 observer_rate_(kStorageEventRate),
274 context_(context), 284 context_(context),
275 extension_prefs_(ExtensionPrefs::Get(context)), 285 extension_prefs_(ExtensionPrefs::Get(context)),
276 extension_registry_observer_(this), 286 extension_registry_observer_(this),
277 weak_ptr_factory_(this) { 287 weak_ptr_factory_(this) {
278 DCHECK(extension_prefs_); 288 DCHECK(extension_prefs_);
279 289
280 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, 290 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
281 content::Source<content::BrowserContext>(context_)); 291 content::Source<content::BrowserContext>(context_));
282 292
283 extension_registry_observer_.Add(ExtensionRegistry::Get(context_)); 293 extension_registry_observer_.Add(ExtensionRegistry::Get(context_));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 return; 333 return;
324 } 334 }
325 335
326 int64_t next_threshold = GetNextStorageThresholdFromPrefs(extension->id()); 336 int64_t next_threshold = GetNextStorageThresholdFromPrefs(extension->id());
327 if (next_threshold <= initial_extension_threshold_) { 337 if (next_threshold <= initial_extension_threshold_) {
328 // Clear the next threshold in the prefs. This effectively raises it to 338 // Clear the next threshold in the prefs. This effectively raises it to
329 // |initial_extension_threshold_|. If the current threshold is already 339 // |initial_extension_threshold_|. If the current threshold is already
330 // higher than this, leave it as is. 340 // higher than this, leave it as is.
331 SetNextStorageThreshold(extension->id(), 0); 341 SetNextStorageThreshold(extension->id(), 0);
332 342
333 if (storage_observer_.get()) { 343 if (io_helper_) {
334 BrowserThread::PostTask( 344 BrowserThread::PostTask(
335 BrowserThread::IO, FROM_HERE, 345 BrowserThread::IO, FROM_HERE,
336 base::BindOnce(&StorageEventObserver::UpdateThresholdForExtension, 346 base::BindOnce(
337 storage_observer_, extension->id(), 347 &ExtensionStorageMonitorIOHelper::UpdateThresholdForExtension,
338 initial_extension_threshold_)); 348 io_helper_, extension->id(), initial_extension_threshold_));
339 } 349 }
340 } 350 }
341 } 351 }
342 352
343 void ExtensionStorageMonitor::OnExtensionUninstalled( 353 void ExtensionStorageMonitor::OnExtensionUninstalled(
344 content::BrowserContext* browser_context, 354 content::BrowserContext* browser_context,
345 const Extension* extension, 355 const Extension* extension,
346 extensions::UninstallReason reason) { 356 extensions::UninstallReason reason) {
347 RemoveNotificationForExtension(extension->id()); 357 RemoveNotificationForExtension(extension->id());
348 } 358 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 488
479 bool should_enforce = (enable_for_all_extensions_) && 489 bool should_enforce = (enable_for_all_extensions_) &&
480 IsStorageNotificationEnabled(extension->id()); 490 IsStorageNotificationEnabled(extension->id());
481 491
482 bool for_metrics = ShouldGatherMetricsFor(extension); 492 bool for_metrics = ShouldGatherMetricsFor(extension);
483 493
484 if (!should_enforce && !for_metrics) 494 if (!should_enforce && !for_metrics)
485 return; // Don't track this extension. 495 return; // Don't track this extension.
486 496
487 // Lazily create the storage monitor proxy on the IO thread. 497 // Lazily create the storage monitor proxy on the IO thread.
488 if (!storage_observer_.get()) { 498 if (!io_helper_) {
489 storage_observer_ = 499 io_helper_ = base::MakeRefCounted<ExtensionStorageMonitorIOHelper>(
490 new StorageEventObserver(weak_ptr_factory_.GetWeakPtr()); 500 weak_ptr_factory_.GetWeakPtr());
491 } 501 }
492 502
493 GURL site_url = util::GetSiteForExtensionId(extension->id(), context_); 503 GURL site_url = util::GetSiteForExtensionId(extension->id(), context_);
494 content::StoragePartition* storage_partition = 504 content::StoragePartition* storage_partition =
495 content::BrowserContext::GetStoragePartitionForSite(context_, site_url); 505 content::BrowserContext::GetStoragePartitionForSite(context_, site_url);
496 DCHECK(storage_partition); 506 DCHECK(storage_partition);
497 scoped_refptr<storage::QuotaManager> quota_manager( 507 scoped_refptr<storage::QuotaManager> quota_manager(
498 storage_partition->GetQuotaManager()); 508 storage_partition->GetQuotaManager());
499 509
500 GURL storage_origin(site_url.GetOrigin()); 510 GURL storage_origin(site_url.GetOrigin());
501 if (extension->is_hosted_app()) 511 if (extension->is_hosted_app())
502 storage_origin = AppLaunchInfo::GetLaunchWebURL(extension).GetOrigin(); 512 storage_origin = AppLaunchInfo::GetLaunchWebURL(extension).GetOrigin();
503 513
504 // Don't give a threshold if we're not enforcing. 514 // Don't give a threshold if we're not enforcing.
505 int next_threshold = 515 int next_threshold =
506 should_enforce ? GetNextStorageThreshold(extension->id()) : -1; 516 should_enforce ? GetNextStorageThreshold(extension->id()) : -1;
507 517
508 BrowserThread::PostTask( 518 BrowserThread::PostTask(
509 BrowserThread::IO, FROM_HERE, 519 BrowserThread::IO, FROM_HERE,
510 base::BindOnce(&StorageEventObserver::StartObservingForExtension, 520 base::BindOnce(
511 storage_observer_, quota_manager, extension->id(), 521 &ExtensionStorageMonitorIOHelper::StartObservingForExtension,
512 storage_origin, next_threshold, observer_rate_, 522 io_helper_, quota_manager, extension->id(), storage_origin,
513 for_metrics)); 523 next_threshold, observer_rate_, for_metrics));
514 } 524 }
515 525
516 void ExtensionStorageMonitor::StopMonitoringStorage( 526 void ExtensionStorageMonitor::StopMonitoringStorage(
517 const std::string& extension_id) { 527 const std::string& extension_id) {
518 if (!storage_observer_.get()) 528 if (!io_helper_.get())
519 return; 529 return;
520 530
521 BrowserThread::PostTask( 531 BrowserThread::PostTask(
522 BrowserThread::IO, FROM_HERE, 532 BrowserThread::IO, FROM_HERE,
523 base::BindOnce(&StorageEventObserver::StopObservingForExtension, 533 base::BindOnce(
524 storage_observer_, extension_id)); 534 &ExtensionStorageMonitorIOHelper::StopObservingForExtension,
535 io_helper_, extension_id));
525 } 536 }
526 537
527 void ExtensionStorageMonitor::StopMonitoringAll() { 538 void ExtensionStorageMonitor::StopMonitoringAll() {
528 extension_registry_observer_.RemoveAll(); 539 extension_registry_observer_.RemoveAll();
529 540
530 RemoveAllNotifications(); 541 RemoveAllNotifications();
531 542
532 if (!storage_observer_.get()) 543 io_helper_ = nullptr;
533 return; 544 weak_ptr_factory_.InvalidateWeakPtrs();
534
535 BrowserThread::PostTask(
536 BrowserThread::IO, FROM_HERE,
537 base::BindOnce(&StorageEventObserver::StopObserving, storage_observer_));
538 storage_observer_ = NULL;
539 } 545 }
540 546
541 void ExtensionStorageMonitor::RemoveNotificationForExtension( 547 void ExtensionStorageMonitor::RemoveNotificationForExtension(
542 const std::string& extension_id) { 548 const std::string& extension_id) {
543 std::set<std::string>::iterator ext_id = 549 std::set<std::string>::iterator ext_id =
544 notified_extension_ids_.find(extension_id); 550 notified_extension_ids_.find(extension_id);
545 if (ext_id == notified_extension_ids_.end()) 551 if (ext_id == notified_extension_ids_.end())
546 return; 552 return;
547 553
548 notified_extension_ids_.erase(ext_id); 554 notified_extension_ids_.erase(ext_id);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 636
631 void ExtensionStorageMonitor::SetStorageNotificationEnabled( 637 void ExtensionStorageMonitor::SetStorageNotificationEnabled(
632 const std::string& extension_id, 638 const std::string& extension_id,
633 bool enable_notifications) { 639 bool enable_notifications) {
634 extension_prefs_->UpdateExtensionPref( 640 extension_prefs_->UpdateExtensionPref(
635 extension_id, kPrefDisableStorageNotifications, 641 extension_id, kPrefDisableStorageNotifications,
636 enable_notifications ? nullptr : base::MakeUnique<base::Value>(true)); 642 enable_notifications ? nullptr : base::MakeUnique<base::Value>(true));
637 } 643 }
638 644
639 } // namespace extensions 645 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698