BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / prerender / prerender_history.h
blobdff22e2bd7ef8d433040da88a8422149ac576f1b
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_
8 #include <list>
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"
14 #include "url/gurl.h"
16 namespace base {
17 class Value;
20 namespace prerender {
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 {
26 public:
27 // Entry is an individual entry in the history list. It corresponds to a
28 // specific prerendered page.
29 struct Entry {
30 Entry() : final_status(FINAL_STATUS_MAX), origin(ORIGIN_MAX) {}
32 Entry(const GURL& url_arg,
33 FinalStatus final_status_arg,
34 Origin origin_arg,
35 base::Time end_time_arg)
36 : url(url_arg), final_status(final_status_arg),
37 origin(origin_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
43 // to.
44 GURL url;
46 // The FinalStatus describing whether the prerendered page was used or why
47 // it was cancelled.
48 FinalStatus final_status;
50 // The Origin describing where the prerender originated from.
51 Origin origin;
53 // Time the PrerenderContents was destroyed.
54 base::Time end_time;
57 // Creates a history with capacity for |max_items| entries.
58 explicit PrerenderHistory(size_t max_items);
59 ~PrerenderHistory();
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.
65 void Clear();
67 // Retrieves the entries as a value which can be displayed.
68 base::Value* GetEntriesAsValue() const;
70 private:
71 std::list<Entry> entries_;
72 size_t max_items_;
74 DISALLOW_COPY_AND_ASSIGN(PrerenderHistory);
78 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_HISTORY_H_