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 #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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 page_load_state_ = NONRETRIABLE; | 222 page_load_state_ = NONRETRIABLE; |
223 break; | 223 break; |
224 case net::ERR_INTERNET_DISCONNECTED: | 224 case net::ERR_INTERNET_DISCONNECTED: |
225 page_load_state_ = DELAY_RETRY; | 225 page_load_state_ = DELAY_RETRY; |
226 break; | 226 break; |
227 default: | 227 default: |
228 page_load_state_ = RETRIABLE; | 228 page_load_state_ = RETRIABLE; |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 // If the page is not the same, invalidate any pending save tasks. | 232 // If the document is not the same, invalidate any pending save tasks. |
233 // | 233 // |
234 // Downloads or 204/205 response codes do not commit (no new navigation) | 234 // Downloads or 204/205 response codes do not commit (no new navigation) |
235 // Same-Page (committed) navigations are: | 235 // Same-Document (committed) navigations are: |
236 // - reference fragment navigations | 236 // - reference fragment navigations |
237 // - pushState/replaceState | 237 // - pushState/replaceState |
238 // - same page history navigation | 238 // - same document history navigation |
239 if (navigation_handle->HasCommitted() && !navigation_handle->IsSamePage()) | 239 if (navigation_handle->HasCommitted() && |
| 240 !navigation_handle->IsSameDocument()) { |
240 weak_ptr_factory_.InvalidateWeakPtrs(); | 241 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 242 } |
241 } | 243 } |
242 | 244 |
243 void BackgroundLoaderOffliner::SetPageDelayForTest(long delay_ms) { | 245 void BackgroundLoaderOffliner::SetPageDelayForTest(long delay_ms) { |
244 page_delay_ms_ = delay_ms; | 246 page_delay_ms_ = delay_ms; |
245 } | 247 } |
246 | 248 |
247 void BackgroundLoaderOffliner::SavePage() { | 249 void BackgroundLoaderOffliner::SavePage() { |
248 if (!pending_request_.get()) { | 250 if (!pending_request_.get()) { |
249 DVLOG(1) << "Pending request was cleared during delay."; | 251 DVLOG(1) << "Pending request was cleared during delay."; |
250 return; | 252 return; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 void BackgroundLoaderOffliner::HandleApplicationStateChangeCancel( | 358 void BackgroundLoaderOffliner::HandleApplicationStateChangeCancel( |
357 const SavePageRequest& request, | 359 const SavePageRequest& request, |
358 int64_t offline_id) { | 360 int64_t offline_id) { |
359 // If for some reason the request was reset during while waiting for callback | 361 // If for some reason the request was reset during while waiting for callback |
360 // ignore the completion callback. | 362 // ignore the completion callback. |
361 if (pending_request_ && pending_request_->request_id() != offline_id) | 363 if (pending_request_ && pending_request_->request_id() != offline_id) |
362 return; | 364 return; |
363 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); | 365 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); |
364 } | 366 } |
365 } // namespace offline_pages | 367 } // namespace offline_pages |
OLD | NEW |