Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Side by Side Diff: components/offline_pages/background/request_picker.h

Issue 2395213002: Implement disabled list (Closed)
Patch Set: set pointer -> const ref Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set>
9 10
10 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
11 #include "components/offline_pages/background/device_conditions.h" 12 #include "components/offline_pages/background/device_conditions.h"
12 #include "components/offline_pages/background/offliner_policy.h" 13 #include "components/offline_pages/background/offliner_policy.h"
13 #include "components/offline_pages/background/request_coordinator.h" 14 #include "components/offline_pages/background/request_coordinator.h"
14 #include "components/offline_pages/background/request_coordinator_event_logger.h " 15 #include "components/offline_pages/background/request_coordinator_event_logger.h "
15 #include "components/offline_pages/background/request_queue.h" 16 #include "components/offline_pages/background/request_queue.h"
16 17
17 namespace offline_pages { 18 namespace offline_pages {
18 19
19 class RequestNotifier; 20 class RequestNotifier;
20 21
21 typedef bool (RequestPicker::*RequestCompareFunction)( 22 typedef bool (RequestPicker::*RequestCompareFunction)(
22 const SavePageRequest* left, const SavePageRequest* right); 23 const SavePageRequest* left, const SavePageRequest* right);
23 24
24 class RequestPicker { 25 class RequestPicker {
25 public: 26 public:
26 RequestPicker(RequestQueue* requestQueue, 27 RequestPicker(RequestQueue* requestQueue,
27 OfflinerPolicy* policy, 28 OfflinerPolicy* policy,
28 RequestNotifier* notifier, 29 RequestNotifier* notifier,
29 RequestCoordinatorEventLogger* event_logger); 30 RequestCoordinatorEventLogger* event_logger);
30 31
31 ~RequestPicker(); 32 ~RequestPicker();
32 33
33 // Choose which request we should process next based on the current 34 // Choose which request we should process next based on the current
34 // conditions, and call back to the RequestCoordinator when we have one. 35 // conditions, and call back to the RequestCoordinator when we have one.
35 void ChooseNextRequest( 36 void ChooseNextRequest(
36 RequestCoordinator::RequestPickedCallback picked_callback, 37 RequestCoordinator::RequestPickedCallback picked_callback,
37 RequestCoordinator::RequestNotPickedCallback not_picked_callback, 38 RequestCoordinator::RequestNotPickedCallback not_picked_callback,
38 DeviceConditions* device_conditions); 39 DeviceConditions* device_conditions,
40 const std::set<int64_t>& disabled_requests);
39 41
40 private: 42 private:
41 // Callback for the GetRequest results to be delivered. 43 // Callback for the GetRequest results to be delivered.
42 void GetRequestResultCallback( 44 void GetRequestResultCallback(
45 const std::set<int64_t>& disabled_requests,
43 RequestQueue::GetRequestsResult result, 46 RequestQueue::GetRequestsResult result,
44 std::vector<std::unique_ptr<SavePageRequest>> results); 47 std::vector<std::unique_ptr<SavePageRequest>> results);
45 48
46 // Filter out requests that don't meet the current conditions. For instance, 49 // Filter out requests that don't meet the current conditions. For instance,
47 // if this is a predictive request, and we are not on WiFi, it should be 50 // if this is a predictive request, and we are not on WiFi, it should be
48 // ignored this round. 51 // ignored this round.
49 bool RequestConditionsSatisfied(const SavePageRequest* request); 52 bool RequestConditionsSatisfied(const SavePageRequest* request);
50 53
51 // Using policies, decide if the new request is preferable to the best we have 54 // Using policies, decide if the new request is preferable to the best we have
52 // so far. 55 // so far.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 RequestCoordinator::RequestPickedCallback picked_callback_; 101 RequestCoordinator::RequestPickedCallback picked_callback_;
99 // Callback for when there are no more reqeusts to pick. 102 // Callback for when there are no more reqeusts to pick.
100 RequestCoordinator::RequestNotPickedCallback not_picked_callback_; 103 RequestCoordinator::RequestNotPickedCallback not_picked_callback_;
101 // Allows us to pass a weak pointer to callbacks. 104 // Allows us to pass a weak pointer to callbacks.
102 base::WeakPtrFactory<RequestPicker> weak_ptr_factory_; 105 base::WeakPtrFactory<RequestPicker> weak_ptr_factory_;
103 }; 106 };
104 107
105 } // namespace offline_pages 108 } // namespace offline_pages
106 109
107 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ 110 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_
OLDNEW
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | components/offline_pages/background/request_picker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698