Index: components/offline_pages/background/request_picker.h |
diff --git a/components/offline_pages/background/request_picker.h b/components/offline_pages/background/request_picker.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0fc4e2aec073d59338ea694f114cc69f7c143e44 |
--- /dev/null |
+++ b/components/offline_pages/background/request_picker.h |
@@ -0,0 +1,43 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ |
+#define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ |
+ |
+#include "base/memory/weak_ptr.h" |
+#include "components/offline_pages/background/request_coordinator.h" |
+#include "components/offline_pages/background/request_queue.h" |
+ |
+namespace offline_pages { |
+ |
+class RequestPicker { |
Dmitry Titov
2016/05/28 00:36:57
So the pattern of usage is:
requestPicker->Choose
Pete Williamson
2016/05/28 00:53:47
The RequestPicker is just a skeleton so far. Even
|
+ public: |
+ RequestPicker(RequestQueue* requestQueue, |
+ RequestCoordinator::RequestPickedCallback picked_callback, |
+ RequestCoordinator::RequestQueueEmptyCallback empty_callback); |
+ |
+ ~RequestPicker(); |
+ |
+ // Choose which request we should process next based on the current |
+ // conditions, and call back to the RequestCoordinator when we have one. |
+ void ChooseNextRequest(); |
+ |
+ private: |
+ // Callback for the GetRequest results to be delivered. |
+ void GetRequestResultCallback(RequestQueue::GetRequestsResult result, |
+ const std::vector<SavePageRequest>& results); |
+ |
+ // unowned pointer to the request queue. |
+ RequestQueue* queue_; |
+ // Callback for when we are done picking a request to do next |
dougarnett
2016/05/31 18:03:04
nit - period at end
|
+ RequestCoordinator::RequestPickedCallback picked_callback_; |
+ // Callback for when there are no more reqeusts to pick. |
+ RequestCoordinator::RequestQueueEmptyCallback empty_callback_; |
+ // Allows us to pass a weak pointer to callbacks. |
+ base::WeakPtrFactory<RequestPicker> weak_ptr_factory_; |
+}; |
+ |
+} // namespace offline_pages |
+ |
+#endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ |