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> | |
mmenke
2012/07/09 18:06:57
Not needed.
gavinp
2012/07/11 17:04:00
Done.
| |
9 | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "base/threading/non_thread_safe.h" | |
mmenke
2012/07/09 18:06:57
base/basictypes.h should be here instead of in the
gavinp
2012/07/11 17:04:00
Done.
| |
12 | |
13 class GURL; | |
14 | |
15 namespace content { | |
16 class SessionStorageNamespace; | |
17 } | |
18 | |
19 namespace prerender { | |
20 | |
21 class PrerenderContents; | |
22 class PrerenderManager; | |
23 | |
24 class PrerenderHandle : public base::NonThreadSafe { | |
25 public: | |
26 ~PrerenderHandle(); | |
mmenke
2012/07/09 18:06:57
Suggest a comment that this calls OnCancel automat
gavinp
2012/07/11 17:04:00
Done.
| |
27 | |
28 // The launcher is navigating away from the context that launched this | |
29 // prerender. The prerender will likely stay alive briefly though, in case we | |
30 // are going through a redirect chain that will target it. This call | |
31 // invalidates the handle. | |
32 void OnNavigateAway(); | |
33 | |
34 // The launcher has taken explicit action to remove this prerender (for | |
35 // instance, removing a link element from a document). This call invalidates | |
36 // the handle. | |
mmenke
2012/07/09 18:06:57
Suggest a comment that it does nothing if abandone
gavinp
2012/07/11 17:04:00
I've tried hard to get rid of a lot of the abandon
mmenke
2012/07/11 18:40:05
Sure. I just want it clear that "OnNavigateAway()
gavinp
2012/07/11 21:19:30
Done.
| |
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; } | |
mmenke
2012/07/09 18:06:57
Don't inline this - style guide strongly discourag
gavinp
2012/07/11 17:04:00
Done.
| |
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. | |
mmenke
2012/07/09 18:06:57
nit: "running" is ambiguous (Is an idle, loaded w
gavinp
2012/07/11 17:04:00
Done.
| |
48 bool IsPrerendering() const; | |
49 | |
50 bool DidFinishLoading() const; | |
mmenke
2012/07/09 18:06:57
Suggest IsFinishedLoading(). If a prerender finis
gavinp
2012/07/11 17:04:00
Done.
| |
51 | |
52 private: | |
53 friend class PrerenderBrowserTest; | |
54 friend class PrerenderManager; | |
55 | |
56 struct PrerenderData { | |
57 explicit PrerenderData(PrerenderManager* manager); | |
58 PrerenderData(PrerenderManager* manager, | |
59 PrerenderContents* contents); | |
60 | |
61 PrerenderManager* manager; | |
62 PrerenderContents* contents; | |
63 int instance_count; | |
64 }; | |
65 | |
66 PrerenderHandle(); | |
67 explicit PrerenderHandle(base::WeakPtr<PrerenderData> prerender_data); | |
68 | |
69 void SwapPrerenderDataWith(PrerenderHandle* other_prerender_handle); | |
70 | |
71 base::WeakPtr<PrerenderData> prerender_data_; | |
72 base::WeakPtrFactory<PrerenderHandle> weak_ptr_factory_; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(PrerenderHandle); | |
75 }; | |
76 | |
77 } // namespace prerender | |
78 | |
79 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_HANDLE_H_ | |
OLD | NEW |