| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/recent_tab_helper.h" | 5 #include "chrome/browser/android/offline_pages/recent_tab_helper.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 DCHECK(OfflinePageModel::CanSaveURL(web_contents()->GetLastCommittedURL())); | 396 DCHECK(OfflinePageModel::CanSaveURL(web_contents()->GetLastCommittedURL())); |
| 397 snapshot_info->expected_page_quality = | 397 snapshot_info->expected_page_quality = |
| 398 snapshot_controller_->current_page_quality(); | 398 snapshot_controller_->current_page_quality(); |
| 399 OfflinePageModel::SavePageParams save_page_params; | 399 OfflinePageModel::SavePageParams save_page_params; |
| 400 save_page_params.url = web_contents()->GetLastCommittedURL(); | 400 save_page_params.url = web_contents()->GetLastCommittedURL(); |
| 401 save_page_params.client_id = snapshot_info->client_id; | 401 save_page_params.client_id = snapshot_info->client_id; |
| 402 save_page_params.proposed_offline_id = snapshot_info->request_id; | 402 save_page_params.proposed_offline_id = snapshot_info->request_id; |
| 403 save_page_params.is_background = false; | 403 save_page_params.is_background = false; |
| 404 save_page_params.original_url = | 404 save_page_params.original_url = |
| 405 OfflinePageUtils::GetOriginalURLFromWebContents(web_contents()); | 405 OfflinePageUtils::GetOriginalURLFromWebContents(web_contents()); |
| 406 std::string signal_data; |
| 406 page_model_->SavePage( | 407 page_model_->SavePage( |
| 407 save_page_params, delegate_->CreatePageArchiver(web_contents()), | 408 save_page_params, delegate_->CreatePageArchiver(web_contents()), |
| 409 signal_data, |
| 408 base::Bind(&RecentTabHelper::SavePageCallback, | 410 base::Bind(&RecentTabHelper::SavePageCallback, |
| 409 weak_ptr_factory_.GetWeakPtr(), snapshot_info)); | 411 weak_ptr_factory_.GetWeakPtr(), snapshot_info)); |
| 410 } | 412 } |
| 411 | 413 |
| 412 void RecentTabHelper::SavePageCallback(SnapshotProgressInfo* snapshot_info, | 414 void RecentTabHelper::SavePageCallback(SnapshotProgressInfo* snapshot_info, |
| 413 OfflinePageModel::SavePageResult result, | 415 OfflinePageModel::SavePageResult result, |
| 414 int64_t offline_id) { | 416 int64_t offline_id) { |
| 415 DCHECK(snapshot_info->IsForLastN() || | 417 DCHECK(snapshot_info->IsForLastN() || |
| 416 snapshot_info->request_id == offline_id); | 418 snapshot_info->request_id == offline_id); |
| 417 ReportSnapshotCompleted(snapshot_info, result == SavePageResult::SUCCESS); | 419 ReportSnapshotCompleted(snapshot_info, result == SavePageResult::SUCCESS); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 } | 476 } |
| 475 | 477 |
| 476 void RecentTabHelper::CancelInFlightSnapshots() { | 478 void RecentTabHelper::CancelInFlightSnapshots() { |
| 477 weak_ptr_factory_.InvalidateWeakPtrs(); | 479 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 478 downloads_ongoing_snapshot_info_.reset(); | 480 downloads_ongoing_snapshot_info_.reset(); |
| 479 downloads_latest_saved_snapshot_info_.reset(); | 481 downloads_latest_saved_snapshot_info_.reset(); |
| 480 last_n_ongoing_snapshot_info_.reset(); | 482 last_n_ongoing_snapshot_info_.reset(); |
| 481 } | 483 } |
| 482 | 484 |
| 483 } // namespace offline_pages | 485 } // namespace offline_pages |
| OLD | NEW |