summaryrefslogtreecommitdiffstats
path: root/chrome/common/thumbnail_score.cc
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-31 06:17:23 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-31 06:17:23 +0000
commitb93a206d2157e787fe522f4e21920e293f52e91f (patch)
tree506790590dff8dc55e710275ab2a1dc131934f94 /chrome/common/thumbnail_score.cc
parentc22fce3332a623a48865a39bdce56caaf22e7eb5 (diff)
downloadchromium_src-b93a206d2157e787fe522f4e21920e293f52e91f.zip
chromium_src-b93a206d2157e787fe522f4e21920e293f52e91f.tar.gz
chromium_src-b93a206d2157e787fe522f4e21920e293f52e91f.tar.bz2
Revert 87264 - Add load_completed property to ThumbnailScore.
The change broke the tsan (ThreadSanitizer) build: http://build.chromium.org/p/chromium.memory/builders/Linux%20Tests%20%28tsan%29/builds/3164 Thumbnails taken while page loading may only contain partial contents, hence these are not desirable. BUG=65936 TEST=with --enable-in-browser-thumbnailing --vmodule=thumbnail_generator=1, confirm that thumbnails taken while page loading were replaced with new ones properly. Review URL: http://codereview.chromium.org/6962008 TBR=satorux@chromium.org Review URL: http://codereview.chromium.org/7094002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/thumbnail_score.cc')
-rw-r--r--chrome/common/thumbnail_score.cc41
1 files changed, 20 insertions, 21 deletions
diff --git a/chrome/common/thumbnail_score.cc b/chrome/common/thumbnail_score.cc
index 055429d..37c942a 100644
--- a/chrome/common/thumbnail_score.cc
+++ b/chrome/common/thumbnail_score.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,25 +15,27 @@ const double ThumbnailScore::kThumbnailMaximumBoringness = 0.94;
const double ThumbnailScore::kThumbnailDegradePerHour = 0.01;
// Calculates a numeric score from traits about where a snapshot was
-// taken. The lower the better. We store the raw components in the
-// database because I'm sure this will evolve and I don't want to break
-// databases.
-static int GetThumbnailType(const ThumbnailScore& score) {
- int type = 0;
- if (!score.at_top)
- type += 1;
- if (!score.good_clipping)
- type += 2;
- if (!score.load_completed)
- type += 3;
- return type;
+// taken. We store the raw components in the database because I'm sure
+// this will evolve and I don't want to break databases.
+static int GetThumbnailType(bool good_clipping, bool at_top) {
+ if (good_clipping && at_top) {
+ return 0;
+ } else if (good_clipping && !at_top) {
+ return 1;
+ } else if (!good_clipping && at_top) {
+ return 2;
+ } else if (!good_clipping && !at_top) {
+ return 3;
+ } else {
+ NOTREACHED();
+ return -1;
+ }
}
ThumbnailScore::ThumbnailScore()
: boring_score(1.0),
good_clipping(false),
at_top(false),
- load_completed(false),
time_at_snapshot(Time::Now()),
redirect_hops_from_dest(0) {
}
@@ -42,7 +44,6 @@ ThumbnailScore::ThumbnailScore(double score, bool clipping, bool top)
: boring_score(score),
good_clipping(clipping),
at_top(top),
- load_completed(false),
time_at_snapshot(Time::Now()),
redirect_hops_from_dest(0) {
}
@@ -52,7 +53,6 @@ ThumbnailScore::ThumbnailScore(double score, bool clipping, bool top,
: boring_score(score),
good_clipping(clipping),
at_top(top),
- load_completed(false),
time_at_snapshot(time),
redirect_hops_from_dest(0) {
}
@@ -73,20 +73,19 @@ bool ThumbnailScore::Equals(const ThumbnailScore& rhs) const {
std::string ThumbnailScore::ToString() const {
return StringPrintf("boring_score: %f, at_top %d, good_clipping %d, "
- "load_completed: %d, "
"time_at_snapshot: %f, redirect_hops_from_dest: %d",
boring_score,
at_top,
good_clipping,
- load_completed,
time_at_snapshot.ToDoubleT(),
redirect_hops_from_dest);
}
bool ShouldReplaceThumbnailWith(const ThumbnailScore& current,
const ThumbnailScore& replacement) {
- int current_type = GetThumbnailType(current);
- int replacement_type = GetThumbnailType(replacement);
+ int current_type = GetThumbnailType(current.good_clipping, current.at_top);
+ int replacement_type = GetThumbnailType(replacement.good_clipping,
+ replacement.at_top);
if (replacement_type < current_type) {
// If we have a better class of thumbnail, add it if it meets
// certain minimum boringness.
@@ -132,7 +131,7 @@ bool ShouldReplaceThumbnailWith(const ThumbnailScore& current,
bool ThumbnailScore::ShouldConsiderUpdating() {
const TimeDelta time_elapsed = Time::Now() - time_at_snapshot;
if (time_elapsed < kUpdateThumbnailTime &&
- good_clipping && at_top && load_completed) {
+ good_clipping && at_top) {
// The current thumbnail is new and has good properties.
return false;
}