• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef CHROME_BROWSER_HISTORY_PAGE_USAGE_DATA_H__
6 #define CHROME_BROWSER_HISTORY_PAGE_USAGE_DATA_H__
7 #pragma once
8 
9 #include "base/string16.h"
10 #include "chrome/browser/history/history_types.h"
11 #include "googleurl/src/gurl.h"
12 
13 class SkBitmap;
14 
15 /////////////////////////////////////////////////////////////////////////////
16 //
17 // PageUsageData
18 //
19 // A per domain usage data structure to compute and manage most visited
20 // pages.
21 //
22 // See History::QueryPageUsageSince()
23 //
24 /////////////////////////////////////////////////////////////////////////////
25 class PageUsageData {
26  public:
27   explicit PageUsageData(history::URLID id);
28 
29   virtual ~PageUsageData();
30 
31   // Return the url ID
GetID()32   history::URLID GetID() const {
33     return id_;
34   }
35 
SetURL(const GURL & url)36   void SetURL(const GURL& url) {
37     url_ = url;
38   }
39 
GetURL()40   const GURL& GetURL() const {
41     return url_;
42   }
43 
SetTitle(const string16 & s)44   void SetTitle(const string16& s) {
45     title_ = s;
46   }
47 
GetTitle()48   const string16& GetTitle() const {
49     return title_;
50   }
51 
SetScore(double v)52   void SetScore(double v) {
53     score_ = v;
54   }
55 
GetScore()56   double GetScore() const {
57     return score_;
58   }
59 
SetThumbnailMissing()60   void SetThumbnailMissing() {
61     thumbnail_set_ = true;
62   }
63 
64   void SetThumbnail(SkBitmap* img);
65 
HasThumbnail()66   bool HasThumbnail() const {
67     return thumbnail_set_;
68   }
69 
GetThumbnail()70   const SkBitmap* GetThumbnail() const {
71     return thumbnail_;
72   }
73 
thumbnail_pending()74   bool thumbnail_pending() const {
75     return thumbnail_pending_;
76   }
77 
set_thumbnail_pending(bool pending)78   void set_thumbnail_pending(bool pending) {
79     thumbnail_pending_ = pending;
80   }
81 
SetFaviconMissing()82   void SetFaviconMissing() {
83     favicon_set_ = true;
84   }
85 
86   void SetFavicon(SkBitmap* img);
87 
HasFavicon()88   bool HasFavicon() const {
89     return favicon_set_;
90   }
91 
favicon_pending()92   bool favicon_pending() const {
93     return favicon_pending_;
94   }
95 
set_favicon_pending(bool pending)96   void set_favicon_pending(bool pending) {
97     favicon_pending_ = pending;
98   }
99 
GetFavicon()100   const SkBitmap* GetFavicon() const {
101     return favicon_;
102   }
103 
104   // Sort predicate to sort instances by score (high to low)
105   static bool Predicate(const PageUsageData* dud1,
106                         const PageUsageData* dud2);
107 
108  private:
109   history::URLID id_;
110   GURL url_;
111   string16 title_;
112 
113   SkBitmap* thumbnail_;
114   bool thumbnail_set_;
115   // Whether we have an outstanding request for the thumbnail.
116   bool thumbnail_pending_;
117 
118   SkBitmap* favicon_;
119   bool favicon_set_;
120   // Whether we have an outstanding request for the favicon.
121   bool favicon_pending_;
122 
123   double score_;
124 };
125 
126 #endif  // CHROME_BROWSER_HISTORY_PAGE_USAGE_DATA_H__
127