| 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/prerendering_offliner.h" | 5 #include "chrome/browser/android/offline_pages/prerendering_offliner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Clear pending request and app listener here and then inform loader we | 152 // Clear pending request and app listener here and then inform loader we |
| 153 // are done with WebContents. | 153 // are done with WebContents. |
| 154 pending_request_.reset(nullptr); | 154 pending_request_.reset(nullptr); |
| 155 app_listener_.reset(nullptr); | 155 app_listener_.reset(nullptr); |
| 156 GetOrCreateLoader()->StopLoading(); | 156 GetOrCreateLoader()->StopLoading(); |
| 157 | 157 |
| 158 // Determine status and run the completion callback. | 158 // Determine status and run the completion callback. |
| 159 Offliner::RequestStatus save_status; | 159 Offliner::RequestStatus save_status; |
| 160 if (save_result == SavePageResult::SUCCESS) { | 160 if (save_result == SavePageResult::ALREADY_EXISTS) { |
| 161 save_status = RequestStatus::SAVED; |
| 162 } else if (save_result == SavePageResult::SUCCESS) { |
| 161 if (saved_on_last_retry_) | 163 if (saved_on_last_retry_) |
| 162 save_status = RequestStatus::SAVED_ON_LAST_RETRY; | 164 save_status = RequestStatus::SAVED_ON_LAST_RETRY; |
| 163 else | 165 else |
| 164 save_status = RequestStatus::SAVED; | 166 save_status = RequestStatus::SAVED; |
| 165 } else { | 167 } else { |
| 166 // TODO(dougarnett): Consider reflecting some recommendation to retry the | 168 // TODO(dougarnett): Consider reflecting some recommendation to retry the |
| 167 // request based on specific save error cases. | 169 // request based on specific save error cases. |
| 168 save_status = RequestStatus::SAVE_FAILED; | 170 save_status = RequestStatus::SAVE_FAILED; |
| 169 } | 171 } |
| 170 saved_on_last_retry_ = false; | 172 saved_on_last_retry_ = false; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 void PrerenderingOffliner::HandleApplicationStateChangeCancel( | 331 void PrerenderingOffliner::HandleApplicationStateChangeCancel( |
| 330 const SavePageRequest& request, | 332 const SavePageRequest& request, |
| 331 int64_t offline_id) { | 333 int64_t offline_id) { |
| 332 // This shouldn't be immediate, but account for case where request was reset | 334 // This shouldn't be immediate, but account for case where request was reset |
| 333 // while waiting for callback. | 335 // while waiting for callback. |
| 334 if (pending_request_ && pending_request_->request_id() != offline_id) | 336 if (pending_request_ && pending_request_->request_id() != offline_id) |
| 335 return; | 337 return; |
| 336 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); | 338 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); |
| 337 } | 339 } |
| 338 } // namespace offline_pages | 340 } // namespace offline_pages |
| OLD | NEW |