Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: chrome/browser/android/offline_pages/prerendering_loader.cc

Issue 2797013002: [Offline pages] Update background loader to override the WebContentsObserver methods expected (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/browser/android/offline_pages/prerendering_loader.h" 5 #include "chrome/browser/android/offline_pages/prerendering_loader.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 144 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
145 adapter_ = std::move(prerender_adapter); 145 adapter_ = std::move(prerender_adapter);
146 } 146 }
147 147
148 void PrerenderingLoader::OnPrerenderStopLoading() { 148 void PrerenderingLoader::OnPrerenderStopLoading() {
149 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 149 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
150 DCHECK(!IsIdle()); 150 DCHECK(!IsIdle());
151 DCHECK(adapter_->GetWebContents()); 151 DCHECK(adapter_->GetWebContents());
152 // Inform SnapshotController of OnLoad event so it can determine 152 // Inform SnapshotController of OnLoad event so it can determine
153 // when to consider it really LOADED. 153 // when to consider it really LOADED.
154 snapshot_controller_->DocumentOnLoadCompletedInMainFrame(); 154 snapshot_controller_->DidStopLoading();
155 } 155 }
156 156
157 void PrerenderingLoader::OnPrerenderDomContentLoaded() { 157 void PrerenderingLoader::OnPrerenderDomContentLoaded() {
158 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 158 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
159 DCHECK(!IsIdle()); 159 DCHECK(!IsIdle());
160 if (!adapter_->GetWebContents()) { 160 if (!adapter_->GetWebContents()) {
161 // Without a WebContents object at this point, we are done. 161 // Without a WebContents object at this point, we are done.
162 HandleLoadingStopped(); 162 HandleLoadingStopped();
163 } else { 163 } else {
164 is_lowbar_met_ = true; 164 is_lowbar_met_ = true;
165 if (kConsiderDclForSnapshot) { 165 if (kConsiderDclForSnapshot) {
166 // Inform SnapshotController of DomContentLoaded event so it can 166 // Inform SnapshotController of DomContentLoaded event so it can
167 // determine when to consider it really LOADED (e.g., some multiple 167 // determine when to consider it really LOADED (e.g., some multiple
168 // second delay from this event). 168 // second delay from this event).
169 snapshot_controller_->DocumentAvailableInMainFrame(); 169 snapshot_controller_->DocumentLoadedInMainFrame();
170 } 170 }
171 } 171 }
172 } 172 }
173 173
174 void PrerenderingLoader::OnPrerenderStop() { 174 void PrerenderingLoader::OnPrerenderStop() {
175 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 175 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
176 HandleLoadingStopped(); 176 HandleLoadingStopped();
177 } 177 }
178 178
179 void PrerenderingLoader::OnPrerenderNetworkBytesChanged(int64_t bytes) { 179 void PrerenderingLoader::OnPrerenderNetworkBytesChanged(int64_t bytes) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 if (adapter_->IsActive()) { 268 if (adapter_->IsActive()) {
269 adapter_->DestroyActive(); 269 adapter_->DestroyActive();
270 } 270 }
271 snapshot_controller_.reset(nullptr); 271 snapshot_controller_.reset(nullptr);
272 session_contents_.reset(nullptr); 272 session_contents_.reset(nullptr);
273 state_ = State::IDLE; 273 state_ = State::IDLE;
274 is_lowbar_met_ = false; 274 is_lowbar_met_ = false;
275 } 275 }
276 276
277 } // namespace offline_pages 277 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698