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

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

Issue 2764373004: [Offline pages] Check errors and invalidate pointers only for mainframe for navigation (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/background_loader_offliner.h" 5 #include "chrome/browser/android/offline_pages/background_loader_offliner.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/sys_info.h" 8 #include "base/sys_info.h"
9 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 9 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
10 #include "chrome/browser/android/offline_pages/offliner_helper.h" 10 #include "chrome/browser/android/offline_pages/offliner_helper.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 void BackgroundLoaderOffliner::WebContentsDestroyed() { 221 void BackgroundLoaderOffliner::WebContentsDestroyed() {
222 if (pending_request_) { 222 if (pending_request_) {
223 SavePageRequest request(*pending_request_.get()); 223 SavePageRequest request(*pending_request_.get());
224 completion_callback_.Run(request, Offliner::RequestStatus::LOADING_FAILED); 224 completion_callback_.Run(request, Offliner::RequestStatus::LOADING_FAILED);
225 ResetState(); 225 ResetState();
226 } 226 }
227 } 227 }
228 228
229 void BackgroundLoaderOffliner::DidFinishNavigation( 229 void BackgroundLoaderOffliner::DidFinishNavigation(
230 content::NavigationHandle* navigation_handle) { 230 content::NavigationHandle* navigation_handle) {
231 if (!navigation_handle->IsInMainFrame())
232 return;
231 // If there was an error of any kind (certificate, client, DNS, etc), 233 // If there was an error of any kind (certificate, client, DNS, etc),
232 // Mark as error page. Resetting here causes RecordNavigationMetrics to crash. 234 // Mark as error page. Resetting here causes RecordNavigationMetrics to crash.
233 if (navigation_handle->IsErrorPage()) { 235 if (navigation_handle->IsErrorPage()) {
234 // TODO(chili): we need to UMA this. 236 // TODO(chili): we need to UMA this.
235 switch (navigation_handle->GetNetErrorCode()) { 237 switch (navigation_handle->GetNetErrorCode()) {
236 case net::ERR_ACCESS_DENIED: 238 case net::ERR_ACCESS_DENIED:
237 case net::ERR_ADDRESS_INVALID: 239 case net::ERR_ADDRESS_INVALID:
238 case net::ERR_ADDRESS_UNREACHABLE: 240 case net::ERR_ADDRESS_UNREACHABLE:
239 case net::ERR_CERT_COMMON_NAME_INVALID: 241 case net::ERR_CERT_COMMON_NAME_INVALID:
240 case net::ERR_CERT_AUTHORITY_INVALID: 242 case net::ERR_CERT_AUTHORITY_INVALID:
(...skipping 19 matching lines...) Expand all
260 page_load_state_ = NONRETRIABLE; 262 page_load_state_ = NONRETRIABLE;
261 break; 263 break;
262 case net::ERR_INTERNET_DISCONNECTED: 264 case net::ERR_INTERNET_DISCONNECTED:
263 page_load_state_ = DELAY_RETRY; 265 page_load_state_ = DELAY_RETRY;
264 break; 266 break;
265 default: 267 default:
266 page_load_state_ = RETRIABLE; 268 page_load_state_ = RETRIABLE;
267 } 269 }
268 } 270 }
269 271
270 // If the document is not the same, invalidate any pending save tasks. 272 // If the document is not the same invalidate any pending save tasks.
271 // 273 //
272 // Downloads or 204/205 response codes do not commit (no new navigation) 274 // Downloads or 204/205 response codes do not commit (no new navigation)
273 // Same-Document (committed) navigations are: 275 // Same-Document (committed) navigations are:
274 // - reference fragment navigations 276 // - reference fragment navigations
275 // - pushState/replaceState 277 // - pushState/replaceState
276 // - same document history navigation 278 // - same document history navigation
277 if (navigation_handle->HasCommitted() && 279 if (navigation_handle->HasCommitted() &&
fgorski 2017/03/23 16:18:00 Is there a chance at this point that we have alrea
chili 2017/03/23 17:31:06 yes, but it should not matter. Before, we also ha
278 !navigation_handle->IsSameDocument()) { 280 !navigation_handle->IsSameDocument()) {
279 weak_ptr_factory_.InvalidateWeakPtrs(); 281 weak_ptr_factory_.InvalidateWeakPtrs();
280 } 282 }
281 } 283 }
282 284
283 void BackgroundLoaderOffliner::SetPageDelayForTest(long delay_ms) { 285 void BackgroundLoaderOffliner::SetPageDelayForTest(long delay_ms) {
284 page_delay_ms_ = delay_ms; 286 page_delay_ms_ = delay_ms;
285 } 287 }
286 288
287 void BackgroundLoaderOffliner::OnNetworkBytesChanged(int64_t bytes) { 289 void BackgroundLoaderOffliner::OnNetworkBytesChanged(int64_t bytes) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 int64_t offline_id) { 410 int64_t offline_id) {
409 // If for some reason the request was reset during while waiting for callback 411 // If for some reason the request was reset during while waiting for callback
410 // ignore the completion callback. 412 // ignore the completion callback.
411 if (pending_request_ && pending_request_->request_id() != offline_id) 413 if (pending_request_ && pending_request_->request_id() != offline_id)
412 return; 414 return;
413 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); 415 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED);
414 } 416 }
415 } // namespace offline_pages 417 } // namespace offline_pages
416 418
417 DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::OfflinerData); 419 DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::OfflinerData);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698