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. If the handle was previously invalidated by OnNavigateAway(), |
| 37 // this call does nothing. |
| 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; |
| 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 active. |
| 49 bool IsPrerendering() const; |
| 50 |
| 51 bool IsFinishedLoading() const; |
| 52 |
| 53 private: |
| 54 friend class PrerenderManager; |
| 55 |
| 56 explicit PrerenderHandle(PrerenderManager::PrerenderData* prerender_data); |
| 57 |
| 58 void SwapPrerenderDataWith(PrerenderHandle* other_prerender_handle); |
| 59 |
| 60 base::WeakPtr<PrerenderManager::PrerenderData> prerender_data_; |
| 61 base::WeakPtrFactory<PrerenderHandle> weak_ptr_factory_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(PrerenderHandle); |
| 64 }; |
| 65 |
| 66 } // namespace prerender |
| 67 |
| 68 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_HANDLE_H_ |
OLD | NEW |