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

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

Issue 2178143002: Check time budget before starting new requests, and unittest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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_COORDINATOR_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 friend class RequestCoordinatorTest; 131 friend class RequestCoordinatorTest;
132 132
133 // The offliner can only handle one request at a time - if the offliner is 133 // The offliner can only handle one request at a time - if the offliner is
134 // busy, prevent other requests. This flag marks whether the offliner is in 134 // busy, prevent other requests. This flag marks whether the offliner is in
135 // use. 135 // use.
136 bool is_busy_; 136 bool is_busy_;
137 // True if the current request has been canceled. 137 // True if the current request has been canceled.
138 bool is_canceled_; 138 bool is_canceled_;
139 // How long to wait for an offliner request before giving up.
140 base::TimeDelta offliner_timeout_;
141 // Unowned pointer to the current offliner, if any. 139 // Unowned pointer to the current offliner, if any.
142 Offliner* offliner_; 140 Offliner* offliner_;
141 base::Time operation_start_time_;
143 // Last known conditions for network, battery 142 // Last known conditions for network, battery
144 std::unique_ptr<DeviceConditions> current_conditions_; 143 std::unique_ptr<DeviceConditions> current_conditions_;
145 // RequestCoordinator takes over ownership of the policy 144 // RequestCoordinator takes over ownership of the policy
146 std::unique_ptr<OfflinerPolicy> policy_; 145 std::unique_ptr<OfflinerPolicy> policy_;
147 // OfflinerFactory. Used to create offline pages. Owned. 146 // OfflinerFactory. Used to create offline pages. Owned.
148 std::unique_ptr<OfflinerFactory> factory_; 147 std::unique_ptr<OfflinerFactory> factory_;
149 // RequestQueue. Used to store incoming requests. Owned. 148 // RequestQueue. Used to store incoming requests. Owned.
150 std::unique_ptr<RequestQueue> queue_; 149 std::unique_ptr<RequestQueue> queue_;
151 // Scheduler. Used to request a callback when network is available. Owned. 150 // Scheduler. Used to request a callback when network is available. Owned.
152 std::unique_ptr<Scheduler> scheduler_; 151 std::unique_ptr<Scheduler> scheduler_;
153 // Status of the most recent offlining. 152 // Status of the most recent offlining.
154 Offliner::RequestStatus last_offlining_status_; 153 Offliner::RequestStatus last_offlining_status_;
155 // Class to choose which request to schedule next 154 // Class to choose which request to schedule next
156 std::unique_ptr<RequestPicker> picker_; 155 std::unique_ptr<RequestPicker> picker_;
157 // Calling this returns to the scheduler across the JNI bridge. 156 // Calling this returns to the scheduler across the JNI bridge.
158 base::Callback<void(bool)> scheduler_callback_; 157 base::Callback<void(bool)> scheduler_callback_;
159 // Logger to record events. 158 // Logger to record events.
160 RequestCoordinatorEventLogger event_logger_; 159 RequestCoordinatorEventLogger event_logger_;
161 // Timer to watch for pre-render attempts running too long. 160 // Timer to watch for pre-render attempts running too long.
162 base::OneShotTimer watchdog_timer_; 161 base::OneShotTimer watchdog_timer_;
162 // How long to wait for an offliner request before giving up.
163 base::TimeDelta offliner_timeout_;
163 // Allows us to pass a weak pointer to callbacks. 164 // Allows us to pass a weak pointer to callbacks.
164 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 165 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
165 166
166 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 167 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
167 }; 168 };
168 169
169 } // namespace offline_pages 170 } // namespace offline_pages
170 171
171 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 172 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698