Chromium Code Reviews| 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/sys_info.h" | 7 #include "base/sys_info.h" |
| 8 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 8 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
| 9 #include "components/offline_pages/core/background/save_page_request.h" | 9 #include "components/offline_pages/core/background/save_page_request.h" |
| 10 #include "components/offline_pages/core/offline_page_model.h" | 10 #include "components/offline_pages/core/offline_page_model.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 OfflinePageModel::SavePageParams params; | 90 OfflinePageModel::SavePageParams params; |
| 91 params.url = web_contents->GetLastCommittedURL(); | 91 params.url = web_contents->GetLastCommittedURL(); |
| 92 params.client_id = request.client_id(); | 92 params.client_id = request.client_id(); |
| 93 params.proposed_offline_id = request.request_id(); | 93 params.proposed_offline_id = request.request_id(); |
| 94 offline_page_model_->SavePage( | 94 offline_page_model_->SavePage( |
| 95 params, std::move(archiver), | 95 params, std::move(archiver), |
| 96 base::Bind(&BackgroundLoaderOffliner::OnPageSaved, | 96 base::Bind(&BackgroundLoaderOffliner::OnPageSaved, |
| 97 weak_ptr_factory_.GetWeakPtr())); | 97 weak_ptr_factory_.GetWeakPtr())); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void BackgroundLoaderOffliner::RenderProcessGone( | |
|
Pete Williamson
2016/12/21 20:49:28
What would cause a call to RenderProcessGone? I d
| |
| 101 base::TerminationStatus status) { | |
| 102 SavePageRequest request(*pending_request_.get()); | |
| 103 switch (status) { | |
| 104 case TERMINATION_STATUS_OOM: | |
| 105 case TERMINATION_STATUS_PROCESS_CRASHED: | |
| 106 case TERMINATION_STATUS_STILL_RUNNING: | |
| 107 completion_callback_.Run(request, | |
| 108 Offliner::RequestStatus::LOADING_FAILED_NO_NEXT); | |
| 109 break; | |
| 110 case TERMINATION_STATUS_PROCESS_WAS_KILLED: | |
|
dougarnett
2016/12/22 01:37:53
Can you share any insight on this case? Cleanly ki
| |
| 111 default: | |
| 112 completion_callback_.Run(request, | |
| 113 Offliner::RequestStatus::LOADING_FAILED); | |
| 114 } | |
| 115 ResetState(); | |
| 116 } | |
| 117 | |
| 118 void BackgroundLoaderOffliner::WebContentsDestroyed() { | |
| 119 completion_callback_.Run(*pending_request_.get(), | |
| 120 Offliner::RequestStatus::LOADING_FAILED); | |
| 121 ResetState(); | |
| 122 } | |
| 123 | |
| 100 void BackgroundLoaderOffliner::OnPageSaved(SavePageResult save_result, | 124 void BackgroundLoaderOffliner::OnPageSaved(SavePageResult save_result, |
| 101 int64_t offline_id) { | 125 int64_t offline_id) { |
| 102 if (!pending_request_) | 126 if (!pending_request_) |
| 103 return; | 127 return; |
| 104 | 128 |
| 105 SavePageRequest request(*pending_request_.get()); | 129 SavePageRequest request(*pending_request_.get()); |
| 106 ResetState(); | 130 ResetState(); |
| 107 | 131 |
| 108 if (save_state_ == DELETE_AFTER_SAVE) { | 132 if (save_state_ == DELETE_AFTER_SAVE) { |
| 109 save_state_ = NONE; | 133 save_state_ = NONE; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 139 application_state == | 163 application_state == |
| 140 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { | 164 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { |
| 141 DVLOG(1) << "App became active, canceling current offlining request"; | 165 DVLOG(1) << "App became active, canceling current offlining request"; |
| 142 SavePageRequest* request = pending_request_.get(); | 166 SavePageRequest* request = pending_request_.get(); |
| 143 Cancel(); | 167 Cancel(); |
| 144 completion_callback_.Run(*request, RequestStatus::FOREGROUND_CANCELED); | 168 completion_callback_.Run(*request, RequestStatus::FOREGROUND_CANCELED); |
| 145 } | 169 } |
| 146 } | 170 } |
| 147 | 171 |
| 148 } // namespace offline_pages | 172 } // namespace offline_pages |
| OLD | NEW |