Chromium Code Reviews| Index: chrome/browser/prerender/prerender_handle.h |
| diff --git a/chrome/browser/prerender/prerender_handle.h b/chrome/browser/prerender/prerender_handle.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b49c11fc12d2f4073cde293471a8d6215bb1e373 |
| --- /dev/null |
| +++ b/chrome/browser/prerender/prerender_handle.h |
| @@ -0,0 +1,68 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_PRERENDER_PRERENDER_HANDLE_H_ |
| +#define CHROME_BROWSER_PRERENDER_PRERENDER_HANDLE_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/threading/non_thread_safe.h" |
| +#include "chrome/browser/prerender/prerender_manager.h" |
| + |
| +class GURL; |
| + |
| +namespace content { |
| +class SessionStorageNamespace; |
| +} |
| + |
| +namespace prerender { |
| + |
| +class PrerenderContents; |
| + |
| +class PrerenderHandle : public base::NonThreadSafe { |
| + public: |
| + // If this handle is currently valid, the destructor will call OnCancel. |
| + ~PrerenderHandle(); |
| + |
| + // The launcher is navigating away from the context that launched this |
| + // prerender. The prerender will likely stay alive briefly though, in case we |
| + // are going through a redirect chain that will target it. This call |
| + // invalidates the handle. |
| + void OnNavigateAway(); |
| + |
| + // The launcher has taken explicit action to remove this prerender (for |
| + // instance, removing a link element from a document). This call invalidates |
| + // the handle. If the handle was previously invalidated by OnNavigateAway(), |
| + // this call does nothing. |
| + void OnCancel(); |
| + |
| + // True if the prerender (pending or running) has not been deleted out from |
| + // under this handle. |
| + bool IsValid() const; |
| + |
| + // True if this prerender was launched by a page that was itself being |
| + // prerendered, and so has not yet been started. |
| + bool IsPending() const; |
| + |
| + // True if this prerender is currently active. |
| + bool IsPrerendering() const; |
| + |
| + bool IsFinishedLoading() const; |
|
dominich
2012/07/12 16:16:48
nit: comment for this method.
gavinp
2012/07/13 12:02:22
Done.
|
| + |
| + private: |
| + friend class PrerenderManager; |
| + |
| + explicit PrerenderHandle(PrerenderManager::PrerenderData* prerender_data); |
| + |
| + void SwapPrerenderDataWith(PrerenderHandle* other_prerender_handle); |
| + |
| + base::WeakPtr<PrerenderManager::PrerenderData> prerender_data_; |
| + base::WeakPtrFactory<PrerenderHandle> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PrerenderHandle); |
| +}; |
| + |
| +} // namespace prerender |
| + |
| +#endif // CHROME_BROWSER_PRERENDER_PRERENDER_HANDLE_H_ |