OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/history/core/common/thumbnail_score.h" | 5 #include "components/history/core/common/thumbnail_score.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 | 9 |
10 using base::Time; | 10 using base::Time; |
11 using base::TimeDelta; | 11 using base::TimeDelta; |
12 | 12 |
13 const int64 ThumbnailScore::kUpdateThumbnailTimeDays = 1; | 13 const int64_t ThumbnailScore::kUpdateThumbnailTimeDays = 1; |
14 const double ThumbnailScore::kThumbnailMaximumBoringness = 0.94; | 14 const double ThumbnailScore::kThumbnailMaximumBoringness = 0.94; |
15 const double ThumbnailScore::kThumbnailDegradePerHour = 0.01; | 15 const double ThumbnailScore::kThumbnailDegradePerHour = 0.01; |
16 const double ThumbnailScore::kTooWideAspectRatio = 2.0; | 16 const double ThumbnailScore::kTooWideAspectRatio = 2.0; |
17 | 17 |
18 // Calculates a numeric score from traits about where a snapshot was | 18 // Calculates a numeric score from traits about where a snapshot was |
19 // taken. The lower the better. We store the raw components in the | 19 // taken. The lower the better. We store the raw components in the |
20 // database because I'm sure this will evolve and I don't want to break | 20 // database because I'm sure this will evolve and I don't want to break |
21 // databases. | 21 // databases. |
22 static int GetThumbnailType(const ThumbnailScore& score) { | 22 static int GetThumbnailType(const ThumbnailScore& score) { |
23 int type = 0; | 23 int type = 0; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 bool ThumbnailScore::ShouldConsiderUpdating() { | 131 bool ThumbnailScore::ShouldConsiderUpdating() { |
132 const TimeDelta time_elapsed = Time::Now() - time_at_snapshot; | 132 const TimeDelta time_elapsed = Time::Now() - time_at_snapshot; |
133 if (time_elapsed < TimeDelta::FromDays(kUpdateThumbnailTimeDays) && | 133 if (time_elapsed < TimeDelta::FromDays(kUpdateThumbnailTimeDays) && |
134 good_clipping && at_top && load_completed) { | 134 good_clipping && at_top && load_completed) { |
135 // The current thumbnail is new and has good properties. | 135 // The current thumbnail is new and has good properties. |
136 return false; | 136 return false; |
137 } | 137 } |
138 // The current thumbnail should be updated. | 138 // The current thumbnail should be updated. |
139 return true; | 139 return true; |
140 } | 140 } |
OLD | NEW |