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