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

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

Issue 10198040: New link rel=prerender api, using WebKit::WebPrerenderingPlatform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediate to dominich review 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..04d342965dd44c1c1c318fecc2d9f7a10e015dd1
--- /dev/null
+++ b/chrome/browser/prerender/prerender_link_manager.h
@@ -0,0 +1,94 @@
+// 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;
+
+// PrerenderLinkManager implements the API on Link elements for all documents
+// being rendered in this chrome instance. It receives messages from the
+// renderer indicating addition, cancelation and abandonment of link elements,
+// and controls the PrerenderManager accordingly.
+class PrerenderLinkManager : public ProfileKeyedService {
+ public:
+ explicit PrerenderLinkManager(PrerenderManager* manager);
+ virtual ~PrerenderLinkManager();
+
+ // A <link rel=prerender ...> element has been inserted into the document.
+ // The |prerender_id| must be unique per |child_id|, and is typically
+ // assigned by the WebPrerendererClient.
dominich 2012/04/30 15:52:05 Is it ever not assigned by the WebPrerendererClien
gavinp 2012/04/30 23:55:39 No, never. Fixed.
+ // Returns true if the prerender was accepted by the prerender manager,
+ // and false if not. In either case, the |prerender_id| is usable for
+ // future OnCancelPrerender and OnAbandonPrerender calls.
+ bool OnAddPrerender(
+ int child_id,
+ int prerender_id,
+ 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);
mmenke 2012/04/30 18:35:22 nit swap argument order, here and below.
gavinp 2012/04/30 23:55:39 Yes. Thanks for catching this; I should have done
+
+ // A renderer launching <link rel=prerender ...> has navigated away from the
+ // launching page, the launching renderer process has crashed, or perhaps the
+ // renderer process was fast-closed when the last render view in it was
+ // 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:
+ FRIEND_TEST_ALL_PREFIXES(PrerenderBrowserTest, PrerenderPage);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderBrowserTest, PrerenderPageRemovingLink);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderBrowserTest,
+ PrerenderPageRemovingLinkWithTwoLinks);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderBrowserTest,
+ PrerenderPageRemovingLinkWithTwoLinksRemovingOne);
+ friend class PrerenderTest;
+
+ typedef std::pair<int, int> ChildAndPrerenderIdPair;
+ typedef std::map<ChildAndPrerenderIdPair, GURL> IdPairToUrlMap;
+ typedef std::multimap<GURL, ChildAndPrerenderIdPair> UrlToIdPairMap;
dominich 2012/04/30 15:52:05 This type isn't used any more, is it?
gavinp 2012/04/30 23:55:39 Done.
+
+ void RemovePrerender(const IdPairToUrlMap::iterator& id_url_iter);
+
+ bool IsEmpty() const;
+
+ PrerenderManager* manager_;
+ IdPairToUrlMap ids_to_url_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrerenderLinkManager);
+};
+
+} // namespace prerender
+
+#endif // CHROME_BROWSER_PRERENDER_PRERENDER_LINK_MANAGER_H_
+

Powered by Google App Engine
This is Rietveld 408576698