[Android] Added UMA for search by image context menu.
[chromium-blink-merge.git] / chrome / renderer / prerender / prerender_dispatcher.h
blob559feb87cfd7688b24b086ca5905cb47651394b3
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.
5 #ifndef CHROME_RENDERER_PRERENDER_PRERENDER_DISPATCHER_H_
6 #define CHROME_RENDERER_PRERENDER_PRERENDER_DISPATCHER_H_
8 #include <map>
9 #include <set>
10 #include <vector>
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "content/public/renderer/render_process_observer.h"
15 #include "third_party/WebKit/public/platform/WebPrerender.h"
16 #include "third_party/WebKit/public/platform/WebPrerenderingSupport.h"
18 class GURL;
20 namespace prerender {
22 // There is one PrerenderDispatcher per render process. It keeps track of which
23 // prerenders were launched from this renderer, and ensures prerender navigation
24 // is triggered on navigation to those. It implements the prerendering interface
25 // supplied to WebKit.
26 class PrerenderDispatcher : public content::RenderProcessObserver,
27 public WebKit::WebPrerenderingSupport {
28 public:
29 PrerenderDispatcher();
30 virtual ~PrerenderDispatcher();
32 bool IsPrerenderURL(const GURL& url) const;
34 private:
35 friend class PrerenderDispatcherTest;
37 // Message handlers for messages from the browser process.
38 void OnPrerenderStart(int prerender_id);
39 void OnPrerenderStopLoading(int prerender_id);
40 void OnPrerenderAddAlias(const GURL& alias);
41 void OnPrerenderRemoveAliases(const std::vector<GURL>& aliases);
42 void OnPrerenderStop(int prerender_id);
44 // From RenderProcessObserver:
45 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
47 // From WebPrerenderingSupport:
48 virtual void add(const WebKit::WebPrerender& prerender) OVERRIDE;
49 virtual void cancel(const WebKit::WebPrerender& prerender) OVERRIDE;
50 virtual void abandon(const WebKit::WebPrerender& prerender) OVERRIDE;
52 // From WebKit, prerender elements launched by renderers in our process.
53 std::map<int, WebKit::WebPrerender> prerenders_;
55 // From the browser process, which prerenders are running, indexed by URL.
56 // Updated by the browser processes as aliases are discovered.
57 std::multiset<GURL> running_prerender_urls_;
60 } // namespace prerender
62 #endif // CHROME_RENDERER_PRERENDER_PRERENDER_DISPATCHER_H_