Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_LINK_MANAGER_H_ | |
| 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_LINK_MANAGER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <map> | |
| 10 #include <utility> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/gtest_prod_util.h" | |
| 14 #include "chrome/browser/profiles/profile_keyed_service.h" | |
| 15 #include "googleurl/src/gurl.h" | |
| 16 | |
| 17 class Profile; | |
| 18 | |
| 19 namespace content { | |
| 20 struct Referrer; | |
| 21 } | |
| 22 | |
| 23 namespace gfx { | |
| 24 class Size; | |
| 25 } | |
| 26 | |
| 27 namespace prerender { | |
| 28 | |
| 29 class PrerenderManager; | |
| 30 | |
| 31 // PrerenderLinkManager implements the API on Link elements for all documents | |
| 32 // being rendered in this chrome instance. It receives messages from the | |
| 33 // renderer indicating addition, cancelation and abandonment of link elements, | |
| 34 // and controls the PrerenderManager accordingly. | |
| 35 class PrerenderLinkManager : public ProfileKeyedService { | |
| 36 public: | |
| 37 explicit PrerenderLinkManager(PrerenderManager* manager); | |
| 38 virtual ~PrerenderLinkManager(); | |
| 39 | |
| 40 // A <link rel=prerender ...> element has been inserted into the document. | |
| 41 // The |prerender_id| must be unique per |child_id|, and is assigned by the | |
| 42 // WebPrerendererClient. | |
| 43 // Returns true if the prerender was accepted by the prerender manager, | |
| 44 // and false if not. In either case, the |prerender_id| is usable for | |
| 45 // future OnCancelPrerender and OnAbandonPrerender calls. | |
| 46 bool OnAddPrerender( | |
| 47 int child_id, | |
| 48 int prerender_id, | |
| 49 const GURL& url, | |
| 50 const content::Referrer& referrer, | |
| 51 const gfx::Size& size, | |
| 52 int render_view_route_id); | |
| 53 | |
| 54 // A <link rel=prerender ...> element has been explicitly removed from a | |
| 55 // document. | |
| 56 void OnCancelPrerender(int child_id, int prerender_id); | |
| 57 | |
| 58 // A renderer launching <link rel=prerender ...> has navigated away from the | |
| 59 // launching page, the launching renderer process has crashed, or perhaps the | |
| 60 // renderer process was fast-closed when the last render view in it was | |
| 61 // closed. | |
| 62 void OnAbandonPrerender(int child_id, int prerender_id); | |
| 63 | |
| 64 // If a renderer channel closes (crash, fast exit, etc...), that's effectively | |
| 65 // an abandon of any prerenders launched by that child. | |
| 66 void OnChannelClosing(int child_id); | |
| 67 | |
| 68 private: | |
| 69 friend class PrerenderBrowserTest; | |
|
cbentzel
2012/05/04 15:32:25
As I commented in prerender_browser_test.cc, I don
gavinp
2012/05/04 23:10:51
If you and mmenke can come to consensus, I'll make
| |
| 70 friend class PrerenderTest; | |
| 71 | |
| 72 typedef std::pair<int, int> ChildAndPrerenderIdPair; | |
| 73 typedef std::map<ChildAndPrerenderIdPair, GURL> IdPairToUrlMap; | |
| 74 | |
| 75 void RemovePrerender(const IdPairToUrlMap::iterator& id_url_iter); | |
| 76 | |
| 77 bool IsEmpty() const; | |
| 78 | |
| 79 PrerenderManager* manager_; | |
| 80 IdPairToUrlMap ids_to_url_map_; | |
| 81 | |
| 82 DISALLOW_COPY_AND_ASSIGN(PrerenderLinkManager); | |
| 83 }; | |
| 84 | |
| 85 } // namespace prerender | |
| 86 | |
| 87 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_LINK_MANAGER_H_ | |
| 88 | |
| OLD | NEW |