| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 SaveSnapshotForDownloads(false); | 156 SaveSnapshotForDownloads(false); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Initialize lazily. It needs TabAndroid for initialization, which is also a | 159 // Initialize lazily. It needs TabAndroid for initialization, which is also a |
| 160 // TabHelper - so can't initialize in constructor because of uncertain order | 160 // TabHelper - so can't initialize in constructor because of uncertain order |
| 161 // of creation of TabHelpers. | 161 // of creation of TabHelpers. |
| 162 bool RecentTabHelper::EnsureInitialized() { | 162 bool RecentTabHelper::EnsureInitialized() { |
| 163 if (snapshot_controller_) // Initialized already. | 163 if (snapshot_controller_) // Initialized already. |
| 164 return snapshots_enabled_; | 164 return snapshots_enabled_; |
| 165 | 165 |
| 166 snapshot_controller_.reset( | 166 snapshot_controller_.reset(SnapshotController::CreateForForegroundOfflining( |
| 167 new SnapshotController(base::ThreadTaskRunnerHandle::Get(), this)); | 167 base::ThreadTaskRunnerHandle::Get(), this)); |
| 168 snapshot_controller_->Stop(); // It is reset when navigation commits. | 168 snapshot_controller_->Stop(); // It is reset when navigation commits. |
| 169 | 169 |
| 170 int tab_id_number = 0; | 170 int tab_id_number = 0; |
| 171 tab_id_.clear(); | 171 tab_id_.clear(); |
| 172 | 172 |
| 173 if (delegate_->GetTabId(web_contents(), &tab_id_number)) | 173 if (delegate_->GetTabId(web_contents(), &tab_id_number)) |
| 174 tab_id_ = base::IntToString(tab_id_number); | 174 tab_id_ = base::IntToString(tab_id_number); |
| 175 | 175 |
| 176 // TODO(dimich): When we have BackgroundOffliner, avoid capturing prerenderer | 176 // TODO(dimich): When we have BackgroundOffliner, avoid capturing prerenderer |
| 177 // WebContents with its origin as well. | 177 // WebContents with its origin as well. |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 } | 481 } |
| 482 | 482 |
| 483 void RecentTabHelper::CancelInFlightSnapshots() { | 483 void RecentTabHelper::CancelInFlightSnapshots() { |
| 484 weak_ptr_factory_.InvalidateWeakPtrs(); | 484 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 485 downloads_ongoing_snapshot_info_.reset(); | 485 downloads_ongoing_snapshot_info_.reset(); |
| 486 downloads_latest_saved_snapshot_info_.reset(); | 486 downloads_latest_saved_snapshot_info_.reset(); |
| 487 last_n_ongoing_snapshot_info_.reset(); | 487 last_n_ongoing_snapshot_info_.reset(); |
| 488 } | 488 } |
| 489 | 489 |
| 490 } // namespace offline_pages | 490 } // namespace offline_pages |
| OLD | NEW |