Commit 19649690 authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[Thumbnails DB] Remove uses of deprecated Time::From/ToInternalValue()

The CL replaces the calls to Time::From/ToInternalValue() by the more
explicit Time::From/ToDeltaSinceWindowsEpoch(). This change is backwards
compatible.

Bug: 634507
Change-Id: Ic5f22baf4c2216eec8080386eefa2e75a8ca5378
Reviewed-on: https://chromium-review.googlesource.com/913609
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539162}
parent bb92f502
...@@ -427,7 +427,7 @@ ThumbnailDatabase::GetOldOnDemandFavicons(base::Time threshold) { ...@@ -427,7 +427,7 @@ ThumbnailDatabase::GetOldOnDemandFavicons(base::Time threshold) {
"JOIN icon_mapping ON (icon_mapping.icon_id = favicon_bitmaps.icon_id) " "JOIN icon_mapping ON (icon_mapping.icon_id = favicon_bitmaps.icon_id) "
"WHERE (favicon_bitmaps.last_requested > 0 AND " "WHERE (favicon_bitmaps.last_requested > 0 AND "
" favicon_bitmaps.last_requested < ?)")); " favicon_bitmaps.last_requested < ?)"));
old_icons.BindInt64(0, threshold.ToInternalValue()); old_icons.BindInt64(0, threshold.ToDeltaSinceWindowsEpoch().InMicroseconds());
std::map<favicon_base::FaviconID, IconMappingsForExpiry> icon_mappings; std::map<favicon_base::FaviconID, IconMappingsForExpiry> icon_mappings;
...@@ -482,8 +482,8 @@ bool ThumbnailDatabase::GetFaviconBitmaps( ...@@ -482,8 +482,8 @@ bool ThumbnailDatabase::GetFaviconBitmaps(
FaviconBitmap favicon_bitmap; FaviconBitmap favicon_bitmap;
favicon_bitmap.bitmap_id = statement.ColumnInt64(0); favicon_bitmap.bitmap_id = statement.ColumnInt64(0);
favicon_bitmap.icon_id = icon_id; favicon_bitmap.icon_id = icon_id;
favicon_bitmap.last_updated = favicon_bitmap.last_updated = base::Time::FromDeltaSinceWindowsEpoch(
base::Time::FromInternalValue(statement.ColumnInt64(1)); base::TimeDelta::FromMicroseconds(statement.ColumnInt64(1)));
if (statement.ColumnByteLength(2) > 0) { if (statement.ColumnByteLength(2) > 0) {
scoped_refptr<base::RefCountedBytes> data(new base::RefCountedBytes()); scoped_refptr<base::RefCountedBytes> data(new base::RefCountedBytes());
statement.ColumnBlobAsVector(2, &data->data()); statement.ColumnBlobAsVector(2, &data->data());
...@@ -491,8 +491,8 @@ bool ThumbnailDatabase::GetFaviconBitmaps( ...@@ -491,8 +491,8 @@ bool ThumbnailDatabase::GetFaviconBitmaps(
} }
favicon_bitmap.pixel_size = gfx::Size(statement.ColumnInt(3), favicon_bitmap.pixel_size = gfx::Size(statement.ColumnInt(3),
statement.ColumnInt(4)); statement.ColumnInt(4));
favicon_bitmap.last_requested = favicon_bitmap.last_requested = base::Time::FromDeltaSinceWindowsEpoch(
base::Time::FromInternalValue(statement.ColumnInt64(5)); base::TimeDelta::FromMicroseconds(statement.ColumnInt64(5)));
favicon_bitmaps->push_back(favicon_bitmap); favicon_bitmaps->push_back(favicon_bitmap);
} }
return result; return result;
...@@ -513,8 +513,10 @@ bool ThumbnailDatabase::GetFaviconBitmap( ...@@ -513,8 +513,10 @@ bool ThumbnailDatabase::GetFaviconBitmap(
if (!statement.Step()) if (!statement.Step())
return false; return false;
if (last_updated) if (last_updated) {
*last_updated = base::Time::FromInternalValue(statement.ColumnInt64(0)); *last_updated = base::Time::FromDeltaSinceWindowsEpoch(
base::TimeDelta::FromMicroseconds(statement.ColumnInt64(0)));
}
if (png_icon_data && statement.ColumnByteLength(1) > 0) { if (png_icon_data && statement.ColumnByteLength(1) > 0) {
scoped_refptr<base::RefCountedBytes> data(new base::RefCountedBytes()); scoped_refptr<base::RefCountedBytes> data(new base::RefCountedBytes());
...@@ -527,8 +529,10 @@ bool ThumbnailDatabase::GetFaviconBitmap( ...@@ -527,8 +529,10 @@ bool ThumbnailDatabase::GetFaviconBitmap(
statement.ColumnInt(3)); statement.ColumnInt(3));
} }
if (last_requested) if (last_requested) {
*last_requested = base::Time::FromInternalValue(statement.ColumnInt64(4)); *last_requested = base::Time::FromDeltaSinceWindowsEpoch(
base::TimeDelta::FromMicroseconds(statement.ColumnInt64(4)));
}
return true; return true;
} }
...@@ -557,12 +561,16 @@ FaviconBitmapID ThumbnailDatabase::AddFaviconBitmap( ...@@ -557,12 +561,16 @@ FaviconBitmapID ThumbnailDatabase::AddFaviconBitmap(
// On-visit bitmaps: // On-visit bitmaps:
// - keep track of last_updated: last write time is used for expiration; // - keep track of last_updated: last write time is used for expiration;
// - always have last_requested==0: no need to keep track of last read time. // - always have last_requested==0: no need to keep track of last read time.
statement.BindInt64(2, type == ON_VISIT ? time.ToInternalValue() : 0); statement.BindInt64(2, type == ON_VISIT
? time.ToDeltaSinceWindowsEpoch().InMicroseconds()
: 0);
// On-demand bitmaps: // On-demand bitmaps:
// - always have last_updated==0: last write time is not stored as they are // - always have last_updated==0: last write time is not stored as they are
// always expired and thus ready to be replaced by ON_VISIT icons; // always expired and thus ready to be replaced by ON_VISIT icons;
// - keep track of last_requested: last read time is used for cache eviction. // - keep track of last_requested: last read time is used for cache eviction.
statement.BindInt64(3, type == ON_DEMAND ? time.ToInternalValue() : 0); statement.BindInt64(3, type == ON_DEMAND
? time.ToDeltaSinceWindowsEpoch().InMicroseconds()
: 0);
statement.BindInt(4, pixel_size.width()); statement.BindInt(4, pixel_size.width());
statement.BindInt(5, pixel_size.height()); statement.BindInt(5, pixel_size.height());
...@@ -590,7 +598,7 @@ bool ThumbnailDatabase::SetFaviconBitmap( ...@@ -590,7 +598,7 @@ bool ThumbnailDatabase::SetFaviconBitmap(
} else { } else {
statement.BindNull(0); statement.BindNull(0);
} }
statement.BindInt64(1, time.ToInternalValue()); statement.BindInt64(1, time.ToDeltaSinceWindowsEpoch().InMicroseconds());
statement.BindInt64(2, 0); statement.BindInt64(2, 0);
statement.BindInt64(3, bitmap_id); statement.BindInt64(3, bitmap_id);
...@@ -608,7 +616,7 @@ bool ThumbnailDatabase::SetFaviconBitmapLastUpdateTime( ...@@ -608,7 +616,7 @@ bool ThumbnailDatabase::SetFaviconBitmapLastUpdateTime(
db_.GetCachedStatement(SQL_FROM_HERE, db_.GetCachedStatement(SQL_FROM_HERE,
"UPDATE favicon_bitmaps SET last_updated=?, " "UPDATE favicon_bitmaps SET last_updated=?, "
"last_requested=? WHERE id=?")); "last_requested=? WHERE id=?"));
statement.BindInt64(0, time.ToInternalValue()); statement.BindInt64(0, time.ToDeltaSinceWindowsEpoch().InMicroseconds());
statement.BindInt64(1, 0); statement.BindInt64(1, 0);
statement.BindInt64(2, bitmap_id); statement.BindInt64(2, bitmap_id);
return statement.Run(); return statement.Run();
...@@ -635,9 +643,10 @@ bool ThumbnailDatabase::TouchOnDemandFavicon(const GURL& icon_url, ...@@ -635,9 +643,10 @@ bool ThumbnailDatabase::TouchOnDemandFavicon(const GURL& icon_url,
SQL_FROM_HERE, SQL_FROM_HERE,
"UPDATE favicon_bitmaps SET last_requested=? WHERE icon_id=? AND " "UPDATE favicon_bitmaps SET last_requested=? WHERE icon_id=? AND "
"last_requested>0 AND last_requested<=?")); "last_requested>0 AND last_requested<=?"));
statement.BindInt64(0, time.ToInternalValue()); statement.BindInt64(0, time.ToDeltaSinceWindowsEpoch().InMicroseconds());
statement.BindInt64(1, icon_id); statement.BindInt64(1, icon_id);
statement.BindInt64(2, max_time.ToInternalValue()); statement.BindInt64(2,
max_time.ToDeltaSinceWindowsEpoch().InMicroseconds());
if (!statement.Run()) if (!statement.Run())
return false; return false;
} }
...@@ -675,8 +684,6 @@ bool ThumbnailDatabase::GetFaviconLastUpdatedTime( ...@@ -675,8 +684,6 @@ bool ThumbnailDatabase::GetFaviconLastUpdatedTime(
if (statement.ColumnType(0) == sql::COLUMN_TYPE_NULL) if (statement.ColumnType(0) == sql::COLUMN_TYPE_NULL)
return false; return false;
// TODO(jkrcal): Convert other uses of the now deprecated
// base::Time::FromInternalValue to make this file consistent again.
if (last_updated) { if (last_updated) {
*last_updated = base::Time::FromDeltaSinceWindowsEpoch( *last_updated = base::Time::FromDeltaSinceWindowsEpoch(
base::TimeDelta::FromMicroseconds(statement.ColumnInt64(0))); base::TimeDelta::FromMicroseconds(statement.ColumnInt64(0)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment