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

Side by Side Diff: chrome/browser/prerender/prerender_handle.h

Issue 10553029: Handle interface to prerenders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remediate to review Created 8 years, 5 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
(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/weak_ptr.h"
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::SupportsWeakPtr<PrerenderHandle>,
25 public base::NonThreadSafe {
26 public:
27 ~PrerenderHandle();
28
29 // The launcher is navigating away from the context that launched this
30 // prerender. The prerender will likely stay alive briefly though, in case we
31 // are going through a redirect chain that will target it. This call
32 // invalidates the handle.
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). This call invalidates
37 // the handle.
38 void OnCancel();
39
40 // True if the prerender (pending or running) has not been deleted out from
41 // under this handle.
42 bool IsValid() const { return prerender_data_ != NULL; }
43
44 // True if this prerender was launched by a page that was itself being
45 // prerendered, and so has not yet been started.
46 bool IsPending() const;
47
48 // True if this prerender is currently running.
49 bool IsPrerendering() const;
50
51 bool DidFinishLoading() const;
52
53 private:
54 friend class PrerenderBrowserTest;
55 friend class PrerenderManager;
56
57 using base::SupportsWeakPtr<PrerenderHandle>::AsWeakPtr;
58
59 struct PrerenderData {
60 explicit PrerenderData(PrerenderManager* manager);
61 PrerenderData(PrerenderManager* manager,
62 PrerenderContents* contents);
63
64 PrerenderManager* manager;
65 PrerenderContents* contents;
66 int instance_count;
67 };
68
69 PrerenderHandle();
70 explicit PrerenderHandle(base::WeakPtr<PrerenderData> prerender_data);
71
72 void SwapPrerenderDataWith(PrerenderHandle* other_prerender_handle);
73
74 base::WeakPtr<PrerenderData> prerender_data_;
75
76 DISALLOW_COPY_AND_ASSIGN(PrerenderHandle);
77 };
78
79 } // namespace prerender
80
81 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698