| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // If previous pages can't be deleted, don't add new ones. | 177 // If previous pages can't be deleted, don't add new ones. |
| 178 ReportSnapshotCompleted(); | 178 ReportSnapshotCompleted(); |
| 179 return; | 179 return; |
| 180 } | 180 } |
| 181 | 181 |
| 182 if (!IsSamePage()) { | 182 if (!IsSamePage()) { |
| 183 ReportSnapshotCompleted(); | 183 ReportSnapshotCompleted(); |
| 184 return; | 184 return; |
| 185 } | 185 } |
| 186 | 186 |
| 187 page_model_->SavePage(snapshot_url_, client_id(), 0ul, | 187 page_model_->SavePage(snapshot_url_, client_id(), 0l, |
| 188 delegate_->CreatePageArchiver(web_contents()), | 188 delegate_->CreatePageArchiver(web_contents()), |
| 189 base::Bind(&RecentTabHelper::SavePageCallback, | 189 base::Bind(&RecentTabHelper::SavePageCallback, |
| 190 weak_ptr_factory_.GetWeakPtr())); | 190 weak_ptr_factory_.GetWeakPtr())); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void RecentTabHelper::SavePageCallback(OfflinePageModel::SavePageResult result, | 193 void RecentTabHelper::SavePageCallback(OfflinePageModel::SavePageResult result, |
| 194 int64_t offline_id) { | 194 int64_t offline_id) { |
| 195 ReportSnapshotCompleted(); | 195 ReportSnapshotCompleted(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void RecentTabHelper::ReportSnapshotCompleted() { | 198 void RecentTabHelper::ReportSnapshotCompleted() { |
| 199 snapshot_controller_->PendingSnapshotCompleted(); | 199 snapshot_controller_->PendingSnapshotCompleted(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool RecentTabHelper::IsSamePage() const { | 202 bool RecentTabHelper::IsSamePage() const { |
| 203 return web_contents() && | 203 return web_contents() && |
| 204 (web_contents()->GetLastCommittedURL() == snapshot_url_); | 204 (web_contents()->GetLastCommittedURL() == snapshot_url_); |
| 205 } | 205 } |
| 206 | 206 |
| 207 ClientId RecentTabHelper::client_id() const { | 207 ClientId RecentTabHelper::client_id() const { |
| 208 return ClientId(kLastNNamespace, tab_id_); | 208 return ClientId(kLastNNamespace, tab_id_); |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace offline_pages | 211 } // namespace offline_pages |
| OLD | NEW |