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/core/background/request_coordinator.h" | 5 #include "components/offline_pages/core/background/request_coordinator.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 190 } |
191 | 191 |
192 RequestCoordinator::RequestCoordinator( | 192 RequestCoordinator::RequestCoordinator( |
193 std::unique_ptr<OfflinerPolicy> policy, | 193 std::unique_ptr<OfflinerPolicy> policy, |
194 std::unique_ptr<Offliner> offliner, | 194 std::unique_ptr<Offliner> offliner, |
195 std::unique_ptr<RequestQueue> queue, | 195 std::unique_ptr<RequestQueue> queue, |
196 std::unique_ptr<Scheduler> scheduler, | 196 std::unique_ptr<Scheduler> scheduler, |
197 net::NetworkQualityEstimator::NetworkQualityProvider* | 197 net::NetworkQualityEstimator::NetworkQualityProvider* |
198 network_quality_estimator) | 198 network_quality_estimator) |
199 : is_low_end_device_(base::SysInfo::IsLowEndDevice()), | 199 : is_low_end_device_(base::SysInfo::IsLowEndDevice()), |
200 is_busy_(false), | 200 state_(RequestCoordinatorState::IDLE), |
201 is_starting_(false), | |
202 processing_state_(ProcessingWindowState::STOPPED), | 201 processing_state_(ProcessingWindowState::STOPPED), |
203 use_test_device_conditions_(false), | 202 use_test_device_conditions_(false), |
204 offliner_(std::move(offliner)), | 203 offliner_(std::move(offliner)), |
205 policy_(std::move(policy)), | 204 policy_(std::move(policy)), |
206 queue_(std::move(queue)), | 205 queue_(std::move(queue)), |
207 scheduler_(std::move(scheduler)), | 206 scheduler_(std::move(scheduler)), |
208 policy_controller_(new ClientPolicyController()), | 207 policy_controller_(new ClientPolicyController()), |
209 network_quality_estimator_(network_quality_estimator), | 208 network_quality_estimator_(network_quality_estimator), |
210 active_request_(nullptr), | 209 active_request_(nullptr), |
211 last_offlining_status_(Offliner::RequestStatus::UNKNOWN), | 210 last_offlining_status_(Offliner::RequestStatus::UNKNOWN), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 void RequestCoordinator::GetQueuedRequestsCallback( | 279 void RequestCoordinator::GetQueuedRequestsCallback( |
281 const GetRequestsCallback& callback, | 280 const GetRequestsCallback& callback, |
282 GetRequestsResult result, | 281 GetRequestsResult result, |
283 std::vector<std::unique_ptr<SavePageRequest>> requests) { | 282 std::vector<std::unique_ptr<SavePageRequest>> requests) { |
284 callback.Run(std::move(requests)); | 283 callback.Run(std::move(requests)); |
285 } | 284 } |
286 | 285 |
287 void RequestCoordinator::StopPrerendering( | 286 void RequestCoordinator::StopPrerendering( |
288 const Offliner::CancelCallback& final_callback, | 287 const Offliner::CancelCallback& final_callback, |
289 Offliner::RequestStatus stop_status) { | 288 Offliner::RequestStatus stop_status) { |
290 if (offliner_ && is_busy_) { | 289 if (offliner_ && state_ == RequestCoordinatorState::OFFLINING) { |
291 DCHECK(active_request_.get()); | 290 DCHECK(active_request_.get()); |
292 offliner_->Cancel(base::Bind( | 291 offliner_->Cancel(base::Bind( |
293 &RequestCoordinator::HandleCancelUpdateStatusCallback, | 292 &RequestCoordinator::HandleCancelUpdateStatusCallback, |
294 weak_ptr_factory_.GetWeakPtr(), final_callback, stop_status)); | 293 weak_ptr_factory_.GetWeakPtr(), final_callback, stop_status)); |
295 return; | 294 return; |
296 } | 295 } |
297 | 296 |
298 UpdateStatusForCancel(stop_status); | 297 UpdateStatusForCancel(stop_status); |
299 int64_t request_id = | 298 int64_t request_id = |
300 active_request_.get() ? active_request_->request_id() : 0LL; | 299 active_request_.get() ? active_request_->request_id() : 0LL; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 // Stopping offliner means it will not call callback so set last status. | 547 // Stopping offliner means it will not call callback so set last status. |
549 last_offlining_status_ = stop_status; | 548 last_offlining_status_ = stop_status; |
550 | 549 |
551 if (active_request_) { | 550 if (active_request_) { |
552 event_logger_.RecordOfflinerResult(active_request_->client_id().name_space, | 551 event_logger_.RecordOfflinerResult(active_request_->client_id().name_space, |
553 last_offlining_status_, | 552 last_offlining_status_, |
554 active_request_->request_id()); | 553 active_request_->request_id()); |
555 RecordOfflinerResultUMA(active_request_->client_id(), | 554 RecordOfflinerResultUMA(active_request_->client_id(), |
556 active_request_->creation_time(), | 555 active_request_->creation_time(), |
557 last_offlining_status_); | 556 last_offlining_status_); |
558 is_busy_ = false; | |
559 active_request_.reset(); | 557 active_request_.reset(); |
560 } | 558 } |
| 559 state_ = RequestCoordinatorState::IDLE; |
561 } | 560 } |
562 | 561 |
563 void RequestCoordinator::ResetActiveRequestCallback(int64_t offline_id) { | 562 void RequestCoordinator::ResetActiveRequestCallback(int64_t offline_id) { |
564 active_request_.reset(); | 563 active_request_.reset(); |
565 } | 564 } |
566 | 565 |
567 void RequestCoordinator::StartSchedulerCallback(int64_t offline_id) { | 566 void RequestCoordinator::StartSchedulerCallback(int64_t offline_id) { |
568 scheduler_callback_.Run(true); | 567 scheduler_callback_.Run(true); |
569 } | 568 } |
570 | 569 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 "OfflinePages.Background.ImmediateStartStatus", immediate_start_status, | 616 "OfflinePages.Background.ImmediateStartStatus", immediate_start_status, |
618 RequestCoordinator::OfflinerImmediateStartStatus::STATUS_COUNT); | 617 RequestCoordinator::OfflinerImmediateStartStatus::STATUS_COUNT); |
619 return immediate_start_status == OfflinerImmediateStartStatus::STARTED; | 618 return immediate_start_status == OfflinerImmediateStartStatus::STARTED; |
620 } | 619 } |
621 | 620 |
622 // The current_conditions_ must be set sometime before calling | 621 // The current_conditions_ must be set sometime before calling |
623 // StartProcessingInternal on all calling code paths. | 622 // StartProcessingInternal on all calling code paths. |
624 bool RequestCoordinator::StartProcessingInternal( | 623 bool RequestCoordinator::StartProcessingInternal( |
625 const ProcessingWindowState processing_state, | 624 const ProcessingWindowState processing_state, |
626 const base::Callback<void(bool)>& callback) { | 625 const base::Callback<void(bool)>& callback) { |
627 if (is_starting_ || is_busy_) | 626 if (state_ != RequestCoordinatorState::IDLE) |
628 return false; | 627 return false; |
629 processing_state_ = processing_state; | 628 processing_state_ = processing_state; |
630 scheduler_callback_ = callback; | 629 scheduler_callback_ = callback; |
631 | 630 |
632 // Mark the time at which we started processing so we can check our time | 631 // Mark the time at which we started processing so we can check our time |
633 // budget. | 632 // budget. |
634 operation_start_time_ = base::Time::Now(); | 633 operation_start_time_ = base::Time::Now(); |
635 | 634 |
636 TryNextRequest(kStartOfProcessing); | 635 TryNextRequest(kStartOfProcessing); |
637 | 636 |
638 return true; | 637 return true; |
639 } | 638 } |
640 | 639 |
641 void RequestCoordinator::StartImmediatelyIfConnected() { | 640 void RequestCoordinator::StartImmediatelyIfConnected() { |
642 StartImmediateProcessing(internal_start_processing_callback_); | 641 StartImmediateProcessing(internal_start_processing_callback_); |
643 } | 642 } |
644 | 643 |
645 RequestCoordinator::OfflinerImmediateStartStatus | 644 RequestCoordinator::OfflinerImmediateStartStatus |
646 RequestCoordinator::TryImmediateStart( | 645 RequestCoordinator::TryImmediateStart( |
647 const base::Callback<void(bool)>& callback) { | 646 const base::Callback<void(bool)>& callback) { |
648 DVLOG(2) << "Immediate " << __func__; | 647 DVLOG(2) << "Immediate " << __func__; |
649 // Make sure not already busy processing. | 648 // Make sure not already busy processing. |
650 if (is_busy_) | 649 if (state_ == RequestCoordinatorState::OFFLINING) |
651 return OfflinerImmediateStartStatus::BUSY; | 650 return OfflinerImmediateStartStatus::BUSY; |
652 | 651 |
653 // Make sure we are not on svelte device to start immediately. | 652 // Make sure we are not on svelte device to start immediately. |
654 if (is_low_end_device_ && | 653 if (is_low_end_device_ && |
655 !offline_pages::IsOfflinePagesSvelteConcurrentLoadingEnabled()) { | 654 !offline_pages::IsOfflinePagesSvelteConcurrentLoadingEnabled()) { |
656 DVLOG(2) << "low end device, returning"; | 655 DVLOG(2) << "low end device, returning"; |
657 // Let the scheduler know we are done processing and failed due to svelte. | 656 // Let the scheduler know we are done processing and failed due to svelte. |
658 callback.Run(false); | 657 callback.Run(false); |
659 return OfflinerImmediateStartStatus::NOT_STARTED_ON_SVELTE; | 658 return OfflinerImmediateStartStatus::NOT_STARTED_ON_SVELTE; |
660 } | 659 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 // If we have already set the connection type for testing, don't get it from | 694 // If we have already set the connection type for testing, don't get it from |
696 // android, but use what the test already set up. | 695 // android, but use what the test already set up. |
697 if (use_test_device_conditions_) | 696 if (use_test_device_conditions_) |
698 return; | 697 return; |
699 | 698 |
700 current_conditions_ = base::MakeUnique<DeviceConditions>( | 699 current_conditions_ = base::MakeUnique<DeviceConditions>( |
701 scheduler_->GetCurrentDeviceConditions()); | 700 scheduler_->GetCurrentDeviceConditions()); |
702 } | 701 } |
703 | 702 |
704 void RequestCoordinator::TryNextRequest(bool is_start_of_processing) { | 703 void RequestCoordinator::TryNextRequest(bool is_start_of_processing) { |
705 is_starting_ = true; | 704 state_ = RequestCoordinatorState::PICKING; |
706 | 705 |
707 // If this is the first call, the device conditions are current, no need to | 706 // If this is the first call, the device conditions are current, no need to |
708 // update them. | 707 // update them. |
709 // TODO(petewil): Now that we can get conditions any time, consider getting | 708 // TODO(petewil): Now that we can get conditions any time, consider getting |
710 // them now instead of passing them in earlier when we start scheduled | 709 // them now instead of passing them in earlier when we start scheduled |
711 // processing. | 710 // processing. |
712 if (!is_start_of_processing) { | 711 if (!is_start_of_processing) { |
713 // Get current device conditions from the Java side across the bridge. | 712 // Get current device conditions from the Java side across the bridge. |
714 // NetworkChangeNotifier will not have the right conditions if chromium is | 713 // NetworkChangeNotifier will not have the right conditions if chromium is |
715 // in the background in android, so prefer to always get the conditions via | 714 // in the background in android, so prefer to always get the conditions via |
(...skipping 14 matching lines...) Expand all Loading... |
730 net::NetworkChangeNotifier::ConnectionType connection_type = | 729 net::NetworkChangeNotifier::ConnectionType connection_type = |
731 current_conditions_->GetNetConnectionType(); | 730 current_conditions_->GetNetConnectionType(); |
732 | 731 |
733 // If there is no network or no time left in the budget, return to the | 732 // If there is no network or no time left in the budget, return to the |
734 // scheduler. We do not remove the pending scheduler task that was set | 733 // scheduler. We do not remove the pending scheduler task that was set |
735 // up earlier in case we run out of time, so the background scheduler | 734 // up earlier in case we run out of time, so the background scheduler |
736 // will return to us at the next opportunity to run background tasks. | 735 // will return to us at the next opportunity to run background tasks. |
737 if (connection_type == | 736 if (connection_type == |
738 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE || | 737 net::NetworkChangeNotifier::ConnectionType::CONNECTION_NONE || |
739 (base::Time::Now() - operation_start_time_) > processing_time_budget) { | 738 (base::Time::Now() - operation_start_time_) > processing_time_budget) { |
740 is_starting_ = false; | 739 state_ = RequestCoordinatorState::IDLE; |
741 | 740 |
742 // If we were doing immediate processing, try to start it again | 741 // If we were doing immediate processing, try to start it again |
743 // when we get connected. | 742 // when we get connected. |
744 if (processing_state_ == ProcessingWindowState::IMMEDIATE_WINDOW) | 743 if (processing_state_ == ProcessingWindowState::IMMEDIATE_WINDOW) |
745 RequestConnectedEventForStarting(); | 744 RequestConnectedEventForStarting(); |
746 | 745 |
747 // Let the scheduler know we are done processing. | 746 // Let the scheduler know we are done processing. |
748 // TODO: Make sure the scheduler callback is valid before running it. | 747 // TODO: Make sure the scheduler callback is valid before running it. |
749 scheduler_callback_.Run(true); | 748 scheduler_callback_.Run(true); |
750 DVLOG(2) << " out of time, giving up. " << __func__; | 749 DVLOG(2) << " out of time, giving up. " << __func__; |
(...skipping 15 matching lines...) Expand all Loading... |
766 // TODO(petewil): Verify current_conditions has a good value on all calling | 765 // TODO(petewil): Verify current_conditions has a good value on all calling |
767 // paths. It is really more of a "last known conditions" than "current | 766 // paths. It is really more of a "last known conditions" than "current |
768 // conditions". Consider having a call to Java to check the current | 767 // conditions". Consider having a call to Java to check the current |
769 // conditions. | 768 // conditions. |
770 } | 769 } |
771 | 770 |
772 // Called by the request picker when a request has been picked. | 771 // Called by the request picker when a request has been picked. |
773 void RequestCoordinator::RequestPicked(const SavePageRequest& request, | 772 void RequestCoordinator::RequestPicked(const SavePageRequest& request, |
774 bool cleanup_needed) { | 773 bool cleanup_needed) { |
775 DVLOG(2) << request.url() << " " << __func__; | 774 DVLOG(2) << request.url() << " " << __func__; |
776 is_starting_ = false; | |
777 | 775 |
778 // Make sure we were not stopped while picking. | 776 // Make sure we were not stopped while picking, since any kind of cancel/stop |
779 if (processing_state_ != ProcessingWindowState::STOPPED) { | 777 // will reset the state back to IDLE. |
| 778 if (state_ == RequestCoordinatorState::PICKING) { |
| 779 state_ = RequestCoordinatorState::OFFLINING; |
780 // Send the request on to the offliner. | 780 // Send the request on to the offliner. |
781 SendRequestToOffliner(request); | 781 SendRequestToOffliner(request); |
782 } | 782 } |
783 | 783 |
784 // Schedule a queue cleanup if needed. | 784 // Schedule a queue cleanup if needed. |
785 if (cleanup_needed) | 785 if (cleanup_needed) |
786 queue_->CleanupRequestQueue(); | 786 queue_->CleanupRequestQueue(); |
787 } | 787 } |
788 | 788 |
789 void RequestCoordinator::RequestNotPicked( | 789 void RequestCoordinator::RequestNotPicked( |
790 bool non_user_requested_tasks_remaining, | 790 bool non_user_requested_tasks_remaining, |
791 bool cleanup_needed) { | 791 bool cleanup_needed) { |
792 DVLOG(2) << __func__; | 792 DVLOG(2) << __func__; |
793 is_starting_ = false; | 793 state_ = RequestCoordinatorState::IDLE; |
794 | 794 |
795 // Clear the outstanding "safety" task in the scheduler. | 795 // Clear the outstanding "safety" task in the scheduler. |
796 scheduler_->Unschedule(); | 796 scheduler_->Unschedule(); |
797 | 797 |
798 // If disabled tasks remain, post a new safety task for 5 sec from now. | 798 // If disabled tasks remain, post a new safety task for 5 sec from now. |
799 if (disabled_requests_.size() > 0) { | 799 if (disabled_requests_.size() > 0) { |
800 scheduler_->BackupSchedule(GetTriggerConditions(kUserRequest), | 800 scheduler_->BackupSchedule(GetTriggerConditions(kUserRequest), |
801 kDisabledTaskRecheckSeconds); | 801 kDisabledTaskRecheckSeconds); |
802 } else if (non_user_requested_tasks_remaining) { | 802 } else if (non_user_requested_tasks_remaining) { |
803 // If we don't have any of those, check for non-user-requested tasks. | 803 // If we don't have any of those, check for non-user-requested tasks. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 "OfflinePages.Background.ImmediateStart.AvailableRequestCount", | 853 "OfflinePages.Background.ImmediateStart.AvailableRequestCount", |
854 available_requests); | 854 available_requests); |
855 UMA_HISTOGRAM_COUNTS_1000( | 855 UMA_HISTOGRAM_COUNTS_1000( |
856 "OfflinePages.Background.ImmediateStart.UnavailableRequestCount", | 856 "OfflinePages.Background.ImmediateStart.UnavailableRequestCount", |
857 total_requests - available_requests); | 857 total_requests - available_requests); |
858 } | 858 } |
859 } | 859 } |
860 } | 860 } |
861 | 861 |
862 void RequestCoordinator::SendRequestToOffliner(const SavePageRequest& request) { | 862 void RequestCoordinator::SendRequestToOffliner(const SavePageRequest& request) { |
863 // Check that offlining didn't get cancelled while performing some async | 863 DCHECK(state_ == RequestCoordinatorState::OFFLINING); |
864 // steps. | |
865 if (processing_state_ == ProcessingWindowState::STOPPED) | |
866 return; | |
867 | |
868 if (!offliner_) { | |
869 // TODO(chili,petewil): We should have UMA here to track frequency of this, | |
870 // if it happens at all. | |
871 DVLOG(0) << "Offliner crashed. Cannot background offline page."; | |
872 return; | |
873 } | |
874 | |
875 DCHECK(!is_busy_); | |
876 is_busy_ = true; | |
877 | |
878 // Record start time if this is first attempt. | 864 // Record start time if this is first attempt. |
879 if (request.started_attempt_count() == 0) { | 865 if (request.started_attempt_count() == 0) { |
880 RecordStartTimeUMA(request); | 866 RecordStartTimeUMA(request); |
881 } | 867 } |
882 | 868 |
883 // Mark attempt started in the database and start offliner when completed. | 869 // Mark attempt started in the database and start offliner when completed. |
884 queue_->MarkAttemptStarted( | 870 queue_->MarkAttemptStarted( |
885 request.request_id(), | 871 request.request_id(), |
886 base::Bind(&RequestCoordinator::StartOffliner, | 872 base::Bind(&RequestCoordinator::StartOffliner, |
887 weak_ptr_factory_.GetWeakPtr(), request.request_id(), | 873 weak_ptr_factory_.GetWeakPtr(), request.request_id(), |
888 request.client_id().name_space)); | 874 request.client_id().name_space)); |
889 } | 875 } |
890 | 876 |
891 void RequestCoordinator::StartOffliner( | 877 void RequestCoordinator::StartOffliner( |
892 int64_t request_id, | 878 int64_t request_id, |
893 const std::string& client_namespace, | 879 const std::string& client_namespace, |
894 std::unique_ptr<UpdateRequestsResult> update_result) { | 880 std::unique_ptr<UpdateRequestsResult> update_result) { |
895 if (update_result->store_state != StoreState::LOADED || | 881 if (update_result->store_state != StoreState::LOADED || |
896 update_result->item_statuses.size() != 1 || | 882 update_result->item_statuses.size() != 1 || |
897 update_result->item_statuses.at(0).first != request_id || | 883 update_result->item_statuses.at(0).first != request_id || |
898 update_result->item_statuses.at(0).second != ItemActionStatus::SUCCESS) { | 884 update_result->item_statuses.at(0).second != ItemActionStatus::SUCCESS) { |
899 is_busy_ = false; | 885 state_ = RequestCoordinatorState::IDLE; |
900 StopProcessing(Offliner::QUEUE_UPDATE_FAILED); | 886 StopProcessing(Offliner::QUEUE_UPDATE_FAILED); |
901 DVLOG(1) << "Failed to mark attempt started: " << request_id; | 887 DVLOG(1) << "Failed to mark attempt started: " << request_id; |
902 UpdateRequestResult request_result = | 888 UpdateRequestResult request_result = |
903 update_result->store_state != StoreState::LOADED | 889 update_result->store_state != StoreState::LOADED |
904 ? UpdateRequestResult::STORE_FAILURE | 890 ? UpdateRequestResult::STORE_FAILURE |
905 : UpdateRequestResult::REQUEST_DOES_NOT_EXIST; | 891 : UpdateRequestResult::REQUEST_DOES_NOT_EXIST; |
906 event_logger_.RecordUpdateRequestFailed(client_namespace, request_result); | 892 event_logger_.RecordUpdateRequestFailed(client_namespace, request_result); |
907 return; | 893 return; |
908 } | 894 } |
909 | 895 |
(...skipping 19 matching lines...) Expand all Loading... |
929 policy_->GetSinglePageTimeLimitForImmediateLoadInSeconds()); | 915 policy_->GetSinglePageTimeLimitForImmediateLoadInSeconds()); |
930 } | 916 } |
931 | 917 |
932 // Inform observer of active request. | 918 // Inform observer of active request. |
933 NotifyChanged(*active_request_.get()); | 919 NotifyChanged(*active_request_.get()); |
934 | 920 |
935 // Start a watchdog timer to catch pre-renders running too long | 921 // Start a watchdog timer to catch pre-renders running too long |
936 watchdog_timer_.Start(FROM_HERE, timeout, this, | 922 watchdog_timer_.Start(FROM_HERE, timeout, this, |
937 &RequestCoordinator::HandleWatchdogTimeout); | 923 &RequestCoordinator::HandleWatchdogTimeout); |
938 } else { | 924 } else { |
939 is_busy_ = false; | 925 state_ = RequestCoordinatorState::IDLE; |
940 DVLOG(0) << "Unable to start LoadAndSave"; | 926 DVLOG(0) << "Unable to start LoadAndSave"; |
941 StopProcessing(Offliner::LOADING_NOT_ACCEPTED); | 927 StopProcessing(Offliner::LOADING_NOT_ACCEPTED); |
942 | 928 |
943 // We need to undo the MarkAttemptStarted that brought us to this | 929 // We need to undo the MarkAttemptStarted that brought us to this |
944 // method since we didn't success in starting after all. | 930 // method since we didn't success in starting after all. |
945 MarkAttemptAborted(request_id, client_namespace); | 931 MarkAttemptAborted(request_id, client_namespace); |
946 } | 932 } |
947 } | 933 } |
948 | 934 |
949 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request, | 935 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request, |
950 Offliner::RequestStatus status) { | 936 Offliner::RequestStatus status) { |
951 DVLOG(2) << "offliner finished, saved: " | 937 DVLOG(2) << "offliner finished, saved: " |
952 << (status == Offliner::RequestStatus::SAVED) | 938 << (status == Offliner::RequestStatus::SAVED) |
953 << ", status: " << static_cast<int>(status) << ", " << __func__; | 939 << ", status: " << static_cast<int>(status) << ", " << __func__; |
954 DCHECK_NE(status, Offliner::RequestStatus::UNKNOWN); | 940 DCHECK_NE(status, Offliner::RequestStatus::UNKNOWN); |
955 DCHECK_NE(status, Offliner::RequestStatus::LOADED); | 941 DCHECK_NE(status, Offliner::RequestStatus::LOADED); |
956 event_logger_.RecordOfflinerResult(request.client_id().name_space, status, | 942 event_logger_.RecordOfflinerResult(request.client_id().name_space, status, |
957 request.request_id()); | 943 request.request_id()); |
958 last_offlining_status_ = status; | 944 last_offlining_status_ = status; |
959 RecordOfflinerResultUMA(request.client_id(), request.creation_time(), | 945 RecordOfflinerResultUMA(request.client_id(), request.creation_time(), |
960 last_offlining_status_); | 946 last_offlining_status_); |
961 watchdog_timer_.Stop(); | 947 watchdog_timer_.Stop(); |
962 is_busy_ = false; | 948 state_ = RequestCoordinatorState::IDLE; |
963 active_request_.reset(nullptr); | 949 active_request_.reset(nullptr); |
964 | 950 |
965 UpdateRequestForCompletedAttempt(request, status); | 951 UpdateRequestForCompletedAttempt(request, status); |
966 if (ShouldTryNextRequest(status)) | 952 if (ShouldTryNextRequest(status)) |
967 TryNextRequest(!kStartOfProcessing); | 953 TryNextRequest(!kStartOfProcessing); |
968 else | 954 else |
969 scheduler_callback_.Run(true); | 955 scheduler_callback_.Run(true); |
970 } | 956 } |
971 | 957 |
972 void RequestCoordinator::OfflinerProgressCallback( | 958 void RequestCoordinator::OfflinerProgressCallback( |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 | 1104 |
1119 ClientPolicyController* RequestCoordinator::GetPolicyController() { | 1105 ClientPolicyController* RequestCoordinator::GetPolicyController() { |
1120 return policy_controller_.get(); | 1106 return policy_controller_.get(); |
1121 } | 1107 } |
1122 | 1108 |
1123 void RequestCoordinator::Shutdown() { | 1109 void RequestCoordinator::Shutdown() { |
1124 network_quality_estimator_ = nullptr; | 1110 network_quality_estimator_ = nullptr; |
1125 } | 1111 } |
1126 | 1112 |
1127 } // namespace offline_pages | 1113 } // namespace offline_pages |
OLD | NEW |