OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_special_storage_policy.h" | 5 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 browser_context ? // |browser_context| can be NULL in unittests. | 63 browser_context ? // |browser_context| can be NULL in unittests. |
64 content::BrowserContext::GetStoragePartitionForSite(browser_context, | 64 content::BrowserContext::GetStoragePartitionForSite(browser_context, |
65 launch_url) : | 65 launch_url) : |
66 NULL; | 66 NULL; |
67 if (partition) { | 67 if (partition) { |
68 // We only have to query for kStorageTypePersistent data usage, because apps | 68 // We only have to query for kStorageTypePersistent data usage, because apps |
69 // cannot ask for any more temporary storage, according to | 69 // cannot ask for any more temporary storage, according to |
70 // https://developers.google.com/chrome/whitepapers/storage. | 70 // https://developers.google.com/chrome/whitepapers/storage. |
71 BrowserThread::PostAfterStartupTask( | 71 BrowserThread::PostAfterStartupTask( |
72 FROM_HERE, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), | 72 FROM_HERE, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
73 base::Bind(&storage::QuotaManager::GetUsageAndQuotaForWebApps, | 73 base::BindOnce(&storage::QuotaManager::GetUsageAndQuotaForWebApps, |
74 partition->GetQuotaManager(), launch_url, | 74 partition->GetQuotaManager(), launch_url, |
75 storage::kStorageTypePersistent, | 75 storage::kStorageTypePersistent, |
76 base::Bind(&ReportQuotaUsage))); | 76 base::Bind(&ReportQuotaUsage))); |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 } // namespace | 80 } // namespace |
81 | 81 |
82 ExtensionSpecialStoragePolicy::ExtensionSpecialStoragePolicy( | 82 ExtensionSpecialStoragePolicy::ExtensionSpecialStoragePolicy( |
83 content_settings::CookieSettings* cookie_settings) | 83 content_settings::CookieSettings* cookie_settings) |
84 : cookie_settings_(cookie_settings) { | 84 : cookie_settings_(cookie_settings) { |
85 } | 85 } |
86 | 86 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 248 |
249 NotifyCleared(); | 249 NotifyCleared(); |
250 } | 250 } |
251 | 251 |
252 void ExtensionSpecialStoragePolicy::NotifyGranted( | 252 void ExtensionSpecialStoragePolicy::NotifyGranted( |
253 const GURL& origin, | 253 const GURL& origin, |
254 int change_flags) { | 254 int change_flags) { |
255 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 255 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
256 BrowserThread::PostTask( | 256 BrowserThread::PostTask( |
257 BrowserThread::IO, FROM_HERE, | 257 BrowserThread::IO, FROM_HERE, |
258 base::Bind(&ExtensionSpecialStoragePolicy::NotifyGranted, this, | 258 base::BindOnce(&ExtensionSpecialStoragePolicy::NotifyGranted, this, |
259 origin, change_flags)); | 259 origin, change_flags)); |
260 return; | 260 return; |
261 } | 261 } |
262 SpecialStoragePolicy::NotifyGranted(origin, change_flags); | 262 SpecialStoragePolicy::NotifyGranted(origin, change_flags); |
263 } | 263 } |
264 | 264 |
265 void ExtensionSpecialStoragePolicy::NotifyRevoked( | 265 void ExtensionSpecialStoragePolicy::NotifyRevoked( |
266 const GURL& origin, | 266 const GURL& origin, |
267 int change_flags) { | 267 int change_flags) { |
268 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 268 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
269 BrowserThread::PostTask( | 269 BrowserThread::PostTask( |
270 BrowserThread::IO, FROM_HERE, | 270 BrowserThread::IO, FROM_HERE, |
271 base::Bind(&ExtensionSpecialStoragePolicy::NotifyRevoked, this, | 271 base::BindOnce(&ExtensionSpecialStoragePolicy::NotifyRevoked, this, |
272 origin, change_flags)); | 272 origin, change_flags)); |
273 return; | 273 return; |
274 } | 274 } |
275 SpecialStoragePolicy::NotifyRevoked(origin, change_flags); | 275 SpecialStoragePolicy::NotifyRevoked(origin, change_flags); |
276 } | 276 } |
277 | 277 |
278 void ExtensionSpecialStoragePolicy::NotifyCleared() { | 278 void ExtensionSpecialStoragePolicy::NotifyCleared() { |
279 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 279 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
280 BrowserThread::PostTask( | 280 BrowserThread::PostTask( |
281 BrowserThread::IO, FROM_HERE, | 281 BrowserThread::IO, FROM_HERE, |
282 base::Bind(&ExtensionSpecialStoragePolicy::NotifyCleared, this)); | 282 base::BindOnce(&ExtensionSpecialStoragePolicy::NotifyCleared, this)); |
283 return; | 283 return; |
284 } | 284 } |
285 SpecialStoragePolicy::NotifyCleared(); | 285 SpecialStoragePolicy::NotifyCleared(); |
286 } | 286 } |
287 | 287 |
288 //----------------------------------------------------------------------------- | 288 //----------------------------------------------------------------------------- |
289 // SpecialCollection helper class | 289 // SpecialCollection helper class |
290 //----------------------------------------------------------------------------- | 290 //----------------------------------------------------------------------------- |
291 | 291 |
292 ExtensionSpecialStoragePolicy::SpecialCollection::SpecialCollection() {} | 292 ExtensionSpecialStoragePolicy::SpecialCollection::SpecialCollection() {} |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 343 } |
344 | 344 |
345 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() { | 345 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() { |
346 ClearCache(); | 346 ClearCache(); |
347 extensions_.Clear(); | 347 extensions_.Clear(); |
348 } | 348 } |
349 | 349 |
350 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() { | 350 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() { |
351 cached_results_.clear(); | 351 cached_results_.clear(); |
352 } | 352 } |
OLD | NEW |