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_HANDLE_H_ | |
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_HANDLE_H_ | |
7 | |
8 #include <list> | |
9 | |
10 #include "base/threading/non_thread_safe.h" | |
11 #include "base/memory/ref_counted.h" | |
dominich
2012/07/02 20:43:03
unnecessary ref_counted.h include?
gavinp
2012/07/03 16:41:02
Done.
| |
12 #include "base/memory/weak_ptr.h" | |
13 | |
14 class GURL; | |
15 | |
16 namespace content { | |
17 class SessionStorageNamespace; | |
18 } | |
19 | |
20 namespace prerender { | |
21 | |
22 class PrerenderContents; | |
23 class PrerenderManager; | |
24 | |
25 class PrerenderHandle : public base::SupportsWeakPtr<PrerenderHandle>, | |
26 public base::NonThreadSafe { | |
27 public: | |
28 ~PrerenderHandle(); | |
29 | |
30 // The launcher is navigating away from the context that launched this | |
31 // prerender. The prerender will likely stay alive briefly though, in case we | |
32 // are going through a redirect chain that will target it. | |
33 void OnNavigateAway(); | |
34 | |
35 // The launcher has taken explicit action to remove this prerender (for | |
36 // instance, removing a link element from a document). | |
37 void OnCancel(); | |
38 | |
39 // True if the prerender (pending or running) has not been deleted out from | |
40 // under this handle. | |
41 bool IsValid() const { return prerender_data_ != NULL; } | |
42 | |
43 // True if this prerender was launched by a page that was itself being | |
44 // prerendered, and so has not yet been started. | |
45 bool IsPending() const; | |
46 | |
47 // True if this prerender is currently running. | |
48 bool IsPrerendering() const; | |
49 | |
50 bool DidFinishLoading() const; | |
51 | |
52 private: | |
53 friend class PrerenderBrowserTest; | |
54 friend class PrerenderManager; | |
55 | |
56 using base::SupportsWeakPtr<PrerenderHandle>::AsWeakPtr; | |
dominich
2012/07/02 20:43:03
why is this using statement necessary?
gavinp
2012/07/03 16:41:02
To make the method private. I don't want to expose
dominich
2012/07/03 17:08:39
Then, as per the recent thread, you might want to
gavinp
2012/07/03 18:45:40
Done.
| |
57 | |
58 struct PrerenderData { | |
59 explicit PrerenderData(PrerenderManager* manager); | |
60 PrerenderData(PrerenderManager* manager, | |
61 PrerenderContents* contents); | |
62 | |
63 PrerenderContents* get_contents() { return contents; } | |
dominich
2012/07/02 20:43:03
no need for this accessor - contents is public. If
gavinp
2012/07/03 16:41:02
It's used only for a single std::transform in Prer
| |
64 | |
65 PrerenderManager* manager; | |
66 PrerenderContents* contents; | |
67 int client_count; | |
dominich
2012/07/02 20:43:03
instance_count?
gavinp
2012/07/03 16:41:02
Done.
| |
68 }; | |
69 | |
70 explicit PrerenderHandle(); | |
dominich
2012/07/02 20:43:03
no explicit
gavinp
2012/07/03 16:41:02
Done.
| |
71 explicit PrerenderHandle(base::WeakPtr<PrerenderData> prerender_data); | |
72 | |
73 void SwapPrerenderDataWith(PrerenderHandle* other_prerender_handle); | |
74 | |
75 base::WeakPtr<PrerenderData> prerender_data_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(PrerenderHandle); | |
78 }; | |
79 | |
80 } // namespace prerender | |
81 | |
82 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_HANDLE_H_ | |
OLD | NEW |