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..ba2a822df28d11c033ffebeb4a049145740fc06a |
| --- /dev/null |
| +++ b/chrome/browser/prerender/prerender_handle.h |
| @@ -0,0 +1,82 @@ |
| +// 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 <list> |
| + |
| +#include "base/threading/non_thread_safe.h" |
| +#include "base/memory/ref_counted.h" |
|
dominich
2012/07/02 20:43:03
unnecessary ref_counted.h include?
gavinp
2012/07/03 16:41:02
Done.
|
| +#include "base/memory/weak_ptr.h" |
| + |
| +class GURL; |
| + |
| +namespace content { |
| +class SessionStorageNamespace; |
| +} |
| + |
| +namespace prerender { |
| + |
| +class PrerenderContents; |
| +class PrerenderManager; |
| + |
| +class PrerenderHandle : public base::SupportsWeakPtr<PrerenderHandle>, |
| + public base::NonThreadSafe { |
| + public: |
| + ~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. |
| + void OnNavigateAway(); |
| + |
| + // The launcher has taken explicit action to remove this prerender (for |
| + // instance, removing a link element from a document). |
| + void OnCancel(); |
| + |
| + // True if the prerender (pending or running) has not been deleted out from |
| + // under this handle. |
| + bool IsValid() const { return prerender_data_ != NULL; } |
| + |
| + // 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 running. |
| + bool IsPrerendering() const; |
| + |
| + bool DidFinishLoading() const; |
| + |
| + private: |
| + friend class PrerenderBrowserTest; |
| + friend class PrerenderManager; |
| + |
| + using base::SupportsWeakPtr<PrerenderHandle>::AsWeakPtr; |
|
dominich
2012/07/02 20:43:03
why is this using statement necessary?
gavinp
2012/07/03 16:41:02
To make the method private. I don't want to expose
dominich
2012/07/03 17:08:39
Then, as per the recent thread, you might want to
gavinp
2012/07/03 18:45:40
Done.
|
| + |
| + struct PrerenderData { |
| + explicit PrerenderData(PrerenderManager* manager); |
| + PrerenderData(PrerenderManager* manager, |
| + PrerenderContents* contents); |
| + |
| + PrerenderContents* get_contents() { return contents; } |
|
dominich
2012/07/02 20:43:03
no need for this accessor - contents is public. If
gavinp
2012/07/03 16:41:02
It's used only for a single std::transform in Prer
|
| + |
| + PrerenderManager* manager; |
| + PrerenderContents* contents; |
| + int client_count; |
|
dominich
2012/07/02 20:43:03
instance_count?
gavinp
2012/07/03 16:41:02
Done.
|
| + }; |
| + |
| + explicit PrerenderHandle(); |
|
dominich
2012/07/02 20:43:03
no explicit
gavinp
2012/07/03 16:41:02
Done.
|
| + explicit PrerenderHandle(base::WeakPtr<PrerenderData> prerender_data); |
| + |
| + void SwapPrerenderDataWith(PrerenderHandle* other_prerender_handle); |
| + |
| + base::WeakPtr<PrerenderData> prerender_data_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PrerenderHandle); |
| +}; |
| + |
| +} // namespace prerender |
| + |
| +#endif // CHROME_BROWSER_PRERENDER_PRERENDER_HANDLE_H_ |