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

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: add quota database 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
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 339 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 *entry = OriginInfoTableEntry(
375 GURL(statement.ColumnString(0)),
376 static_cast<StorageType>(statement.ColumnInt(1)),
377 statement.ColumnInt(2),
378 base::Time::FromInternalValue(statement.ColumnInt64(3)),
379 base::Time::FromInternalValue(statement.ColumnInt64(4)));
380 }
381
382 return statement.Succeeded();
michaeln 2015/10/30 00:49:02 Hmmm... this will return true when nothing was fou
calamity 2015/11/02 06:27:44 The return value indicating success/error is actua
michaeln 2015/11/03 02:42:04 The return value of the new GetOriginInfo method i
calamity 2015/11/04 00:42:43 Done. Added some comments about return values.
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

Powered by Google App Engine
This is Rietveld 408576698