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

Unified Diff: components/offline_pages/background/request_queue.h

Issue 2372043002: [Offline pages] Applying TaskQueue to RequestQueue::ChangeRequestsState (Closed)
Patch Set: Addressing feedback from dougarnett Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/background/request_queue.h
diff --git a/components/offline_pages/background/request_queue.h b/components/offline_pages/background/request_queue.h
index 068bf2062fa811ea2097618897298a3bd5801998..445a1f9a332b29e1fdcb7bd023f6f63e1f54e47e 100644
--- a/components/offline_pages/background/request_queue.h
+++ b/components/offline_pages/background/request_queue.h
@@ -15,11 +15,14 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "components/offline_pages/background/save_page_request.h"
+#include "components/offline_pages/core/task_queue.h"
#include "components/offline_pages/offline_page_item.h"
+#include "components/offline_pages/offline_store_types.h"
namespace offline_pages {
class RequestQueueStore;
+typedef StoreUpdateResult<SavePageRequest> UpdateRequestsResult;
// Class responsible for managing save page requests.
class RequestQueue {
@@ -58,6 +61,10 @@ class RequestQueue {
typedef base::Callback<void(AddRequestResult, const SavePageRequest& request)>
AddRequestCallback;
+ // Callback used by |ChangeRequestsState|.
+ typedef base::Callback<void(std::unique_ptr<UpdateRequestsResult>)>
+ UpdateCallback;
+
// Callback used by |UdpateRequest|.
typedef base::Callback<void(UpdateRequestResult)> UpdateRequestCallback;
@@ -98,14 +105,11 @@ class RequestQueue {
void RemoveRequests(const std::vector<int64_t>& request_ids,
const RemoveRequestsCallback& callback);
- // Changes the state to |new_state_ for requests matching the
+ // Changes the state to |new_state| for requests matching the
// |request_ids|. Results are returned through |callback|.
- // TODO(petewil): Instead of having one function per property,
- // modify this to have a single update function that updates an entire
- // request, and doesn't need to care what updates.
void ChangeRequestsState(const std::vector<int64_t>& request_ids,
const SavePageRequest::RequestState new_state,
- const UpdateMultipleRequestsCallback& callback);
+ const UpdateCallback& callback);
void GetForUpdateDone(
const RequestQueue::UpdateRequestCallback& update_callback,
@@ -126,6 +130,9 @@ class RequestQueue {
std::unique_ptr<RequestQueueStore> store_;
+ // Task queue to serialize store access.
+ TaskQueue task_queue_;
+
// Allows us to pass a weak pointer to callbacks.
base::WeakPtrFactory<RequestQueue> weak_ptr_factory_;
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | components/offline_pages/background/request_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698