| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 content::WebContents* web_contents( | 132 content::WebContents* web_contents( |
| 133 content::WebContentsObserver::web_contents()); | 133 content::WebContentsObserver::web_contents()); |
| 134 | 134 |
| 135 std::unique_ptr<OfflinePageArchiver> archiver( | 135 std::unique_ptr<OfflinePageArchiver> archiver( |
| 136 new OfflinePageMHTMLArchiver(web_contents)); | 136 new OfflinePageMHTMLArchiver(web_contents)); |
| 137 | 137 |
| 138 OfflinePageModel::SavePageParams params; | 138 OfflinePageModel::SavePageParams params; |
| 139 params.url = web_contents->GetLastCommittedURL(); | 139 params.url = web_contents->GetLastCommittedURL(); |
| 140 params.client_id = request.client_id(); | 140 params.client_id = request.client_id(); |
| 141 params.proposed_offline_id = request.request_id(); | 141 params.proposed_offline_id = request.request_id(); |
| 142 params.is_background = true; |
| 142 offline_page_model_->SavePage( | 143 offline_page_model_->SavePage( |
| 143 params, std::move(archiver), | 144 params, std::move(archiver), |
| 144 base::Bind(&BackgroundLoaderOffliner::OnPageSaved, | 145 base::Bind(&BackgroundLoaderOffliner::OnPageSaved, |
| 145 weak_ptr_factory_.GetWeakPtr())); | 146 weak_ptr_factory_.GetWeakPtr())); |
| 146 } | 147 } |
| 147 | 148 |
| 148 void BackgroundLoaderOffliner::RenderProcessGone( | 149 void BackgroundLoaderOffliner::RenderProcessGone( |
| 149 base::TerminationStatus status) { | 150 base::TerminationStatus status) { |
| 150 if (pending_request_) { | 151 if (pending_request_) { |
| 151 SavePageRequest request(*pending_request_.get()); | 152 SavePageRequest request(*pending_request_.get()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 application_state == | 217 application_state == |
| 217 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { | 218 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { |
| 218 DVLOG(1) << "App became active, canceling current offlining request"; | 219 DVLOG(1) << "App became active, canceling current offlining request"; |
| 219 SavePageRequest* request = pending_request_.get(); | 220 SavePageRequest* request = pending_request_.get(); |
| 220 Cancel(); | 221 Cancel(); |
| 221 completion_callback_.Run(*request, RequestStatus::FOREGROUND_CANCELED); | 222 completion_callback_.Run(*request, RequestStatus::FOREGROUND_CANCELED); |
| 222 } | 223 } |
| 223 } | 224 } |
| 224 | 225 |
| 225 } // namespace offline_pages | 226 } // namespace offline_pages |
| OLD | NEW |