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

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: a previous version of VSS wasn't as good as the current one. 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::NonThreadSafe {
25 public:
26 ~PrerenderHandle();
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.
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 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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698