| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_BROWSER_COMMON_THUMBNAIL_SCORE_H__ | 5 #ifndef CHROME_BROWSER_COMMON_THUMBNAIL_SCORE_H__ |
| 6 #define CHROME_BROWSER_COMMON_THUMBNAIL_SCORE_H__ | 6 #define CHROME_BROWSER_COMMON_THUMBNAIL_SCORE_H__ |
| 7 | 7 |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 | 9 |
| 10 // A set of metadata about a Thumbnail. | 10 // A set of metadata about a Thumbnail. |
| 11 struct ThumbnailScore { | 11 struct ThumbnailScore { |
| 12 // Initializes the ThumbnailScore to the absolute worst possible | 12 // Initializes the ThumbnailScore to the absolute worst possible |
| 13 // values except for time, which is set to Now(). | 13 // values except for time, which is set to Now(). |
| 14 ThumbnailScore(); | 14 ThumbnailScore(); |
| 15 | 15 |
| 16 // Builds a ThumbnailScore with the passed in values, and sets the | 16 // Builds a ThumbnailScore with the passed in values, and sets the |
| 17 // thumbnail generation time to Now(). | 17 // thumbnail generation time to Now(). |
| 18 ThumbnailScore(double score, bool clipping, bool top); | 18 ThumbnailScore(double score, bool clipping, bool top); |
| 19 | 19 |
| 20 // Builds a ThumbnailScore with the passed in values. | 20 // Builds a ThumbnailScore with the passed in values. |
| 21 ThumbnailScore(double score, bool clipping, bool top, | 21 ThumbnailScore(double score, bool clipping, bool top, |
| 22 const Time& time); | 22 const base::Time& time); |
| 23 ~ThumbnailScore(); | 23 ~ThumbnailScore(); |
| 24 | 24 |
| 25 // Tests for equivalence between two ThumbnailScore objects. | 25 // Tests for equivalence between two ThumbnailScore objects. |
| 26 bool Equals(const ThumbnailScore& rhs) const; | 26 bool Equals(const ThumbnailScore& rhs) const; |
| 27 | 27 |
| 28 // How "boring" a thumbnail is. The boring score is the 0,1 ranged | 28 // How "boring" a thumbnail is. The boring score is the 0,1 ranged |
| 29 // percentage of pixels that are the most common luma. Higher boring | 29 // percentage of pixels that are the most common luma. Higher boring |
| 30 // scores indicate that a higher percentage of a bitmap are all the | 30 // scores indicate that a higher percentage of a bitmap are all the |
| 31 // same brightness (most likely the same color). | 31 // same brightness (most likely the same color). |
| 32 double boring_score; | 32 double boring_score; |
| 33 | 33 |
| 34 // Whether the thumbnail was taken with height greater then | 34 // Whether the thumbnail was taken with height greater then |
| 35 // width. In cases where we don't have |good_clipping|, the | 35 // width. In cases where we don't have |good_clipping|, the |
| 36 // thumbnails are either clipped from the horizontal center of the | 36 // thumbnails are either clipped from the horizontal center of the |
| 37 // window, or are otherwise weirdly stretched. | 37 // window, or are otherwise weirdly stretched. |
| 38 bool good_clipping; | 38 bool good_clipping; |
| 39 | 39 |
| 40 // Whether this thumbnail was taken while the renderer was | 40 // Whether this thumbnail was taken while the renderer was |
| 41 // displaying the top of the page. Most pages are more recognizable | 41 // displaying the top of the page. Most pages are more recognizable |
| 42 // by their headers then by a set of random text half way down the | 42 // by their headers then by a set of random text half way down the |
| 43 // page; i.e. most MediaWiki sites would be indistinguishable by | 43 // page; i.e. most MediaWiki sites would be indistinguishable by |
| 44 // thumbnails with |at_top| set to false. | 44 // thumbnails with |at_top| set to false. |
| 45 bool at_top; | 45 bool at_top; |
| 46 | 46 |
| 47 // Record the time when a thumbnail was taken. This is used to make | 47 // Record the time when a thumbnail was taken. This is used to make |
| 48 // sure thumbnails are kept fresh. | 48 // sure thumbnails are kept fresh. |
| 49 Time time_at_snapshot; | 49 base::Time time_at_snapshot; |
| 50 | 50 |
| 51 // How bad a thumbnail needs to be before we completely ignore it. | 51 // How bad a thumbnail needs to be before we completely ignore it. |
| 52 static const double kThumbnailMaximumBoringness; | 52 static const double kThumbnailMaximumBoringness; |
| 53 | 53 |
| 54 // Time before we take a worse thumbnail (subject to | 54 // Time before we take a worse thumbnail (subject to |
| 55 // kThumbnailMaximumBoringness) over what's currently in the database | 55 // kThumbnailMaximumBoringness) over what's currently in the database |
| 56 // for freshness. | 56 // for freshness. |
| 57 static const TimeDelta kUpdateThumbnailTime; | 57 static const base::TimeDelta kUpdateThumbnailTime; |
| 58 | 58 |
| 59 // Penalty of how much more boring a thumbnail should be per hour. | 59 // Penalty of how much more boring a thumbnail should be per hour. |
| 60 static const double kThumbnailDegradePerHour; | 60 static const double kThumbnailDegradePerHour; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 // Checks whether we should replace one thumbnail with another. | 63 // Checks whether we should replace one thumbnail with another. |
| 64 bool ShouldReplaceThumbnailWith(const ThumbnailScore& current, | 64 bool ShouldReplaceThumbnailWith(const ThumbnailScore& current, |
| 65 const ThumbnailScore& replacement); | 65 const ThumbnailScore& replacement); |
| 66 | 66 |
| 67 #endif // CHROME_BROWSER_COMMON_THUMBNAIL_SCORE_H__ | 67 #endif // CHROME_BROWSER_COMMON_THUMBNAIL_SCORE_H__ |
| 68 | 68 |
| OLD | NEW |