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 #include <string> |
| 10 #include <vector> |
9 | 11 |
10 #include "base/callback.h" | 12 #include "base/callback.h" |
11 #include "chrome/browser/android/offline_pages/prerender_adapter.h" | 13 #include "chrome/browser/android/offline_pages/prerender_adapter.h" |
12 #include "components/offline_pages/core/background/offliner.h" | 14 #include "components/offline_pages/core/background/offliner.h" |
13 #include "components/offline_pages/core/snapshot_controller.h" | 15 #include "components/offline_pages/core/snapshot_controller.h" |
14 | 16 |
15 class GURL; | 17 class GURL; |
16 | 18 |
17 namespace content { | 19 namespace content { |
18 class BrowserContext; | 20 class BrowserContext; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 void HandleLoadEvent(); | 99 void HandleLoadEvent(); |
98 | 100 |
99 // Handles some event/signal that loading has stopped (whether due to a | 101 // Handles some event/signal that loading has stopped (whether due to a |
100 // failure, cancel, or stop request). It may be due to some asynchronous | 102 // failure, cancel, or stop request). It may be due to some asynchronous |
101 // trigger that occurs after the request has stopped for some other reason. | 103 // trigger that occurs after the request has stopped for some other reason. |
102 void HandleLoadingStopped(); | 104 void HandleLoadingStopped(); |
103 | 105 |
104 // Cancels any current prerender and moves loader to idle state. | 106 // Cancels any current prerender and moves loader to idle state. |
105 void CancelPrerender(); | 107 void CancelPrerender(); |
106 | 108 |
| 109 // Returns a vector of strings for analysis of loading progress. |
| 110 const std::vector<std::string>& GetLoadingSignalData() { |
| 111 return signal_data_; |
| 112 } |
| 113 |
107 // Tracks loading state including whether the Loader is idle. | 114 // Tracks loading state including whether the Loader is idle. |
108 State state_; | 115 State state_; |
109 | 116 |
110 // Handles determining when to report page is LOADED. | 117 // Handles determining when to report page is LOADED. |
111 std::unique_ptr<SnapshotController> snapshot_controller_; | 118 std::unique_ptr<SnapshotController> snapshot_controller_; |
112 | 119 |
113 // Not owned. | 120 // Not owned. |
114 content::BrowserContext* browser_context_; | 121 content::BrowserContext* browser_context_; |
115 | 122 |
116 // Adapter for handling calls to the prerender stack. | 123 // Adapter for handling calls to the prerender stack. |
117 std::unique_ptr<PrerenderAdapter> adapter_; | 124 std::unique_ptr<PrerenderAdapter> adapter_; |
118 | 125 |
119 // A WebContents for the active load request that is used to hold the session | 126 // A WebContents for the active load request that is used to hold the session |
120 // storage namespace for rendering. This will NOT have the loaded page. | 127 // storage namespace for rendering. This will NOT have the loaded page. |
121 std::unique_ptr<content::WebContents> session_contents_; | 128 std::unique_ptr<content::WebContents> session_contents_; |
122 | 129 |
| 130 // Signal data collected for this rendering attempt |
| 131 std::vector<std::string> signal_data_; |
| 132 |
123 // Callback to call when the active load request completes, fails, or is | 133 // Callback to call when the active load request completes, fails, or is |
124 // canceled. | 134 // canceled. |
125 LoadPageCallback load_done_callback_; | 135 LoadPageCallback load_done_callback_; |
126 | 136 |
127 // Callback to call when we know more bytes have loaded from the network. | 137 // Callback to call when we know more bytes have loaded from the network. |
128 ProgressCallback progress_callback_; | 138 ProgressCallback progress_callback_; |
129 | 139 |
130 // True if the lowbar of snapshotting a page is met. | 140 // True if the lowbar of snapshotting a page is met. |
131 bool is_lowbar_met_; | 141 bool is_lowbar_met_; |
132 | 142 |
133 DISALLOW_COPY_AND_ASSIGN(PrerenderingLoader); | 143 DISALLOW_COPY_AND_ASSIGN(PrerenderingLoader); |
134 }; | 144 }; |
135 | 145 |
136 } // namespace offline_pages | 146 } // namespace offline_pages |
137 | 147 |
138 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_LOADER_H_ | 148 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_LOADER_H_ |
OLD | NEW |