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

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

Issue 2119613002: Adds a prerenderer watchdog timer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Constant renaming per DewittJ Created 4 years, 5 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
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h"
14 #include "base/timer/timer.h"
13 #include "components/keyed_service/core/keyed_service.h" 15 #include "components/keyed_service/core/keyed_service.h"
14 #include "components/offline_pages/background/device_conditions.h" 16 #include "components/offline_pages/background/device_conditions.h"
15 #include "components/offline_pages/background/offliner.h" 17 #include "components/offline_pages/background/offliner.h"
16 #include "components/offline_pages/background/request_coordinator_event_logger.h " 18 #include "components/offline_pages/background/request_coordinator_event_logger.h "
17 #include "components/offline_pages/background/request_queue.h" 19 #include "components/offline_pages/background/request_queue.h"
18 #include "components/offline_pages/background/scheduler.h" 20 #include "components/offline_pages/background/scheduler.h"
19 #include "url/gurl.h" 21 #include "url/gurl.h"
20 22
21 namespace offline_pages { 23 namespace offline_pages {
22 24
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // tests). 112 // tests).
111 void OfflinerDoneCallback(const SavePageRequest& request, 113 void OfflinerDoneCallback(const SavePageRequest& request,
112 Offliner::RequestStatus status); 114 Offliner::RequestStatus status);
113 115
114 void TryNextRequest(); 116 void TryNextRequest();
115 117
116 // Returns the appropriate offliner to use, getting a new one from the factory 118 // Returns the appropriate offliner to use, getting a new one from the factory
117 // if needed. 119 // if needed.
118 void GetOffliner(); 120 void GetOffliner();
119 121
122 void SetOfflinerTimeoutForTest(const base::TimeDelta& timeout) {
123 offliner_timeout_ = timeout;
124 }
125
120 friend class RequestCoordinatorTest; 126 friend class RequestCoordinatorTest;
121 127
122 // The offliner can only handle one request at a time - if the offliner is 128 // The offliner can only handle one request at a time - if the offliner is
123 // busy, prevent other requests. This flag marks whether the offliner is in 129 // busy, prevent other requests. This flag marks whether the offliner is in
124 // use. 130 // use.
125 bool is_busy_; 131 bool is_busy_;
126 // True if the current request has been canceled. 132 // True if the current request has been canceled.
127 bool is_canceled_; 133 bool is_canceled_;
134 // How long to wait for an offliner request before giving up.
135 base::TimeDelta offliner_timeout_;
128 // Unowned pointer to the current offliner, if any. 136 // Unowned pointer to the current offliner, if any.
129 Offliner* offliner_; 137 Offliner* offliner_;
130 // RequestCoordinator takes over ownership of the policy 138 // RequestCoordinator takes over ownership of the policy
131 std::unique_ptr<OfflinerPolicy> policy_; 139 std::unique_ptr<OfflinerPolicy> policy_;
132 // OfflinerFactory. Used to create offline pages. Owned. 140 // OfflinerFactory. Used to create offline pages. Owned.
133 std::unique_ptr<OfflinerFactory> factory_; 141 std::unique_ptr<OfflinerFactory> factory_;
134 // RequestQueue. Used to store incoming requests. Owned. 142 // RequestQueue. Used to store incoming requests. Owned.
135 std::unique_ptr<RequestQueue> queue_; 143 std::unique_ptr<RequestQueue> queue_;
136 // Scheduler. Used to request a callback when network is available. Owned. 144 // Scheduler. Used to request a callback when network is available. Owned.
137 std::unique_ptr<Scheduler> scheduler_; 145 std::unique_ptr<Scheduler> scheduler_;
138 // Status of the most recent offlining. 146 // Status of the most recent offlining.
139 Offliner::RequestStatus last_offlining_status_; 147 Offliner::RequestStatus last_offlining_status_;
140 // Class to choose which request to schedule next 148 // Class to choose which request to schedule next
141 std::unique_ptr<RequestPicker> picker_; 149 std::unique_ptr<RequestPicker> picker_;
142 // Calling this returns to the scheduler across the JNI bridge. 150 // Calling this returns to the scheduler across the JNI bridge.
143 base::Callback<void(bool)> scheduler_callback_; 151 base::Callback<void(bool)> scheduler_callback_;
144 // Logger to record events. 152 // Logger to record events.
145 RequestCoordinatorEventLogger event_logger_; 153 RequestCoordinatorEventLogger event_logger_;
154 // Timer to watch for pre-render attempts running too long.
155 base::OneShotTimer watchdog_timer_;
146 // Allows us to pass a weak pointer to callbacks. 156 // Allows us to pass a weak pointer to callbacks.
147 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 157 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
148 158
149 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 159 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
150 }; 160 };
151 161
152 } // namespace offline_pages 162 } // namespace offline_pages
153 163
154 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 164 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW
« no previous file with comments | « no previous file | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698