| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_RENDERER_PRERENDER_PRERENDER_DISPATCHER_H_ | 5 #ifndef CHROME_RENDERER_PRERENDER_PRERENDER_DISPATCHER_H_ |
| 6 #define CHROME_RENDERER_PRERENDER_PRERENDER_DISPATCHER_H_ | 6 #define CHROME_RENDERER_PRERENDER_PRERENDER_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "content/public/renderer/render_process_observer.h" | 12 #include "content/public/renderer/render_process_observer.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebPrerenderingSupp
ort.h" |
| 13 | 14 |
| 14 class GURL; | 15 class GURL; |
| 15 | 16 |
| 16 namespace prerender { | 17 namespace prerender { |
| 17 | 18 |
| 18 class PrerenderingSupport; | 19 // There is one PrerenderDispatcher per render process. It keeps track of which |
| 19 | 20 // prerenders were launched from this renderer, and ensures prerender navigation |
| 20 // PrerenderDispatcher keeps track of which URLs are being prerendered. There | 21 // is triggered on navigation to those. It implements the prerendering interface |
| 21 // is only one PrerenderDispatcher per render process, and it will only be | 22 // supplied to WebKit. |
| 22 // aware of prerenders that are triggered by this render process. As well, | 23 class PrerenderDispatcher : public content::RenderProcessObserver, |
| 23 // it holds on to other objects that must exist once per-renderer process, | 24 public WebKit::WebPrerenderingSupport { |
| 24 // such as the PrerenderingSupport. | |
| 25 class PrerenderDispatcher : public content::RenderProcessObserver { | |
| 26 public: | 25 public: |
| 27 PrerenderDispatcher(); | 26 PrerenderDispatcher(); |
| 28 virtual ~PrerenderDispatcher(); | 27 virtual ~PrerenderDispatcher(); |
| 29 | 28 |
| 30 bool IsPrerenderURL(const GURL & url) const; | 29 bool IsPrerenderURL(const GURL& url) const; |
| 31 | 30 |
| 32 private: | 31 private: |
| 33 friend class PrerenderDispatcherTest; | 32 friend class PrerenderDispatcherTest; |
| 34 | 33 |
| 35 void OnAddPrerenderURL(const GURL& url); | 34 void OnAddPrerenderURL(const GURL& url); |
| 36 void OnRemovePrerenderURL(const GURL& url); | 35 void OnRemovePrerenderURL(const GURL& url); |
| 37 | 36 |
| 38 // RenderProcessObserver: | 37 // From RenderProcessObserver: |
| 39 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | 38 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
| 40 | 39 |
| 40 // From WebPrerenderingSupport: |
| 41 virtual void add(const WebKit::WebPrerender& prerender) OVERRIDE; |
| 42 virtual void cancel(const WebKit::WebPrerender& prerender) OVERRIDE; |
| 43 virtual void abandon(const WebKit::WebPrerender& prerender) OVERRIDE; |
| 44 |
| 41 typedef std::map<GURL, int> PrerenderMap; | 45 typedef std::map<GURL, int> PrerenderMap; |
| 42 PrerenderMap prerender_urls_; | 46 PrerenderMap prerender_urls_; |
| 43 | |
| 44 // There is one PrerenderingSupport object per renderer, and it provides | |
| 45 // the interface to prerendering to the WebKit platform. | |
| 46 scoped_ptr<PrerenderingSupport> prerendering_support_; | |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 } // namespace prerender | 49 } // namespace prerender |
| 50 | 50 |
| 51 #endif // CHROME_RENDERER_PRERENDER_PRERENDER_DISPATCHER_H_ | 51 #endif // CHROME_RENDERER_PRERENDER_PRERENDER_DISPATCHER_H_ |
| OLD | NEW |