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
3// found in the LICENSE file.
4
5#include "chrome/browser/history/page_usage_data.h"
6
7#include <algorithm>
8
9#include "third_party/skia/include/core/SkBitmap.h"
10
11PageUsageData::PageUsageData(history::URLID id)
12    : id_(id),
13      thumbnail_(NULL),
14      thumbnail_set_(false),
15      thumbnail_pending_(false),
16      favicon_(NULL),
17      favicon_set_(false),
18      favicon_pending_(false),
19      score_(0.0) {
20}
21
22PageUsageData::~PageUsageData() {
23  delete thumbnail_;
24  delete favicon_;
25}
26
27void PageUsageData::SetThumbnail(SkBitmap* img) {
28  if (thumbnail_ && thumbnail_ != img)
29    delete thumbnail_;
30
31  thumbnail_ = img;
32  thumbnail_set_ = true;
33}
34
35void PageUsageData::SetFavicon(SkBitmap* img) {
36  if (favicon_ && favicon_ != img)
37    delete favicon_;
38  favicon_ = img;
39  favicon_set_ = true;
40}
41
42// static
43bool PageUsageData::Predicate(const PageUsageData* lhs,
44                              const PageUsageData* rhs) {
45  return lhs->GetScore() > rhs->GetScore();
46}
47