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

Side by Side Diff: storage/browser/quota/quota_database.cc

Issue 1424653002: Add access count and time-since-accessed histograms to temp storage eviction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@quota_uma
Patch Set: fix test Created 5 years, 1 month 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
« no previous file with comments | « storage/browser/quota/quota_database.h ('k') | storage/browser/quota/quota_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "storage/browser/quota/quota_database.h" 5 #include "storage/browser/quota/quota_database.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 const char kSql[] = 279 const char kSql[] =
280 "SELECT last_eviction_time" 280 "SELECT last_eviction_time"
281 " FROM EvictionInfoTable" 281 " FROM EvictionInfoTable"
282 " WHERE origin = ? AND type = ?"; 282 " WHERE origin = ? AND type = ?";
283 283
284 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); 284 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql));
285 statement.BindString(0, origin.spec()); 285 statement.BindString(0, origin.spec());
286 statement.BindInt(1, static_cast<int>(type)); 286 statement.BindInt(1, static_cast<int>(type));
287 287
288 if (!statement.Step()) 288 if (!statement.Step())
289 return statement.Succeeded(); 289 return false;
290 290
291 *last_modified_time = base::Time::FromInternalValue(statement.ColumnInt64(0)); 291 *last_modified_time = base::Time::FromInternalValue(statement.ColumnInt64(0));
292 return true; 292 return true;
293 } 293 }
294 294
295 bool QuotaDatabase::SetOriginLastEvictionTime(const GURL& origin, 295 bool QuotaDatabase::SetOriginLastEvictionTime(const GURL& origin,
296 StorageType type, 296 StorageType type,
297 base::Time last_modified_time) { 297 base::Time last_modified_time) {
298 if (!LazyOpen(true)) 298 if (!LazyOpen(true))
299 return false; 299 return false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 statement.BindInt(1, static_cast<int>(type)); 350 statement.BindInt(1, static_cast<int>(type));
351 351
352 if (!statement.Run()) 352 if (!statement.Run())
353 return false; 353 return false;
354 } 354 }
355 355
356 ScheduleCommit(); 356 ScheduleCommit();
357 return true; 357 return true;
358 } 358 }
359 359
360 bool QuotaDatabase::GetOriginInfo(const GURL& origin,
361 StorageType type,
362 QuotaDatabase::OriginInfoTableEntry* entry) {
363 if (!LazyOpen(false))
364 return false;
365
366 const char* kSql =
367 "SELECT * FROM OriginInfoTable"
368 " WHERE origin = ? AND type = ?";
369 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql));
370 statement.BindString(0, origin.spec());
371 statement.BindInt(1, static_cast<int>(type));
372
373 if (!statement.Step())
374 return false;
375
376 *entry = OriginInfoTableEntry(
377 GURL(statement.ColumnString(0)),
378 static_cast<StorageType>(statement.ColumnInt(1)), statement.ColumnInt(2),
379 base::Time::FromInternalValue(statement.ColumnInt64(3)),
380 base::Time::FromInternalValue(statement.ColumnInt64(4)));
381
382 return true;
383 }
384
360 bool QuotaDatabase::DeleteHostQuota( 385 bool QuotaDatabase::DeleteHostQuota(
361 const std::string& host, StorageType type) { 386 const std::string& host, StorageType type) {
362 if (!LazyOpen(false)) 387 if (!LazyOpen(false))
363 return false; 388 return false;
364 389
365 const char* kSql = 390 const char* kSql =
366 "DELETE FROM HostQuotaTable" 391 "DELETE FROM HostQuotaTable"
367 " WHERE host = ? AND type = ?"; 392 " WHERE host = ? AND type = ?";
368 393
369 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); 394 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql));
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 if (lhs.origin < rhs.origin) return true; 792 if (lhs.origin < rhs.origin) return true;
768 if (rhs.origin < lhs.origin) return false; 793 if (rhs.origin < lhs.origin) return false;
769 if (lhs.type < rhs.type) return true; 794 if (lhs.type < rhs.type) return true;
770 if (rhs.type < lhs.type) return false; 795 if (rhs.type < lhs.type) return false;
771 if (lhs.used_count < rhs.used_count) return true; 796 if (lhs.used_count < rhs.used_count) return true;
772 if (rhs.used_count < lhs.used_count) return false; 797 if (rhs.used_count < lhs.used_count) return false;
773 return lhs.last_access_time < rhs.last_access_time; 798 return lhs.last_access_time < rhs.last_access_time;
774 } 799 }
775 800
776 } // namespace storage 801 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/quota/quota_database.h ('k') | storage/browser/quota/quota_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698