| 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 "components/offline_pages/background/request_coordinator.h" | 5 #include "components/offline_pages/background/request_coordinator.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "components/offline_pages/background/offliner_factory.h" | 16 #include "components/offline_pages/background/offliner_factory.h" |
| 17 #include "components/offline_pages/background/offliner_policy.h" | 17 #include "components/offline_pages/background/offliner_policy.h" |
| 18 #include "components/offline_pages/background/request_picker.h" | 18 #include "components/offline_pages/background/request_picker.h" |
| 19 #include "components/offline_pages/background/save_page_request.h" | 19 #include "components/offline_pages/background/save_page_request.h" |
| 20 #include "components/offline_pages/client_policy_controller.h" |
| 20 #include "components/offline_pages/offline_page_item.h" | 21 #include "components/offline_pages/offline_page_item.h" |
| 21 #include "components/offline_pages/offline_page_model.h" | 22 #include "components/offline_pages/offline_page_model.h" |
| 22 | 23 |
| 23 namespace offline_pages { | 24 namespace offline_pages { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 const bool kUserRequest = true; | 27 const bool kUserRequest = true; |
| 27 | 28 |
| 28 // Records the final request status UMA for an offlining request. This should | 29 // Records the final request status UMA for an offlining request. This should |
| 29 // only be called once per Offliner::LoadAndSave request. | 30 // only be called once per Offliner::LoadAndSave request. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 : is_busy_(false), | 86 : is_busy_(false), |
| 86 is_starting_(false), | 87 is_starting_(false), |
| 87 is_stopped_(false), | 88 is_stopped_(false), |
| 88 use_test_connection_type_(false), | 89 use_test_connection_type_(false), |
| 89 test_connection_type_(), | 90 test_connection_type_(), |
| 90 offliner_(nullptr), | 91 offliner_(nullptr), |
| 91 policy_(std::move(policy)), | 92 policy_(std::move(policy)), |
| 92 factory_(std::move(factory)), | 93 factory_(std::move(factory)), |
| 93 queue_(std::move(queue)), | 94 queue_(std::move(queue)), |
| 94 scheduler_(std::move(scheduler)), | 95 scheduler_(std::move(scheduler)), |
| 96 policy_controller_(new ClientPolicyController()), |
| 95 network_quality_estimator_(network_quality_estimator), | 97 network_quality_estimator_(network_quality_estimator), |
| 96 active_request_(nullptr), | 98 active_request_(nullptr), |
| 97 last_offlining_status_(Offliner::RequestStatus::UNKNOWN), | 99 last_offlining_status_(Offliner::RequestStatus::UNKNOWN), |
| 98 offliner_timeout_(base::TimeDelta::FromSeconds( | 100 offliner_timeout_(base::TimeDelta::FromSeconds( |
| 99 policy_->GetSinglePageTimeLimitInSeconds())), | 101 policy_->GetSinglePageTimeLimitInSeconds())), |
| 100 weak_ptr_factory_(this) { | 102 weak_ptr_factory_(this) { |
| 101 DCHECK(policy_ != nullptr); | 103 DCHECK(policy_ != nullptr); |
| 102 picker_.reset( | 104 picker_.reset( |
| 103 new RequestPicker(queue_.get(), policy_.get(), this, &event_logger_)); | 105 new RequestPicker(queue_.get(), policy_.get(), this, &event_logger_)); |
| 104 } | 106 } |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 void RequestCoordinator::NotifyChanged(const SavePageRequest& request) { | 594 void RequestCoordinator::NotifyChanged(const SavePageRequest& request) { |
| 593 FOR_EACH_OBSERVER(Observer, observers_, OnChanged(request)); | 595 FOR_EACH_OBSERVER(Observer, observers_, OnChanged(request)); |
| 594 } | 596 } |
| 595 | 597 |
| 596 void RequestCoordinator::GetOffliner() { | 598 void RequestCoordinator::GetOffliner() { |
| 597 if (!offliner_) { | 599 if (!offliner_) { |
| 598 offliner_ = factory_->GetOffliner(policy_.get()); | 600 offliner_ = factory_->GetOffliner(policy_.get()); |
| 599 } | 601 } |
| 600 } | 602 } |
| 601 | 603 |
| 604 ClientPolicyController* RequestCoordinator::GetPolicyController() { |
| 605 return policy_controller_.get(); |
| 606 } |
| 607 |
| 602 void RequestCoordinator::Shutdown() { | 608 void RequestCoordinator::Shutdown() { |
| 603 network_quality_estimator_ = nullptr; | 609 network_quality_estimator_ = nullptr; |
| 604 } | 610 } |
| 605 | 611 |
| 606 } // namespace offline_pages | 612 } // namespace offline_pages |
| OLD | NEW |