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

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

Issue 2425873003: [Offline Pages] Add evaluation test support in RequestCoordinator. (Closed)
Patch Set: 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_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 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void MarkRequestCompleted(int64_t request_id); 130 void MarkRequestCompleted(int64_t request_id);
131 131
132 const Scheduler::TriggerConditions GetTriggerConditions( 132 const Scheduler::TriggerConditions GetTriggerConditions(
133 const bool user_requested); 133 const bool user_requested);
134 134
135 // A way for tests to set the callback in use when an operation is over. 135 // A way for tests to set the callback in use when an operation is over.
136 void SetProcessingCallbackForTest(const base::Callback<void(bool)> callback) { 136 void SetProcessingCallbackForTest(const base::Callback<void(bool)> callback) {
137 scheduler_callback_ = callback; 137 scheduler_callback_ = callback;
138 } 138 }
139 139
140 // A way to set the callback which would be called if the request is an
141 // user-requested one. Used by testing harness to determine if a request has
142 // been processed.
143 void SetUserRequestCallbackForTest(
144 const base::Callback<void(bool)> callback) {
145 user_request_callback_ = callback;
146 }
147
140 // Observers implementing the RequestCoordinator::Observer interface can 148 // Observers implementing the RequestCoordinator::Observer interface can
141 // register here to get notifications of changes to request state. This 149 // register here to get notifications of changes to request state. This
142 // pointer is not owned, and it is the callers responsibility to remove the 150 // pointer is not owned, and it is the callers responsibility to remove the
143 // observer before the observer is deleted. 151 // observer before the observer is deleted.
144 void AddObserver(RequestCoordinator::Observer* observer); 152 void AddObserver(RequestCoordinator::Observer* observer);
145 153
146 void RemoveObserver(RequestCoordinator::Observer* observer); 154 void RemoveObserver(RequestCoordinator::Observer* observer);
147 155
148 // Implement RequestNotifier 156 // Implement RequestNotifier
149 void NotifyAdded(const SavePageRequest& request) override; 157 void NotifyAdded(const SavePageRequest& request) override;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 std::unique_ptr<RequestPicker> picker_; 368 std::unique_ptr<RequestPicker> picker_;
361 // A set of request_ids that we are holding off until the download manager is 369 // A set of request_ids that we are holding off until the download manager is
362 // done with them. 370 // done with them.
363 std::set<int64_t> disabled_requests_; 371 std::set<int64_t> disabled_requests_;
364 // Calling this returns to the scheduler across the JNI bridge. 372 // Calling this returns to the scheduler across the JNI bridge.
365 base::Callback<void(bool)> scheduler_callback_; 373 base::Callback<void(bool)> scheduler_callback_;
366 // Logger to record events. 374 // Logger to record events.
367 RequestCoordinatorEventLogger event_logger_; 375 RequestCoordinatorEventLogger event_logger_;
368 // Timer to watch for pre-render attempts running too long. 376 // Timer to watch for pre-render attempts running too long.
369 base::OneShotTimer watchdog_timer_; 377 base::OneShotTimer watchdog_timer_;
378 // Callback invoked when a user request is done (default empty).
379 base::Callback<void(bool)> user_request_callback_;
370 // Allows us to pass a weak pointer to callbacks. 380 // Allows us to pass a weak pointer to callbacks.
371 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 381 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
372 382
373 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 383 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
374 }; 384 };
375 385
376 } // namespace offline_pages 386 } // namespace offline_pages
377 387
378 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 388 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698