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

Side by Side Diff: storage/browser/quota/quota_manager.h

Issue 1221523003: Add a SiteEngagementEvictionPolicy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@get_total_engagement_points
Patch Set: Extract SiteEngagementScoreProvider interface Created 5 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ 5 #ifndef STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_
6 #define STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ 6 #define STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 int64 quota; 62 int64 quota;
63 int64 available_disk_space; 63 int64 available_disk_space;
64 64
65 UsageAndQuota(); 65 UsageAndQuota();
66 UsageAndQuota(int64 usage, 66 UsageAndQuota(int64 usage,
67 int64 global_limited_usage, 67 int64 global_limited_usage,
68 int64 quota, 68 int64 quota,
69 int64 available_disk_space); 69 int64 available_disk_space);
70 }; 70 };
71 71
72 // TODO(calamity): Use this in the temporary storage eviction path.
73 // An interface for deciding which origin's temporary storage should be evicted
74 // when the quota is exceeded.
75 class STORAGE_EXPORT TemporaryStorageEvictionPolicy {
michaeln 2015/07/23 02:26:18 I'd vote for a simpler name, QuotaEvictionPolicy.
calamity 2015/07/28 01:07:59 Done.
76 public:
77 // Returns the next origin to evict. It might return an empty GURL when there
78 // are no evictable origins.
79 virtual void GetEvictionOrigin(const std::map<GURL, int64>& usage_map,
michaeln 2015/07/23 02:22:32 I think we need to add SpecialStoragePolicy* to th
calamity 2015/07/28 01:07:59 I think the last access time is an improvement to
80 int64 global_quota,
81 const GetEvictionOriginCallback& callback) = 0;
82
83 protected:
84 ~TemporaryStorageEvictionPolicy() {}
85 };
86
72 // An interface called by QuotaTemporaryStorageEvictor. 87 // An interface called by QuotaTemporaryStorageEvictor.
73 class STORAGE_EXPORT QuotaEvictionHandler { 88 class STORAGE_EXPORT QuotaEvictionHandler {
74 public: 89 public:
75 typedef base::Callback<void(const GURL&)> GetLRUOriginCallback;
76 typedef StatusCallback EvictOriginDataCallback; 90 typedef StatusCallback EvictOriginDataCallback;
77 typedef base::Callback<void(QuotaStatusCode status, 91 typedef base::Callback<void(QuotaStatusCode status,
78 const UsageAndQuota& usage_and_quota)> 92 const UsageAndQuota& usage_and_quota)>
79 UsageAndQuotaCallback; 93 UsageAndQuotaCallback;
80 94
81 // Returns the least recently used origin. It might return empty 95 // Returns next origin to evict. It might return an empty GURL when there are
82 // GURL when there are no evictable origins. 96 // no evictable origins.
83 virtual void GetLRUOrigin( 97 virtual void GetEvictionOrigin(StorageType type,
84 StorageType type, 98 const GetEvictionOriginCallback& callback) = 0;
85 const GetLRUOriginCallback& callback) = 0;
86 99
87 virtual void EvictOriginData( 100 virtual void EvictOriginData(
88 const GURL& origin, 101 const GURL& origin,
89 StorageType type, 102 StorageType type,
90 const EvictOriginDataCallback& callback) = 0; 103 const EvictOriginDataCallback& callback) = 0;
91 104
92 virtual void GetUsageAndQuotaForEviction( 105 virtual void GetUsageAndQuotaForEviction(
93 const UsageAndQuotaCallback& callback) = 0; 106 const UsageAndQuotaCallback& callback) = 0;
94 107
95 protected: 108 protected:
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 368
356 void DidOriginDataEvicted(QuotaStatusCode status); 369 void DidOriginDataEvicted(QuotaStatusCode status);
357 370
358 void ReportHistogram(); 371 void ReportHistogram();
359 void DidGetTemporaryGlobalUsageForHistogram(int64 usage, 372 void DidGetTemporaryGlobalUsageForHistogram(int64 usage,
360 int64 unlimited_usage); 373 int64 unlimited_usage);
361 void DidGetPersistentGlobalUsageForHistogram(int64 usage, 374 void DidGetPersistentGlobalUsageForHistogram(int64 usage,
362 int64 unlimited_usage); 375 int64 unlimited_usage);
363 376
364 // QuotaEvictionHandler. 377 // QuotaEvictionHandler.
365 void GetLRUOrigin(StorageType type, 378 void GetEvictionOrigin(StorageType type,
366 const GetLRUOriginCallback& callback) override; 379 const GetEvictionOriginCallback& callback) override;
367 void EvictOriginData(const GURL& origin, 380 void EvictOriginData(const GURL& origin,
368 StorageType type, 381 StorageType type,
369 const EvictOriginDataCallback& callback) override; 382 const EvictOriginDataCallback& callback) override;
370 void GetUsageAndQuotaForEviction( 383 void GetUsageAndQuotaForEviction(
371 const UsageAndQuotaCallback& callback) override; 384 const UsageAndQuotaCallback& callback) override;
372 385
386 void GetLRUOrigin(StorageType type,
387 const GetEvictionOriginCallback& callback);
388
373 void DidSetTemporaryGlobalOverrideQuota(const QuotaCallback& callback, 389 void DidSetTemporaryGlobalOverrideQuota(const QuotaCallback& callback,
374 const int64* new_quota, 390 const int64* new_quota,
375 bool success); 391 bool success);
376 void DidGetPersistentHostQuota(const std::string& host, 392 void DidGetPersistentHostQuota(const std::string& host,
377 const int64* quota, 393 const int64* quota,
378 bool success); 394 bool success);
379 void DidSetPersistentHostQuota(const std::string& host, 395 void DidSetPersistentHostQuota(const std::string& host,
380 const QuotaCallback& callback, 396 const QuotaCallback& callback,
381 const int64* new_quota, 397 const int64* new_quota,
382 bool success); 398 bool success);
(...skipping 18 matching lines...) Expand all
401 const bool is_incognito_; 417 const bool is_incognito_;
402 const base::FilePath profile_path_; 418 const base::FilePath profile_path_;
403 419
404 scoped_refptr<QuotaManagerProxy> proxy_; 420 scoped_refptr<QuotaManagerProxy> proxy_;
405 bool db_disabled_; 421 bool db_disabled_;
406 bool eviction_disabled_; 422 bool eviction_disabled_;
407 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; 423 scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
408 scoped_refptr<base::SequencedTaskRunner> db_thread_; 424 scoped_refptr<base::SequencedTaskRunner> db_thread_;
409 mutable scoped_ptr<QuotaDatabase> database_; 425 mutable scoped_ptr<QuotaDatabase> database_;
410 426
411 GetLRUOriginCallback lru_origin_callback_; 427 GetEvictionOriginCallback lru_origin_callback_;
412 std::set<GURL> access_notified_origins_; 428 std::set<GURL> access_notified_origins_;
413 429
414 QuotaClientList clients_; 430 QuotaClientList clients_;
415 431
416 scoped_ptr<UsageTracker> temporary_usage_tracker_; 432 scoped_ptr<UsageTracker> temporary_usage_tracker_;
417 scoped_ptr<UsageTracker> persistent_usage_tracker_; 433 scoped_ptr<UsageTracker> persistent_usage_tracker_;
418 scoped_ptr<UsageTracker> syncable_usage_tracker_; 434 scoped_ptr<UsageTracker> syncable_usage_tracker_;
419 // TODO(michaeln): Need a way to clear the cache, drop and 435 // TODO(michaeln): Need a way to clear the cache, drop and
420 // reinstantiate the trackers when they're not handling requests. 436 // reinstantiate the trackers when they're not handling requests.
421 437
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 470
455 struct QuotaManagerDeleter { 471 struct QuotaManagerDeleter {
456 static void Destruct(const QuotaManager* manager) { 472 static void Destruct(const QuotaManager* manager) {
457 manager->DeleteOnCorrectThread(); 473 manager->DeleteOnCorrectThread();
458 } 474 }
459 }; 475 };
460 476
461 } // namespace storage 477 } // namespace storage
462 478
463 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ 479 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698