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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 pending_request_->completed_attempt_count() + 1 >= | 287 pending_request_->completed_attempt_count() + 1 >= |
288 policy_->GetMaxCompletedTries())) { | 288 policy_->GetMaxCompletedTries())) { |
289 saved_on_last_retry_ = true; | 289 saved_on_last_retry_ = true; |
290 GetOrCreateLoader()->StartSnapshot(); | 290 GetOrCreateLoader()->StartSnapshot(); |
291 return true; | 291 return true; |
292 } | 292 } |
293 } | 293 } |
294 return false; | 294 return false; |
295 } | 295 } |
296 | 296 |
| 297 void PrerenderingOffliner::ObserveResourceTracking(const ResourceDataType type, |
| 298 int64_t started_count, |
| 299 int64_t completed_count) { |
| 300 // Add the signal to extra data, and use for tracking. |
| 301 loader_->ObserveResourceTracking(type, started_count, completed_count); |
| 302 } |
| 303 |
297 void PrerenderingOffliner::SetLoaderForTesting( | 304 void PrerenderingOffliner::SetLoaderForTesting( |
298 std::unique_ptr<PrerenderingLoader> loader) { | 305 std::unique_ptr<PrerenderingLoader> loader) { |
299 DCHECK(!loader_); | 306 DCHECK(!loader_); |
300 loader_ = std::move(loader); | 307 loader_ = std::move(loader); |
301 } | 308 } |
302 | 309 |
303 void PrerenderingOffliner::SetLowEndDeviceForTesting(bool is_low_end_device) { | 310 void PrerenderingOffliner::SetLowEndDeviceForTesting(bool is_low_end_device) { |
304 is_low_end_device_ = is_low_end_device; | 311 is_low_end_device_ = is_low_end_device; |
305 } | 312 } |
306 | 313 |
(...skipping 25 matching lines...) Expand all Loading... |
332 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { | 339 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) { |
333 DVLOG(1) << "App became active, canceling current offlining request"; | 340 DVLOG(1) << "App became active, canceling current offlining request"; |
334 // No need to check the return value or complete early, as false would | 341 // 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 | 342 // indicate that there was no request, in which case the state change is |
336 // ignored. | 343 // ignored. |
337 Cancel( | 344 Cancel( |
338 base::Bind(HandleApplicationStateChangeCancel, completion_callback_)); | 345 base::Bind(HandleApplicationStateChangeCancel, completion_callback_)); |
339 } | 346 } |
340 } | 347 } |
341 } // namespace offline_pages | 348 } // namespace offline_pages |
OLD | NEW |