diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 19:57:29 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 19:57:29 +0000 |
commit | e26020469bc0ecf2a31471465fd6782465b9be1c (patch) | |
tree | 74d243147ebbac8bc55922a03e4c35df43be5f33 /chrome/browser/prerender/prerender_history.h | |
parent | 1a5f6e5a2466e9a3bf47300dc56afe4d708d9524 (diff) | |
download | chromium_src-e26020469bc0ecf2a31471465fd6782465b9be1c.zip chromium_src-e26020469bc0ecf2a31471465fd6782465b9be1c.tar.gz chromium_src-e26020469bc0ecf2a31471465fd6782465b9be1c.tar.bz2 |
Prerender tab for net-internals
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/7143001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89235 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prerender/prerender_history.h')
-rw-r--r-- | chrome/browser/prerender/prerender_history.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/chrome/browser/prerender/prerender_history.h b/chrome/browser/prerender/prerender_history.h new file mode 100644 index 0000000..1754c2b --- /dev/null +++ b/chrome/browser/prerender/prerender_history.h @@ -0,0 +1,61 @@ +// Copyright (c) 2011 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_PRERENDER_PRERENDER_HISTORY_H_ +#define CHROME_BROWSER_PRERENDER_PRERENDER_HISTORY_H_ +#pragma once + +#include <list> + +#include "base/threading/non_thread_safe.h" +#include "chrome/browser/prerender/prerender_final_status.h" +#include "googleurl/src/gurl.h" + +class Value; + +namespace prerender { + +// PrerenderHistory maintains a per-session history of prerendered pages +// and their final dispositions. It has a fixed maximum capacity, and old +// items in history will be removed when the capacity is reached. +class PrerenderHistory : public base::NonThreadSafe { + public: + // Entry is an individual entry in the history list. It corresponds to a + // specific prerendered page. + struct Entry { + Entry() : final_status(FINAL_STATUS_MAX) {} + + Entry(const GURL& url_arg, FinalStatus final_status_arg) + : url(url_arg), final_status(final_status_arg) { + } + + // The URL which was prerendered. This should be the URL included in the + // <link rel="prerender"> tag, and not any URLs which it may have redirected + // to. + GURL url; + + // The FinalStatus describing whether the prerendered page was used or why + // it was cancelled. + FinalStatus final_status; + }; + + // Creates a history with capacity for |max_items| entries. + explicit PrerenderHistory(size_t max_items); + ~PrerenderHistory(); + + // Adds |entry| to the history. If at capacity, the oldest entry is dropped. + void AddEntry(const Entry& entry); + + // Retrieves the entries as a value which can be displayed. + Value* GetEntriesAsValue() const; + + private: + std::list<Entry> entries_; + size_t max_items_; + + DISALLOW_COPY_AND_ASSIGN(PrerenderHistory); +}; + +} +#endif // CHROME_BROWSER_PRERENDER_PRERENDER_HISTORY_H_ |