summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history/page_usage_data.h
blob: 07f58dd510d6c423d3c63b02c902c1b849b4bc4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright (c) 2012 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.

#ifndef CHROME_BROWSER_HISTORY_PAGE_USAGE_DATA_H__
#define CHROME_BROWSER_HISTORY_PAGE_USAGE_DATA_H__

#include "base/strings/string16.h"
#include "base/time/time.h"
#include "chrome/browser/history/history_types.h"
#include "url/gurl.h"

class SkBitmap;

/////////////////////////////////////////////////////////////////////////////
//
// PageUsageData
//
// A per domain usage data structure to compute and manage most visited
// pages.
//
// See History::QueryPageUsageSince()
//
/////////////////////////////////////////////////////////////////////////////
class PageUsageData {
 public:
  explicit PageUsageData(history::SegmentID id);

  virtual ~PageUsageData();

  // Return the url ID
  history::SegmentID GetID() const {
    return id_;
  }

  void SetURL(const GURL& url) {
    url_ = url;
  }

  const GURL& GetURL() const {
    return url_;
  }

  void SetTitle(const string16& s) {
    title_ = s;
  }

  const string16& GetTitle() const {
    return title_;
  }

  void SetScore(double v) {
    score_ = v;
  }

  double GetScore() const {
    return score_;
  }

  void SetDuration(base::TimeDelta duration) {
    duration_ = duration;
  }

  base::TimeDelta duration() const {
    return duration_;
  }

  // Sort predicate to sort instances by score (high to low)
  static bool Predicate(const PageUsageData* dud1, const PageUsageData* dud2);

 private:
  history::SegmentID id_;
  GURL url_;
  string16 title_;

  double score_;

  // Duration is only set by QuerySegmentDurationSince().
  base::TimeDelta duration_;
};

#endif  // CHROME_BROWSER_HISTORY_PAGE_USAGE_DATA_H__