Chromium Code Reviews| 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 "base/basictypes.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "base/threading/non_thread_safe.h" | |
| 11 #include "chrome/browser/prerender/prerender_manager.h" | |
| 12 | |
| 13 class GURL; | |
| 14 | |
| 15 namespace content { | |
| 16 class SessionStorageNamespace; | |
| 17 } | |
| 18 | |
| 19 namespace prerender { | |
| 20 | |
| 21 class PrerenderContents; | |
| 22 | |
| 23 class PrerenderHandle : public base::NonThreadSafe { | |
| 24 public: | |
| 25 // If this handle is currently valid, the destructor will call OnCancel. | |
| 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; | |
| 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 active. | |
| 48 bool IsPrerendering() const; | |
| 49 | |
| 50 bool IsFinishedLoading() const; | |
| 51 | |
| 52 private: | |
| 53 friend class PrerenderManager; | |
| 54 | |
| 55 PrerenderHandle(); | |
| 56 explicit PrerenderHandle( | |
| 57 PrerenderManager::PrerenderData* prerender_data); | |
|
mmenke
2012/07/11 18:40:05
nit: May fit on one line now.
gavinp
2012/07/11 21:19:30
Done.
gavinp
2012/07/11 21:19:30
Done.
| |
| 58 | |
| 59 void SwapPrerenderDataWith(PrerenderHandle* other_prerender_handle); | |
| 60 | |
| 61 base::WeakPtr<PrerenderManager::PrerenderData> prerender_data_; | |
| 62 base::WeakPtrFactory<PrerenderHandle> weak_ptr_factory_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(PrerenderHandle); | |
| 65 }; | |
| 66 | |
| 67 } // namespace prerender | |
| 68 | |
| 69 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_HANDLE_H_ | |
| OLD | NEW |