OLD | NEW |
(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_PRERENDERING_LOADER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_LOADER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "components/offline_pages/background/offliner.h" |
| 10 |
| 11 class GURL; |
| 12 class PrerenderManager; |
| 13 |
| 14 namespace content { |
| 15 class WebContents; |
| 16 class SessionStorageNamespace; |
| 17 } // namespace content |
| 18 |
| 19 namespace gfx { |
| 20 class Size; |
| 21 } // namespace gfx |
| 22 |
| 23 namespace offline_pages { |
| 24 |
| 25 // A client-side page loader that integrates with the PrerenderManager to do |
| 26 // the page loading in the background. |
| 27 class PrerenderingLoader { |
| 28 public: |
| 29 // Reports status of a load page request with loaded contents if available. |
| 30 typedef base::Callback<void(Offliner::CompletionStatus, |
| 31 content::WebContents*)> |
| 32 LoadPageCallback; |
| 33 |
| 34 explicit PrerenderingLoader(PrerenderManager* prerender_manager); |
| 35 ~PrerenderingLoader(); |
| 36 |
| 37 // Loads a page in the background if possible and returns whether the |
| 38 // request was accepted. If so, the LoadPageCallback will be informed |
| 39 // of status. Only one load request may exist as a time. If a previous |
| 40 // request is still in progress it must be canceled before a new |
| 41 // request will be accepted. |
| 42 bool LoadPage(const GURL& url, |
| 43 content::SessionStorageNamespace* session_storage_namespace, |
| 44 const gfx::Size& size, |
| 45 const LoadPageCallback& callback); |
| 46 |
| 47 // Stops (completes or cancels) the load request. Must be called when |
| 48 // LoadPageCallback is done with consuming the contents. |
| 49 // This loader should also be responsible for stopping offline |
| 50 // prerenders when Chrome is transitioned to foreground. |
| 51 void StopLoading(); |
| 52 }; |
| 53 |
| 54 } // namespace offline_pages |
| 55 |
| 56 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_LOADER_H_ |
OLD | NEW |