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

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

Issue 2771933004: [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 16 matching lines...) Expand all
257 case net::ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED: 259 case net::ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED:
258 case net::ERR_SSL_SERVER_CERT_BAD_FORMAT: 260 case net::ERR_SSL_SERVER_CERT_BAD_FORMAT:
259 case net::ERR_UNKNOWN_URL_SCHEME: 261 case net::ERR_UNKNOWN_URL_SCHEME:
260 page_load_state_ = NONRETRIABLE; 262 page_load_state_ = NONRETRIABLE;
261 break; 263 break;
262 default: 264 default:
263 page_load_state_ = RETRIABLE; 265 page_load_state_ = RETRIABLE;
264 } 266 }
265 } 267 }
266 268
267 // If the page is not the same, invalidate any pending save tasks. 269 // If the document is not the same invalidate any pending save tasks.
268 // 270 //
269 // Downloads or 204/205 response codes do not commit (no new navigation) 271 // Downloads or 204/205 response codes do not commit (no new navigation)
270 // Same-Page (committed) navigations are: 272 // Same-Page (committed) navigations are:
271 // - reference fragment navigations 273 // - reference fragment navigations
272 // - pushState/replaceState 274 // - pushState/replaceState
273 // - same page history navigation 275 // - same page history navigation
274 if (navigation_handle->HasCommitted() && !navigation_handle->IsSamePage()) 276 if (navigation_handle->HasCommitted() && !navigation_handle->IsSamePage())
275 weak_ptr_factory_.InvalidateWeakPtrs(); 277 weak_ptr_factory_.InvalidateWeakPtrs();
276 } 278 }
277 279
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 int64_t offline_id) { 393 int64_t offline_id) {
392 // If for some reason the request was reset during while waiting for callback 394 // If for some reason the request was reset during while waiting for callback
393 // ignore the completion callback. 395 // ignore the completion callback.
394 if (pending_request_ && pending_request_->request_id() != offline_id) 396 if (pending_request_ && pending_request_->request_id() != offline_id)
395 return; 397 return;
396 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); 398 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED);
397 } 399 }
398 } // namespace offline_pages 400 } // namespace offline_pages
399 401
400 DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::OfflinerData); 402 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