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

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: Tweak time limit names 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 129
130 friend class RequestCoordinatorTest; 130 friend class RequestCoordinatorTest;
131 131
132 // The offliner can only handle one request at a time - if the offliner is 132 // The offliner can only handle one request at a time - if the offliner is
133 // busy, prevent other requests. This flag marks whether the offliner is in 133 // busy, prevent other requests. This flag marks whether the offliner is in
134 // use. 134 // use.
135 bool is_busy_; 135 bool is_busy_;
136 // True if the current request has been canceled. 136 // True if the current request has been canceled.
137 bool is_canceled_; 137 bool is_canceled_;
138 // How long to wait for an offliner request before giving up.
139 base::TimeDelta offliner_timeout_;
140 // Unowned pointer to the current offliner, if any. 138 // Unowned pointer to the current offliner, if any.
141 Offliner* offliner_; 139 Offliner* offliner_;
140 base::Time operation_start_time_;
142 // Last known conditions for network, battery 141 // Last known conditions for network, battery
143 std::unique_ptr<DeviceConditions> current_conditions_; 142 std::unique_ptr<DeviceConditions> current_conditions_;
144 // RequestCoordinator takes over ownership of the policy 143 // RequestCoordinator takes over ownership of the policy
145 std::unique_ptr<OfflinerPolicy> policy_; 144 std::unique_ptr<OfflinerPolicy> policy_;
146 // OfflinerFactory. Used to create offline pages. Owned. 145 // OfflinerFactory. Used to create offline pages. Owned.
147 std::unique_ptr<OfflinerFactory> factory_; 146 std::unique_ptr<OfflinerFactory> factory_;
148 // RequestQueue. Used to store incoming requests. Owned. 147 // RequestQueue. Used to store incoming requests. Owned.
149 std::unique_ptr<RequestQueue> queue_; 148 std::unique_ptr<RequestQueue> queue_;
150 // Scheduler. Used to request a callback when network is available. Owned. 149 // Scheduler. Used to request a callback when network is available. Owned.
151 std::unique_ptr<Scheduler> scheduler_; 150 std::unique_ptr<Scheduler> scheduler_;
152 // Status of the most recent offlining. 151 // Status of the most recent offlining.
153 Offliner::RequestStatus last_offlining_status_; 152 Offliner::RequestStatus last_offlining_status_;
154 // Class to choose which request to schedule next 153 // Class to choose which request to schedule next
155 std::unique_ptr<RequestPicker> picker_; 154 std::unique_ptr<RequestPicker> picker_;
156 // Calling this returns to the scheduler across the JNI bridge. 155 // Calling this returns to the scheduler across the JNI bridge.
157 base::Callback<void(bool)> scheduler_callback_; 156 base::Callback<void(bool)> scheduler_callback_;
158 // Logger to record events. 157 // Logger to record events.
159 RequestCoordinatorEventLogger event_logger_; 158 RequestCoordinatorEventLogger event_logger_;
160 // Timer to watch for pre-render attempts running too long. 159 // Timer to watch for pre-render attempts running too long.
161 base::OneShotTimer watchdog_timer_; 160 base::OneShotTimer watchdog_timer_;
161 // How long to wait for an offliner request before giving up.
162 base::TimeDelta offliner_timeout_;
162 // Allows us to pass a weak pointer to callbacks. 163 // Allows us to pass a weak pointer to callbacks.
163 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 164 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
164 165
165 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 166 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
166 }; 167 };
167 168
168 } // namespace offline_pages 169 } // namespace offline_pages
169 170
170 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 171 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW
« no previous file with comments | « components/offline_pages/background/offliner_policy.h ('k') | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698