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

Side by Side Diff: chrome/common/thumbnail_score.h

Issue 6389001: Add heuristics to skip thumbnail generation when it's unnecessary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix debug unit tests Created 9 years, 10 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_COMMON_THUMBNAIL_SCORE_H_ 5 #ifndef CHROME_COMMON_THUMBNAIL_SCORE_H_
6 #define CHROME_COMMON_THUMBNAIL_SCORE_H_ 6 #define CHROME_COMMON_THUMBNAIL_SCORE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string>
9 #include "base/time.h" 10 #include "base/time.h"
10 11
11 // A set of metadata about a Thumbnail. 12 // A set of metadata about a Thumbnail.
12 struct ThumbnailScore { 13 struct ThumbnailScore {
13 // Initializes the ThumbnailScore to the absolute worst possible values 14 // Initializes the ThumbnailScore to the absolute worst possible values
14 // except for time, which is set to Now(), and redirect_hops_from_dest which 15 // except for time, which is set to Now(), and redirect_hops_from_dest which
15 // is set to 0. 16 // is set to 0.
16 ThumbnailScore(); 17 ThumbnailScore();
17 18
18 // Builds a ThumbnailScore with the passed in values, and sets the 19 // Builds a ThumbnailScore with the passed in values, and sets the
19 // thumbnail generation time to Now(). 20 // thumbnail generation time to Now().
20 ThumbnailScore(double score, bool clipping, bool top); 21 ThumbnailScore(double score, bool clipping, bool top);
21 22
22 // Builds a ThumbnailScore with the passed in values. 23 // Builds a ThumbnailScore with the passed in values.
23 ThumbnailScore(double score, bool clipping, bool top, 24 ThumbnailScore(double score, bool clipping, bool top,
24 const base::Time& time); 25 const base::Time& time);
25 ~ThumbnailScore(); 26 ~ThumbnailScore();
26 27
27 // Tests for equivalence between two ThumbnailScore objects. 28 // Tests for equivalence between two ThumbnailScore objects.
28 bool Equals(const ThumbnailScore& rhs) const; 29 bool Equals(const ThumbnailScore& rhs) const;
29 30
31 // Returns string representation of this object.
32 std::string ToString() const;
33
30 // How "boring" a thumbnail is. The boring score is the 0,1 ranged 34 // How "boring" a thumbnail is. The boring score is the 0,1 ranged
31 // percentage of pixels that are the most common luma. Higher boring 35 // percentage of pixels that are the most common luma. Higher boring
32 // scores indicate that a higher percentage of a bitmap are all the 36 // scores indicate that a higher percentage of a bitmap are all the
33 // same brightness (most likely the same color). 37 // same brightness (most likely the same color).
34 double boring_score; 38 double boring_score;
35 39
36 // Whether the thumbnail was taken with height greater then 40 // Whether the thumbnail was taken with height greater then
37 // width. In cases where we don't have |good_clipping|, the 41 // width. In cases where we don't have |good_clipping|, the
38 // thumbnails are either clipped from the horizontal center of the 42 // thumbnails are either clipped from the horizontal center of the
39 // window, or are otherwise weirdly stretched. 43 // window, or are otherwise weirdly stretched.
(...skipping 20 matching lines...) Expand all
60 // by the comparison function. 64 // by the comparison function.
61 // 65 //
62 // If "http://google.com/" redirected to "http://www.google.com/", then 66 // If "http://google.com/" redirected to "http://www.google.com/", then
63 // a thumbnail for the first would have a redirect hop of 1, and the second 67 // a thumbnail for the first would have a redirect hop of 1, and the second
64 // would have a redirect hop of 0. 68 // would have a redirect hop of 0.
65 int redirect_hops_from_dest; 69 int redirect_hops_from_dest;
66 70
67 // How bad a thumbnail needs to be before we completely ignore it. 71 // How bad a thumbnail needs to be before we completely ignore it.
68 static const double kThumbnailMaximumBoringness; 72 static const double kThumbnailMaximumBoringness;
69 73
74 // We consider a thumbnail interesting enough if the boring score is
75 // lower than this.
76 static const double kThumbnailInterestingEnoughBoringness;
77
70 // Time before we take a worse thumbnail (subject to 78 // Time before we take a worse thumbnail (subject to
71 // kThumbnailMaximumBoringness) over what's currently in the database 79 // kThumbnailMaximumBoringness) over what's currently in the database
72 // for freshness. 80 // for freshness.
73 static const base::TimeDelta kUpdateThumbnailTime; 81 static const base::TimeDelta kUpdateThumbnailTime;
74 82
75 // Penalty of how much more boring a thumbnail should be per hour. 83 // Penalty of how much more boring a thumbnail should be per hour.
76 static const double kThumbnailDegradePerHour; 84 static const double kThumbnailDegradePerHour;
85
86 // Checks whether we should consider updating a new thumbnail based on
87 // this score. For instance, we don't have to update a new thumbnail
88 // if the current thumbnail is new and interesting enough.
89 bool ShouldConsiderUpdating();
77 }; 90 };
78 91
79 // Checks whether we should replace one thumbnail with another. 92 // Checks whether we should replace one thumbnail with another.
80 bool ShouldReplaceThumbnailWith(const ThumbnailScore& current, 93 bool ShouldReplaceThumbnailWith(const ThumbnailScore& current,
81 const ThumbnailScore& replacement); 94 const ThumbnailScore& replacement);
82 95
83 #endif // CHROME_COMMON_THUMBNAIL_SCORE_H_ 96 #endif // CHROME_COMMON_THUMBNAIL_SCORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698