| 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_ = 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 DVLOG_IF(1, downloads_ongoing_snapshot_info_) | 504 DVLOG_IF(1, downloads_ongoing_snapshot_info_) |
| 505 << " - Canceling ongoing downloads snapshot"; | 505 << " - Canceling ongoing downloads snapshot"; |
| 506 weak_ptr_factory_.InvalidateWeakPtrs(); | 506 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 507 downloads_ongoing_snapshot_info_.reset(); | 507 downloads_ongoing_snapshot_info_.reset(); |
| 508 downloads_latest_saved_snapshot_info_.reset(); | 508 downloads_latest_saved_snapshot_info_.reset(); |
| 509 last_n_ongoing_snapshot_info_.reset(); | 509 last_n_ongoing_snapshot_info_.reset(); |
| 510 last_n_latest_saved_snapshot_info_.reset(); | 510 last_n_latest_saved_snapshot_info_.reset(); |
| 511 } | 511 } |
| 512 | 512 |
| 513 } // namespace offline_pages | 513 } // namespace offline_pages |
| OLD | NEW |