1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_TYPES_H_
6 #define CHROME_BROWSER_HISTORY_HISTORY_TYPES_H_
8 #include "components/history/core/browser/history_types.h"
9 #include "content/public/common/page_transition_types.h"
17 // Identifier for a context to scope page ids. (ContextIDs are used in
18 // comparisons only and are never dereferenced.)
19 // NB: The use of WebContents here is temporary; when the dependency on content
20 // is broken, some other type will take its place.
21 typedef content::WebContents* ContextID;
23 // VisitRow -------------------------------------------------------------------
25 // Holds all information associated with a specific visit. A visit holds time
26 // and referrer information for one time a URL is visited.
30 VisitRow(URLID arg_url_id,
31 base::Time arg_visit_time,
32 VisitID arg_referring_visit,
33 content::PageTransition arg_transition,
34 SegmentID arg_segment_id);
37 // ID of this row (visit ID, used a a referrer for other visits).
40 // Row ID into the URL table of the URL that this page is.
43 base::Time visit_time;
45 // Indicates another visit that was the referring page for this one.
46 // 0 indicates no referrer.
47 VisitID referring_visit;
49 // A combination of bits from PageTransition.
50 content::PageTransition transition;
52 // The segment id (see visitsegment_database.*).
53 // If 0, the segment id is null in the table.
56 // Record how much time a user has this visit starting from the user
57 // opened this visit to the user closed or ended this visit.
58 // This includes both active and inactive time as long as
59 // the visit was present.
60 base::TimeDelta visit_duration;
62 // Compares two visits based on dates, for sorting.
63 bool operator<(const VisitRow& other) {
64 return visit_time < other.visit_time;
67 // We allow the implicit copy constuctor and operator=.
70 // We pass around vectors of visits a lot
71 typedef std::vector<VisitRow> VisitVector;
73 // The basic information associated with a visit (timestamp, type of visit),
74 // used by HistoryBackend::AddVisits() to create new visits for a URL.
75 typedef std::pair<base::Time, content::PageTransition> VisitInfo;
77 // QueryURLResult -------------------------------------------------------------
79 // QueryURLResult encapsulates the result of a call to HistoryBackend::QueryURL.
80 struct QueryURLResult {
84 // Indicates whether the call to HistoryBackend::QueryURL was successfull
85 // or not. If false, then both |row| and |visits| fields are undefined.
91 // Navigation -----------------------------------------------------------------
93 // Marshalling structure for AddPage.
94 struct HistoryAddPageArgs {
95 // The default constructor is equivalent to:
97 // HistoryAddPageArgs(
98 // GURL(), base::Time(), NULL, 0, GURL(),
99 // history::RedirectList(), content::PAGE_TRANSITION_LINK,
100 // SOURCE_BROWSED, false)
101 HistoryAddPageArgs();
102 HistoryAddPageArgs(const GURL& url,
104 ContextID context_id,
106 const GURL& referrer,
107 const history::RedirectList& redirects,
108 content::PageTransition transition,
110 bool did_replace_entry);
111 ~HistoryAddPageArgs();
116 ContextID context_id;
120 history::RedirectList redirects;
121 content::PageTransition transition;
122 VisitSource visit_source;
123 bool did_replace_entry;
126 // Abbreviated information about a visit.
127 struct BriefVisitInfo {
130 content::PageTransition transition;
133 // An observer of VisitDatabase.
134 class VisitDatabaseObserver {
136 virtual ~VisitDatabaseObserver();
137 virtual void OnAddVisit(const BriefVisitInfo& info) = 0;
140 } // namespace history
142 #endif // CHROME_BROWSER_HISTORY_HISTORY_TYPES_H_