Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Side by Side Diff: chrome/browser/android/offline_pages/prerender_adapter.h

Issue 1968593002: PrerenderingLoader initial integration with PrerenderManager/PrerenderHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: An initialization order fix Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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_ANDROID_OFFLINE_PAGES_PRERENDER_ADAPTER_H_
6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDER_ADAPTER_H_
7
8 #include <memory>
9
10 #include "base/callback.h"
11 #include "chrome/browser/prerender/prerender_handle.h"
12 #include "chrome/browser/prerender/prerender_manager.h"
13 #include "components/offline_pages/background/offliner.h"
14
15 class GURL;
16
17 namespace content {
18 class BrowserContext;
19 class WebContents;
20 class SessionStorageNamespace;
21 } // namespace content
22
23 namespace gfx {
24 class Size;
25 } // namespace gfx
26
27 namespace offline_pages {
28
29 // An adapter for making calls into the prerender stack for managing an
30 // prerendering request for offlining (ORIGIN_OFFLINE). This provides virtual
31 // methods that may be overridden or mocked to allow for unit testing.
32 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
33 public:
34 PrerenderAdapter();
35 virtual ~PrerenderAdapter();
36
37 // Returns whether prerendering is enabled and configured.
38 virtual bool CanPrerender() const;
39
40 // Requests prerendering of |url| for offlining.
41 virtual bool AddPrerenderForOffline(
42 content::BrowserContext* browser_context,
43 const GURL& url,
44 content::SessionStorageNamespace* session_storage_namespace,
45 const gfx::Size& size);
46
47 // Sets an observer on prerendering events.
48 virtual void SetObserver(prerender::PrerenderHandle::Observer* observer);
49
50 // Returns whether actively prerendering.
51 virtual bool IsPrerendering() const;
52
53 // Reports that prerendering should be canceled.
54 virtual void OnCancel();
55
56 // Returns a pointer to the prerendered WebContents. This should only be
57 // called once prerendering observer events indicate content is loaded.
58 // It may be used for snapshotting the page. The caller does NOT get
59 // ownership on the contents and must call PrerenderingLoader::StopLoading()
60 // to report when it no longer needs the contents.
61 virtual content::WebContents* GetWebContents() const;
62
63 // Returns the final status of prerendering.
64 virtual prerender::FinalStatus GetFinalStatus() const;
65
66 // Returns whether there is an active prerendering.
67 virtual bool IsActive() const;
68
69 // Returns whether there is an active prerendering associated with
70 // the |handle|. This may be used to confirm that an observed prerender
71 // event for |handle| applies to the active prerendering.
72 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
73
74 // Destroys and clears any current prerendering operation and state.
75 virtual void DestroyActive();
76
77 private:
78 // At most one prerender request may be active for this adapter and this
79 // holds its handle if one is active.
80 std::unique_ptr<prerender::PrerenderHandle> active_handle_;
81 };
82
83 } // namespace offline_pages
84
85 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDER_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698