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

Side by Side Diff: chrome/renderer/prerender/prerender_dispatcher.h

Issue 10424002: Adding unit tests for PrerenderDispatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaner interface for more readable tests Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/gtest_prod_util.h"
13 #include "content/public/renderer/render_process_observer.h" 14 #include "content/public/renderer/render_process_observer.h"
14 15
15 class GURL; 16 class GURL;
16 17
17 namespace prerender { 18 namespace prerender {
18 19
19 class PrerenderingSupport; 20 class PrerenderingSupport;
20 21
21 // PrerenderDispatcher keeps track of which URLs are being prerendered. There 22 // PrerenderDispatcher keeps track of which URLs are being prerendered. There
22 // is only one PrerenderDispatcher per render process, and it will only be 23 // is only one PrerenderDispatcher per render process, and it will only be
23 // aware of prerenders that are triggered by this render process. As well, 24 // aware of prerenders that are triggered by this render process. As well,
24 // it holds on to other objects that must exist once per-renderer process, 25 // it holds on to other objects that must exist once per-renderer process,
25 // such as the PrerenderingSupport. 26 // such as the PrerenderingSupport.
26 class PrerenderDispatcher : public content::RenderProcessObserver { 27 class PrerenderDispatcher : public content::RenderProcessObserver {
27 public: 28 public:
28 PrerenderDispatcher(); 29 PrerenderDispatcher();
29 virtual ~PrerenderDispatcher(); 30 virtual ~PrerenderDispatcher();
30 31
31 bool IsPrerenderURL(const GURL & url) const; 32 bool IsPrerenderURL(const GURL & url) const;
32 33
33 private: 34 private:
35 friend class PrerenderDispatcherTest;
36 FRIEND_TEST_ALL_PREFIXES(PrerenderDispatcherTest, PrerenderDispatcherEmpty);
gavinp 2012/05/24 17:39:40 Do you need these now? I think you don't, and pro
dominich 2012/05/24 18:11:56 Done.
37 FRIEND_TEST_ALL_PREFIXES(PrerenderDispatcherTest,
38 PrerenderDispatcherSingleAdd);
39 FRIEND_TEST_ALL_PREFIXES(PrerenderDispatcherTest,
40 PrerenderDispatcherMultipleAdd);
41 FRIEND_TEST_ALL_PREFIXES(PrerenderDispatcherTest,
42 PrerenderDispatcherSingleRemove);
43 FRIEND_TEST_ALL_PREFIXES(PrerenderDispatcherTest,
44 PrerenderDispatcherMultipleRemove);
34 void OnAddPrerenderURL(const GURL& url); 45 void OnAddPrerenderURL(const GURL& url);
35 void OnRemovePrerenderURL(const GURL& url); 46 void OnRemovePrerenderURL(const GURL& url);
36 47
37 // RenderProcessObserver: 48 // RenderProcessObserver:
38 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; 49 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
39 50
40 typedef std::map<GURL, int> PrerenderMap; 51 typedef std::map<GURL, int> PrerenderMap;
41 PrerenderMap prerender_urls_; 52 PrerenderMap prerender_urls_;
42 53
43 // There is one PrerenderingSupport object per renderer, and it provides 54 // There is one PrerenderingSupport object per renderer, and it provides
44 // the interface to prerendering to the WebKit platform. 55 // the interface to prerendering to the WebKit platform.
45 scoped_ptr<PrerenderingSupport> prerendering_support_; 56 scoped_ptr<PrerenderingSupport> prerendering_support_;
46 }; 57 };
47 58
48 } // namespace prerender 59 } // namespace prerender
49 60
50 #endif // CHROME_RENDERER_PRERENDER_PRERENDER_DISPATCHER_H_ 61 #endif // CHROME_RENDERER_PRERENDER_PRERENDER_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698