| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/thumbnail_score.h" | 5 #include "chrome/common/thumbnail_score.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 | 9 |
| 10 using base::Time; | 10 using base::Time; |
| 11 using base::TimeDelta; | 11 using base::TimeDelta; |
| 12 | 12 |
| 13 const TimeDelta ThumbnailScore::kUpdateThumbnailTime = TimeDelta::FromDays(1); | 13 const int64 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 | 16 |
| 17 // Calculates a numeric score from traits about where a snapshot was | 17 // Calculates a numeric score from traits about where a snapshot was |
| 18 // taken. The lower the better. We store the raw components in the | 18 // taken. The lower the better. We store the raw components in the |
| 19 // database because I'm sure this will evolve and I don't want to break | 19 // database because I'm sure this will evolve and I don't want to break |
| 20 // databases. | 20 // databases. |
| 21 static int GetThumbnailType(const ThumbnailScore& score) { | 21 static int GetThumbnailType(const ThumbnailScore& score) { |
| 22 int type = 0; | 22 int type = 0; |
| 23 if (!score.at_top) | 23 if (!score.at_top) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 // If the current thumbnail doesn't meet basic boringness | 125 // If the current thumbnail doesn't meet basic boringness |
| 126 // requirements, but the replacement does, always replace the | 126 // requirements, but the replacement does, always replace the |
| 127 // current one even if we're using a worse thumbnail type. | 127 // current one even if we're using a worse thumbnail type. |
| 128 return current.boring_score >= ThumbnailScore::kThumbnailMaximumBoringness && | 128 return current.boring_score >= ThumbnailScore::kThumbnailMaximumBoringness && |
| 129 replacement.boring_score < ThumbnailScore::kThumbnailMaximumBoringness; | 129 replacement.boring_score < ThumbnailScore::kThumbnailMaximumBoringness; |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool ThumbnailScore::ShouldConsiderUpdating() { | 132 bool ThumbnailScore::ShouldConsiderUpdating() { |
| 133 const TimeDelta time_elapsed = Time::Now() - time_at_snapshot; | 133 const TimeDelta time_elapsed = Time::Now() - time_at_snapshot; |
| 134 if (time_elapsed < kUpdateThumbnailTime && | 134 if (time_elapsed < TimeDelta::FromDays(kUpdateThumbnailTimeDays) && |
| 135 good_clipping && at_top && load_completed) { | 135 good_clipping && at_top && load_completed) { |
| 136 // The current thumbnail is new and has good properties. | 136 // The current thumbnail is new and has good properties. |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 // The current thumbnail should be updated. | 139 // The current thumbnail should be updated. |
| 140 return true; | 140 return true; |
| 141 } | 141 } |
| OLD | NEW |