Chromium Code Reviews| Index: chrome/browser/android/offline_pages/prerender_adapter.h |
| diff --git a/chrome/browser/android/offline_pages/prerender_adapter.h b/chrome/browser/android/offline_pages/prerender_adapter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b80dc34c10586539eb72251716a082fdc3508ffc |
| --- /dev/null |
| +++ b/chrome/browser/android/offline_pages/prerender_adapter.h |
| @@ -0,0 +1,85 @@ |
| +// Copyright 2016 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_ANDROID_OFFLINE_PAGES_PRERENDER_ADAPTER_H_ |
| +#define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDER_ADAPTER_H_ |
| + |
| +#include <memory> |
| + |
| +#include "base/callback.h" |
| +#include "chrome/browser/prerender/prerender_handle.h" |
| +#include "chrome/browser/prerender/prerender_manager.h" |
| +#include "components/offline_pages/background/offliner.h" |
| + |
| +class GURL; |
| + |
| +namespace content { |
| +class BrowserContext; |
| +class WebContents; |
| +class SessionStorageNamespace; |
| +} // namespace content |
| + |
| +namespace gfx { |
| +class Size; |
| +} // namespace gfx |
| + |
| +namespace offline_pages { |
| + |
| +// An adapter for making calls into the prerender stack for managing an |
| +// prerendering request for offlining (ORIGIN_OFFLINE). This provides virtual |
| +// methods that may be overridden or mocked to allow for unit testing. |
| +class PrerenderAdapter { |
|
pasko
2016/05/12 19:10:07
looks closer in meaning to something like Prerende
dougarnett
2016/05/13 00:00:24
It has ended up close to that with just 2 Prerende
|
| + public: |
| + PrerenderAdapter(); |
| + virtual ~PrerenderAdapter(); |
| + |
| + // Returns whether prerendering is enabled and configured. |
| + virtual bool CanPrerender() const; |
| + |
| + // Requests prerendering of |url| for offlining. |
| + virtual bool AddPrerenderForOffline( |
| + content::BrowserContext* browser_context, |
| + const GURL& url, |
| + content::SessionStorageNamespace* session_storage_namespace, |
| + const gfx::Size& size); |
| + |
| + // Sets an observer on prerendering events. |
| + virtual void SetObserver(prerender::PrerenderHandle::Observer* observer); |
| + |
| + // Returns whether actively prerendering. |
| + virtual bool IsPrerendering() const; |
| + |
| + // Reports that prerendering should be canceled. |
| + virtual void OnCancel(); |
| + |
| + // Returns a pointer to the prerendered WebContents. This should only be |
| + // called once prerendering observer events indicate content is loaded. |
| + // It may be used for snapshotting the page. The caller does NOT get |
| + // ownership on the contents and must call PrerenderingLoader::StopLoading() |
| + // to report when it no longer needs the contents. |
| + virtual content::WebContents* GetWebContents() const; |
| + |
| + // Returns the final status of prerendering. |
| + virtual prerender::FinalStatus GetFinalStatus() const; |
| + |
| + // Returns whether there is an active prerendering. |
| + virtual bool IsActive() const; |
| + |
| + // Returns whether there is an active prerendering associated with |
| + // the |handle|. This may be used to confirm that an observed prerender |
| + // event for |handle| applies to the active prerendering. |
| + virtual bool IsActive(prerender::PrerenderHandle* handle) const; |
|
pasko
2016/05/12 19:10:07
would handle->IsPrerendering() be sufficient to re
dougarnett
2016/05/13 00:00:24
Maybe for IsActive() which is worried about whethe
|
| + |
| + // Destroys and clears any current prerendering operation and state. |
| + virtual void DestroyActive(); |
| + |
| + private: |
| + // At most one prerender request may be active for this adapter and this |
| + // holds its handle if one is active. |
| + std::unique_ptr<prerender::PrerenderHandle> active_handle_; |
| +}; |
| + |
| +} // namespace offline_pages |
| + |
| +#endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDER_ADAPTER_H_ |