| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 bool BackgroundLoaderOffliner::HandleTimeout(const SavePageRequest& request) { | 198 bool BackgroundLoaderOffliner::HandleTimeout(const SavePageRequest& request) { |
| 199 // TODO(romax) Decide if we want to also take a snapshot on the last timeout | 199 // TODO(romax) Decide if we want to also take a snapshot on the last timeout |
| 200 // for the background loader offliner. | 200 // for the background loader offliner. |
| 201 return false; | 201 return false; |
| 202 } | 202 } |
| 203 | 203 |
| 204 void BackgroundLoaderOffliner::DocumentLoadedInFrame( | 204 void BackgroundLoaderOffliner::DocumentLoadedInFrame( |
| 205 content::RenderFrameHost* render_host) { | 205 content::RenderFrameHost* render_host) { |
| 206 // Inform snapshot controller if in main frame. | 206 // Inform snapshot controller if in main frame. |
| 207 if (!render_host->GetParent()) | 207 if (!render_host->GetParent()) |
| 208 snapshot_controller_->DocumentAvailableInMainFrame(); | 208 snapshot_controller_->DocumentLoadedInMainFrame(); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void BackgroundLoaderOffliner::DidStopLoading() { | 211 void BackgroundLoaderOffliner::DidStopLoading() { |
| 212 if (!pending_request_.get()) { | 212 if (!pending_request_.get()) { |
| 213 DVLOG(1) << "DidStopLoading called even though no pending request."; | 213 DVLOG(1) << "DidStopLoading called even though no pending request."; |
| 214 return; | 214 return; |
| 215 } | 215 } |
| 216 | 216 |
| 217 snapshot_controller_->DocumentOnLoadCompletedInMainFrame(); | 217 snapshot_controller_->DidStopLoading(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void BackgroundLoaderOffliner::RenderProcessGone( | 220 void BackgroundLoaderOffliner::RenderProcessGone( |
| 221 base::TerminationStatus status) { | 221 base::TerminationStatus status) { |
| 222 if (pending_request_) { | 222 if (pending_request_) { |
| 223 SavePageRequest request(*pending_request_.get()); | 223 SavePageRequest request(*pending_request_.get()); |
| 224 switch (status) { | 224 switch (status) { |
| 225 case base::TERMINATION_STATUS_OOM: | 225 case base::TERMINATION_STATUS_OOM: |
| 226 case base::TERMINATION_STATUS_PROCESS_CRASHED: | 226 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
| 227 case base::TERMINATION_STATUS_STILL_RUNNING: | 227 case base::TERMINATION_STATUS_STILL_RUNNING: |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 int64_t offline_id) { | 419 int64_t offline_id) { |
| 420 // If for some reason the request was reset during while waiting for callback | 420 // If for some reason the request was reset during while waiting for callback |
| 421 // ignore the completion callback. | 421 // ignore the completion callback. |
| 422 if (pending_request_ && pending_request_->request_id() != offline_id) | 422 if (pending_request_ && pending_request_->request_id() != offline_id) |
| 423 return; | 423 return; |
| 424 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); | 424 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); |
| 425 } | 425 } |
| 426 } // namespace offline_pages | 426 } // namespace offline_pages |
| 427 | 427 |
| 428 DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::OfflinerData); | 428 DEFINE_WEB_CONTENTS_USER_DATA_KEY(offline_pages::OfflinerData); |
| OLD | NEW |