Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(892)

Unified Diff: chrome/browser/prerender/prerender_link_manager.h

Issue 9875026: **NOTFORLANDING** New link rel=prerender API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch sets 3-7 against trunk, for combined browsing Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prerender/prerender_link_manager.h
diff --git a/chrome/browser/prerender/prerender_link_manager.h b/chrome/browser/prerender/prerender_link_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..bc3bccda9c18b270b28e3b6e8b976509abb54865
--- /dev/null
+++ b/chrome/browser/prerender/prerender_link_manager.h
@@ -0,0 +1,76 @@
+// Copyright (c) 2012 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_LINK_MANAGER_H_
+#define CHROME_BROWSER_PRERENDER_PRERENDER_LINK_MANAGER_H_
+#pragma once
+
+#include <map>
+#include <utility>
+
+#include "base/basictypes.h"
+#include "base/gtest_prod_util.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+#include "googleurl/src/gurl.h"
+
+class Profile;
+
+namespace content {
+struct Referrer;
+}
+
+namespace gfx {
+class Size;
+}
+
+namespace prerender {
+
+class PrerenderManager;
+
+// Launch and cancel prerenders based on the LinkPrerender element events.
cbentzel 2012/04/24 15:42:59 I'd prefer a bit more description here.
gavinp 2012/04/26 23:55:39 Done.
+class PrerenderLinkManager : public ProfileKeyedService {
+ public:
+ explicit PrerenderLinkManager(PrerenderManager* manager);
+ virtual ~PrerenderLinkManager();
+
+ // A <link rel=prerender ...> element has been inserted into the document.
+ void OnAddPrerender(
+ int prerender_id,
+ int child_id,
mmenke 2012/04/24 15:26:15 nit: I suggest always putting child_id first. Th
gavinp 2012/04/26 23:55:39 Done.
+ const GURL& url,
+ const content::Referrer& referrer,
+ const gfx::Size& size,
+ int render_view_route_id);
+
+ // A <link rel=prerender ...> element has been explicitly removed from a
+ // document.
+ void OnCancelPrerender(int prerender_id, int child_id);
+
+ // A renderer launching <link rel=prerender ...> has navigated away from the
+ // launching page, the launching renderer process has crashed, or perhaps the
+ // renderer processed was fast-closed when the last render view in it was
cbentzel 2012/04/24 15:42:59 Nit: renderer process
gavinp 2012/04/26 23:55:39 Done.
+ // closed.
+ void OnAbandonPrerender(int prerender_id, int child_id);
+
+ // If a renderer channel closes (crash, fast exit, etc...), that's effectively
+ // an abandon of any prerenders launched by that child.
+ void OnChannelClosing(int child_id);
+
+ private:
+ typedef std::pair<int, int> ChildAndPrerenderIdPair;
+ typedef std::map<ChildAndPrerenderIdPair, GURL> PrerenderIdToUrlMap;
mmenke 2012/04/24 15:26:15 nit: Suggest you rename this either IdToUrlMap, I
gavinp 2012/04/26 23:55:39 Done.
+ typedef std::multimap<GURL, ChildAndPrerenderIdPair> UrlToPrerenderIdMap;
+
+ void RemovePrerender(const PrerenderIdToUrlMap::iterator& id_url_iter);
+
+ PrerenderManager* manager_;
+ PrerenderIdToUrlMap id_map_;
+ UrlToPrerenderIdMap url_map_;
mmenke 2012/04/24 15:26:15 nit: Suggest you rename these ids_to_url_map_, et
gavinp 2012/04/26 23:55:39 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(PrerenderLinkManager);
+};
+
+} // namespace prerender
+
+#endif // CHROME_BROWSER_PRERENDER_PRERENDER_LINK_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698