| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 params.proposed_offline_id = request.request_id(); | 293 params.proposed_offline_id = request.request_id(); |
| 294 params.is_background = true; | 294 params.is_background = true; |
| 295 | 295 |
| 296 // Pass in the original URL if it's different from last committed | 296 // Pass in the original URL if it's different from last committed |
| 297 // when redirects occur. | 297 // when redirects occur. |
| 298 if (!request.original_url().is_empty()) | 298 if (!request.original_url().is_empty()) |
| 299 params.original_url = request.original_url(); | 299 params.original_url = request.original_url(); |
| 300 else if (params.url != request.url()) | 300 else if (params.url != request.url()) |
| 301 params.original_url = request.url(); | 301 params.original_url = request.url(); |
| 302 | 302 |
| 303 // TODO(petewil): Generate signal data. Blank for now. |
| 304 std::string signal_data; |
| 305 |
| 303 offline_page_model_->SavePage( | 306 offline_page_model_->SavePage( |
| 304 params, std::move(archiver), | 307 params, std::move(archiver), signal_data, |
| 305 base::Bind(&BackgroundLoaderOffliner::OnPageSaved, | 308 base::Bind(&BackgroundLoaderOffliner::OnPageSaved, |
| 306 weak_ptr_factory_.GetWeakPtr())); | 309 weak_ptr_factory_.GetWeakPtr())); |
| 307 } | 310 } |
| 308 | 311 |
| 309 void BackgroundLoaderOffliner::OnPageSaved(SavePageResult save_result, | 312 void BackgroundLoaderOffliner::OnPageSaved(SavePageResult save_result, |
| 310 int64_t offline_id) { | 313 int64_t offline_id) { |
| 311 if (!pending_request_) | 314 if (!pending_request_) |
| 312 return; | 315 return; |
| 313 | 316 |
| 314 SavePageRequest request(*pending_request_.get()); | 317 SavePageRequest request(*pending_request_.get()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 void BackgroundLoaderOffliner::HandleApplicationStateChangeCancel( | 365 void BackgroundLoaderOffliner::HandleApplicationStateChangeCancel( |
| 363 const SavePageRequest& request, | 366 const SavePageRequest& request, |
| 364 int64_t offline_id) { | 367 int64_t offline_id) { |
| 365 // If for some reason the request was reset during while waiting for callback | 368 // If for some reason the request was reset during while waiting for callback |
| 366 // ignore the completion callback. | 369 // ignore the completion callback. |
| 367 if (pending_request_ && pending_request_->request_id() != offline_id) | 370 if (pending_request_ && pending_request_->request_id() != offline_id) |
| 368 return; | 371 return; |
| 369 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); | 372 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); |
| 370 } | 373 } |
| 371 } // namespace offline_pages | 374 } // namespace offline_pages |
| OLD | NEW |