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/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" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "components/offline_pages/background/offliner_factory.h" | 17 #include "components/offline_pages/core/background/offliner_factory.h" |
18 #include "components/offline_pages/background/offliner_policy.h" | 18 #include "components/offline_pages/core/background/offliner_policy.h" |
19 #include "components/offline_pages/background/save_page_request.h" | 19 #include "components/offline_pages/core/background/save_page_request.h" |
20 #include "components/offline_pages/client_policy_controller.h" | 20 #include "components/offline_pages/core/client_policy_controller.h" |
21 #include "components/offline_pages/offline_page_feature.h" | 21 #include "components/offline_pages/core/offline_page_feature.h" |
22 #include "components/offline_pages/offline_page_item.h" | 22 #include "components/offline_pages/core/offline_page_item.h" |
23 #include "components/offline_pages/offline_page_model.h" | 23 #include "components/offline_pages/core/offline_page_model.h" |
24 | 24 |
25 namespace offline_pages { | 25 namespace offline_pages { |
26 | 26 |
27 namespace { | 27 namespace { |
28 const bool kUserRequest = true; | 28 const bool kUserRequest = true; |
29 const bool kStartOfProcessing = true; | 29 const bool kStartOfProcessing = true; |
30 const int kMinDurationSeconds = 1; | 30 const int kMinDurationSeconds = 1; |
31 const int kMaxDurationSeconds = 7 * 24 * 60 * 60; // 7 days | 31 const int kMaxDurationSeconds = 7 * 24 * 60 * 60; // 7 days |
32 const int kDurationBuckets = 50; | 32 const int kDurationBuckets = 50; |
33 const int kDisabledTaskRecheckSeconds = 5; | 33 const int kDisabledTaskRecheckSeconds = 5; |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 NotifyCompleted(request, status); | 485 NotifyCompleted(request, status); |
486 } | 486 } |
487 | 487 |
488 void RequestCoordinator::ScheduleAsNeeded() { | 488 void RequestCoordinator::ScheduleAsNeeded() { |
489 // Get all requests from queue (there is no filtering mechanism). | 489 // Get all requests from queue (there is no filtering mechanism). |
490 queue_->GetRequests( | 490 queue_->GetRequests( |
491 base::Bind(&RequestCoordinator::GetRequestsForSchedulingCallback, | 491 base::Bind(&RequestCoordinator::GetRequestsForSchedulingCallback, |
492 weak_ptr_factory_.GetWeakPtr())); | 492 weak_ptr_factory_.GetWeakPtr())); |
493 } | 493 } |
494 | 494 |
495 void RequestCoordinator::StopProcessing( | 495 void RequestCoordinator::StopProcessing(Offliner::RequestStatus stop_status) { |
496 Offliner::RequestStatus stop_status) { | |
497 processing_state_ = ProcessingWindowState::STOPPED; | 496 processing_state_ = ProcessingWindowState::STOPPED; |
498 StopPrerendering(stop_status); | 497 StopPrerendering(stop_status); |
499 | 498 |
500 // Let the scheduler know we are done processing. | 499 // Let the scheduler know we are done processing. |
501 scheduler_callback_.Run(true); | 500 scheduler_callback_.Run(true); |
502 } | 501 } |
503 | 502 |
504 void RequestCoordinator::HandleWatchdogTimeout() { | 503 void RequestCoordinator::HandleWatchdogTimeout() { |
505 Offliner::RequestStatus watchdog_status = | 504 Offliner::RequestStatus watchdog_status = |
506 Offliner::REQUEST_COORDINATOR_TIMED_OUT; | 505 Offliner::REQUEST_COORDINATOR_TIMED_OUT; |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 994 |
996 ClientPolicyController* RequestCoordinator::GetPolicyController() { | 995 ClientPolicyController* RequestCoordinator::GetPolicyController() { |
997 return policy_controller_.get(); | 996 return policy_controller_.get(); |
998 } | 997 } |
999 | 998 |
1000 void RequestCoordinator::Shutdown() { | 999 void RequestCoordinator::Shutdown() { |
1001 network_quality_estimator_ = nullptr; | 1000 network_quality_estimator_ = nullptr; |
1002 } | 1001 } |
1003 | 1002 |
1004 } // namespace offline_pages | 1003 } // namespace offline_pages |
OLD | NEW |