1 // Copyright (c) 2011 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_PRERENDER_PRERENDER_HISTORY_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_HISTORY_H_
10 #include "base/threading/non_thread_safe.h"
11 #include "base/time/time.h"
12 #include "chrome/browser/prerender/prerender_final_status.h"
13 #include "chrome/browser/prerender/prerender_origin.h"
22 // PrerenderHistory maintains a per-session history of prerendered pages
23 // and their final dispositions. It has a fixed maximum capacity, and old
24 // items in history will be removed when the capacity is reached.
25 class PrerenderHistory
: public base::NonThreadSafe
{
27 // Entry is an individual entry in the history list. It corresponds to a
28 // specific prerendered page.
30 Entry() : final_status(FINAL_STATUS_MAX
), origin(ORIGIN_MAX
) {}
32 Entry(const GURL
& url_arg
,
33 FinalStatus final_status_arg
,
35 base::Time end_time_arg
)
36 : url(url_arg
), final_status(final_status_arg
),
38 end_time(end_time_arg
) {
41 // The URL which was prerendered. This should be the URL included in the
42 // <link rel="prerender"> tag, and not any URLs which it may have redirected
46 // The FinalStatus describing whether the prerendered page was used or why
48 FinalStatus final_status
;
50 // The Origin describing where the prerender originated from.
53 // Time the PrerenderContents was destroyed.
57 // Creates a history with capacity for |max_items| entries.
58 explicit PrerenderHistory(size_t max_items
);
61 // Adds |entry| to the history. If at capacity, the oldest entry is dropped.
62 void AddEntry(const Entry
& entry
);
64 // Deletes all history entries.
67 // Retrieves the entries as a value which can be displayed.
68 base::Value
* GetEntriesAsValue() const;
71 std::list
<Entry
> entries_
;
74 DISALLOW_COPY_AND_ASSIGN(PrerenderHistory
);
78 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_HISTORY_H_