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> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/android/offline_pages/prerender_adapter.h" | 14 #include "chrome/browser/android/offline_pages/prerender_adapter.h" |
15 #include "components/offline_pages/core/background/offliner.h" | 15 #include "components/offline_pages/core/background/offliner.h" |
| 16 #include "components/offline_pages/core/background/resource_data_type.h" |
16 #include "components/offline_pages/core/snapshot_controller.h" | 17 #include "components/offline_pages/core/snapshot_controller.h" |
17 | 18 |
18 class GURL; | 19 class GURL; |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 class BrowserContext; | 22 class BrowserContext; |
22 class WebContents; | 23 class WebContents; |
23 } // namespace content | 24 } // namespace content |
24 | 25 |
25 namespace offline_pages { | 26 namespace offline_pages { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 void OnPrerenderDomContentLoaded() override; | 79 void OnPrerenderDomContentLoaded() override; |
79 void OnPrerenderStop() override; | 80 void OnPrerenderStop() override; |
80 void OnPrerenderNetworkBytesChanged(int64_t bytes) override; | 81 void OnPrerenderNetworkBytesChanged(int64_t bytes) override; |
81 | 82 |
82 // SnapshotController::Client implementation: | 83 // SnapshotController::Client implementation: |
83 void StartSnapshot() override; | 84 void StartSnapshot() override; |
84 | 85 |
85 // Returns true if the lowbar of snapshotting a page is met. | 86 // Returns true if the lowbar of snapshotting a page is met. |
86 virtual bool IsLowbarMet(); | 87 virtual bool IsLowbarMet(); |
87 | 88 |
| 89 void ObserveResourceTracking(const ResourceDataType type, |
| 90 int64_t started_count, |
| 91 int64_t completed_count); |
| 92 |
88 // Returns a JSON dictionary value for analysis of loading progress. | 93 // Returns a JSON dictionary value for analysis of loading progress. |
89 const base::DictionaryValue& GetLoadingSignalData() { return signal_data_; } | 94 const base::DictionaryValue& GetLoadingSignalData() { return signal_data_; } |
90 | 95 |
91 private: | 96 private: |
92 // State of the loader (only one request may be active at a time). | 97 // State of the loader (only one request may be active at a time). |
93 enum class State { | 98 enum class State { |
94 IDLE, // No active load request. | 99 IDLE, // No active load request. |
95 PENDING, // Load request is pending the start of prerendering. | 100 PENDING, // Load request is pending the start of prerendering. |
96 LOADING, // Loading in progress. | 101 LOADING, // Loading in progress. |
97 LOADED, // Loaded and now waiting for requestor to StopLoading(). | 102 LOADED, // Loaded and now waiting for requestor to StopLoading(). |
(...skipping 11 matching lines...) Expand all Loading... |
109 | 114 |
110 // Cancels any current prerender and moves loader to idle state. | 115 // Cancels any current prerender and moves loader to idle state. |
111 void CancelPrerender(); | 116 void CancelPrerender(); |
112 | 117 |
113 // Mark the time when we started loading the page. | 118 // Mark the time when we started loading the page. |
114 void MarkLoadStartTime(); | 119 void MarkLoadStartTime(); |
115 | 120 |
116 // Add a signal to the signal data. | 121 // Add a signal to the signal data. |
117 void AddLoadingSignal(const char* signal_name); | 122 void AddLoadingSignal(const char* signal_name); |
118 | 123 |
| 124 // Add resource percentage based signal to the signal data. |
| 125 void AddResourceSignal(const ResourceDataType type, |
| 126 int64_t started_count, |
| 127 int64_t completed_count); |
| 128 |
119 // Tracks loading state including whether the Loader is idle. | 129 // Tracks loading state including whether the Loader is idle. |
120 State state_; | 130 State state_; |
121 | 131 |
122 // Handles determining when to report page is LOADED. | 132 // Handles determining when to report page is LOADED. |
123 std::unique_ptr<SnapshotController> snapshot_controller_; | 133 std::unique_ptr<SnapshotController> snapshot_controller_; |
124 | 134 |
125 // Not owned. | 135 // Not owned. |
126 content::BrowserContext* browser_context_; | 136 content::BrowserContext* browser_context_; |
127 | 137 |
128 // Adapter for handling calls to the prerender stack. | 138 // Adapter for handling calls to the prerender stack. |
(...skipping 18 matching lines...) Expand all Loading... |
147 | 157 |
148 // Time in ticks of when we start loading the page. | 158 // Time in ticks of when we start loading the page. |
149 base::TimeTicks load_start_time_; | 159 base::TimeTicks load_start_time_; |
150 | 160 |
151 DISALLOW_COPY_AND_ASSIGN(PrerenderingLoader); | 161 DISALLOW_COPY_AND_ASSIGN(PrerenderingLoader); |
152 }; | 162 }; |
153 | 163 |
154 } // namespace offline_pages | 164 } // namespace offline_pages |
155 | 165 |
156 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_LOADER_H_ | 166 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_PRERENDERING_LOADER_H_ |
OLD | NEW |