| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 std::unique_ptr<PrerenderAdapter> prerender_adapter); | 67 std::unique_ptr<PrerenderAdapter> prerender_adapter); |
| 68 | 68 |
| 69 // PrerenderAdapter::Observer implementation: | 69 // PrerenderAdapter::Observer implementation: |
| 70 void OnPrerenderStopLoading() override; | 70 void OnPrerenderStopLoading() override; |
| 71 void OnPrerenderDomContentLoaded() override; | 71 void OnPrerenderDomContentLoaded() override; |
| 72 void OnPrerenderStop() override; | 72 void OnPrerenderStop() override; |
| 73 | 73 |
| 74 // SnapshotController::Client implementation: | 74 // SnapshotController::Client implementation: |
| 75 void StartSnapshot() override; | 75 void StartSnapshot() override; |
| 76 | 76 |
| 77 // Returns true if the lowbar of snapshotting a page is met. |
| 78 bool IsLowbarMet(); |
| 79 |
| 77 private: | 80 private: |
| 78 // State of the loader (only one request may be active at a time). | 81 // State of the loader (only one request may be active at a time). |
| 79 enum class State { | 82 enum class State { |
| 80 IDLE, // No active load request. | 83 IDLE, // No active load request. |
| 81 PENDING, // Load request is pending the start of prerendering. | 84 PENDING, // Load request is pending the start of prerendering. |
| 82 LOADING, // Loading in progress. | 85 LOADING, // Loading in progress. |
| 83 LOADED, // Loaded and now waiting for requestor to StopLoading(). | 86 LOADED, // Loaded and now waiting for requestor to StopLoading(). |
| 84 }; | 87 }; |
| 85 | 88 |
| 86 // Handles some event/signal that the load request has succeeded or failed. | 89 // Handles some event/signal that the load request has succeeded or failed. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 109 std::unique_ptr<PrerenderAdapter> adapter_; | 112 std::unique_ptr<PrerenderAdapter> adapter_; |
| 110 | 113 |
| 111 // A WebContents for the active load request that is used to hold the session | 114 // A WebContents for the active load request that is used to hold the session |
| 112 // storage namespace for rendering. This will NOT have the loaded page. | 115 // storage namespace for rendering. This will NOT have the loaded page. |
| 113 std::unique_ptr<content::WebContents> session_contents_; | 116 std::unique_ptr<content::WebContents> session_contents_; |
| 114 | 117 |
| 115 // Callback to call when the active load request completes, fails, or is | 118 // Callback to call when the active load request completes, fails, or is |
| 116 // canceled. | 119 // canceled. |
| 117 LoadPageCallback callback_; | 120 LoadPageCallback callback_; |
| 118 | 121 |
| 122 // True if the lowbar of snapshotting a page is met. |
| 123 bool is_lowbar_met_; |
| 124 |
| 119 DISALLOW_COPY_AND_ASSIGN(PrerenderingLoader); | 125 DISALLOW_COPY_AND_ASSIGN(PrerenderingLoader); |
| 120 }; | 126 }; |
| 121 | 127 |
| 122 } // namespace offline_pages | 128 } // namespace offline_pages |
| 123 | 129 |
| 124 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_LOADER_H_ | 130 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_LOADER_H_ |
| OLD | NEW |