Chromium Code Reviews| Index: components/offline_pages/background/get_requests_task.h |
| diff --git a/components/offline_pages/background/get_requests_task.h b/components/offline_pages/background/get_requests_task.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4c5dac205471c91e512ff585132629d8e536bc7c |
| --- /dev/null |
| +++ b/components/offline_pages/background/get_requests_task.h |
| @@ -0,0 +1,45 @@ |
| +// 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_GET_REQUESTS_TASK_H_ |
| +#define COMPONENTS_OFFLINE_PAGES_BACKGROUND_GET_REQUESTS_TASK_H_ |
| + |
| +#include <memory> |
| +#include <vector> |
| + |
| +#include "base/memory/weak_ptr.h" |
| +#include "components/offline_pages/background/request_queue_store.h" |
| +#include "components/offline_pages/core/task.h" |
| + |
| +namespace offline_pages { |
| + |
| +class GetRequestsTask : public Task { |
| + public: |
| + GetRequestsTask(RequestQueueStore* store, |
| + const RequestQueueStore::GetRequestsCallback& callback); |
| + ~GetRequestsTask() override; |
| + |
| + // Task implementation: |
| + void Run() override; |
| + |
| + private: |
| + // Step 1: Read the reqests fromt he store. |
|
dougarnett
2016/11/28 18:48:41
from
fgorski
2016/11/28 19:14:56
Done.
|
| + void ReadRequest(); |
|
Pete Williamson
2016/11/28 21:13:51
Good change, I like the idea of Step 1 having its
|
| + // Step 2: Calls the callback with result, completes the task. |
| + void CompleteWithResult( |
| + bool success, |
| + std::vector<std::unique_ptr<SavePageRequest>> requests); |
| + |
| + // Store from which requests will be read. |
| + RequestQueueStore* store_; |
| + // Callback used to return the read results. |
| + RequestQueueStore::GetRequestsCallback callback_; |
| + |
| + base::WeakPtrFactory<GetRequestsTask> weak_ptr_factory_; |
| + DISALLOW_COPY_AND_ASSIGN(GetRequestsTask); |
| +}; |
| + |
| +} // namespace offline_pages |
| + |
| +#endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_GET_REQUESTS_TASK_H_ |