Chromium Code Reviews| 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/prerendering_offliner.h" | 5 #include "chrome/browser/android/offline_pages/prerendering_offliner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 | 271 |
| 272 // Post the cancel callback right after this call concludes. | 272 // Post the cancel callback right after this call concludes. |
| 273 base::ThreadTaskRunnerHandle::Get()->PostTask( | 273 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 274 FROM_HERE, base::Bind(callback, *pending_request_.get())); | 274 FROM_HERE, base::Bind(callback, *pending_request_.get())); |
| 275 GetOrCreateLoader()->StopLoading(); | 275 GetOrCreateLoader()->StopLoading(); |
| 276 pending_request_.reset(nullptr); | 276 pending_request_.reset(nullptr); |
| 277 app_listener_.reset(nullptr); | 277 app_listener_.reset(nullptr); |
| 278 return true; | 278 return true; |
| 279 } | 279 } |
| 280 | 280 |
| 281 void PrerenderingOffliner::TerminateLoadIfInProgress() { | |
| 282 // This is not implemented since this offliner is deprecated and | |
|
dewittj
2017/05/24 23:24:40
Is this different behavior than we have today?
Dmitry Titov
2017/05/25 23:24:12
No, it directly uses Android class. I hope we will
| |
| 283 // will be removed shortly. | |
| 284 } | |
| 285 | |
| 281 bool PrerenderingOffliner::HandleTimeout(int64_t request_id) { | 286 bool PrerenderingOffliner::HandleTimeout(int64_t request_id) { |
| 282 if (pending_request_) { | 287 if (pending_request_) { |
| 283 DCHECK(request_id == pending_request_->request_id()); | 288 DCHECK(request_id == pending_request_->request_id()); |
| 284 if (GetOrCreateLoader()->IsLowbarMet() && | 289 if (GetOrCreateLoader()->IsLowbarMet() && |
| 285 (pending_request_->started_attempt_count() + 1 >= | 290 (pending_request_->started_attempt_count() + 1 >= |
| 286 policy_->GetMaxStartedTries() || | 291 policy_->GetMaxStartedTries() || |
| 287 pending_request_->completed_attempt_count() + 1 >= | 292 pending_request_->completed_attempt_count() + 1 >= |
| 288 policy_->GetMaxCompletedTries())) { | 293 policy_->GetMaxCompletedTries())) { |
| 289 saved_on_last_retry_ = true; | 294 saved_on_last_retry_ = true; |
| 290 GetOrCreateLoader()->StartSnapshot(); | 295 GetOrCreateLoader()->StartSnapshot(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { | 337 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { |
| 333 DVLOG(1) << "App became active, canceling current offlining request"; | 338 DVLOG(1) << "App became active, canceling current offlining request"; |
| 334 // No need to check the return value or complete early, as false would | 339 // No need to check the return value or complete early, as false would |
| 335 // indicate that there was no request, in which case the state change is | 340 // indicate that there was no request, in which case the state change is |
| 336 // ignored. | 341 // ignored. |
| 337 Cancel( | 342 Cancel( |
| 338 base::Bind(HandleApplicationStateChangeCancel, completion_callback_)); | 343 base::Bind(HandleApplicationStateChangeCancel, completion_callback_)); |
| 339 } | 344 } |
| 340 } | 345 } |
| 341 } // namespace offline_pages | 346 } // namespace offline_pages |
| OLD | NEW |