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

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

Issue 2197573003: Provide API in RequestCoordinator to remove results by client ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback per DougArnett Created 4 years, 4 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_QUEUE_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "components/offline_pages/offline_page_item.h"
16 17
17 namespace offline_pages { 18 namespace offline_pages {
18 19
19 class RequestQueueStore; 20 class RequestQueueStore;
20 class SavePageRequest; 21 class SavePageRequest;
21 22
22 // Class responsible for managing save page requests. 23 // Class responsible for managing save page requests.
23 class RequestQueue { 24 class RequestQueue {
24 public: 25 public:
25 enum class GetRequestsResult { 26 enum class GetRequestsResult {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 70
70 // Updates a request in the request queue if a request with matching ID 71 // Updates a request in the request queue if a request with matching ID
71 // exists. Does nothing otherwise. Result is returned through |callback|. 72 // exists. Does nothing otherwise. Result is returned through |callback|.
72 void UpdateRequest(const SavePageRequest& request, 73 void UpdateRequest(const SavePageRequest& request,
73 const UpdateRequestCallback& callback); 74 const UpdateRequestCallback& callback);
74 75
75 // Removes the request matching the |request_id|. Result is returned through 76 // Removes the request matching the |request_id|. Result is returned through
76 // |callback|. 77 // |callback|.
77 void RemoveRequest(int64_t request_id, const UpdateRequestCallback& callback); 78 void RemoveRequest(int64_t request_id, const UpdateRequestCallback& callback);
78 79
80 // Removes the requests matching the |client_ids|. Results are returned
81 // through |callback|.
82 void RemoveRequestsByClientId(const std::vector<ClientId>& client_id,
83 const UpdateRequestCallback& callback);
Dmitry Titov 2016/08/01 19:37:30 formatting - whitespace.
Pete Williamson 2016/08/01 23:23:07 Done.
84
79 void GetForUpdateDone( 85 void GetForUpdateDone(
80 const RequestQueue::UpdateRequestCallback& update_callback, 86 const RequestQueue::UpdateRequestCallback& update_callback,
81 const SavePageRequest& update_request, 87 const SavePageRequest& update_request,
82 bool success, 88 bool success,
83 const std::vector<SavePageRequest>& requests); 89 const std::vector<SavePageRequest>& requests);
84 90
85 private: 91 private:
86 // Callback used by |PurgeRequests|. 92 // Callback used by |PurgeRequests|.
87 typedef base::Callback<void(UpdateRequestResult, 93 typedef base::Callback<void(UpdateRequestResult,
88 int /* removed requests count */)> 94 int /* removed requests count */)>
89 PurgeRequestsCallback; 95 PurgeRequestsCallback;
90 96
91 // Purges the queue, removing the requests that are no longer relevant, e.g. 97 // Purges the queue, removing the requests that are no longer relevant, e.g.
92 // expired request. Result is returned through |callback| carries the number 98 // expired request. Result is returned through |callback| carries the number
93 // of removed requests. 99 // of removed requests.
94 void PurgeRequests(const PurgeRequestsCallback& callback); 100 void PurgeRequests(const PurgeRequestsCallback& callback);
95 101
96 std::unique_ptr<RequestQueueStore> store_; 102 std::unique_ptr<RequestQueueStore> store_;
97 103
98 // Allows us to pass a weak pointer to callbacks. 104 // Allows us to pass a weak pointer to callbacks.
99 base::WeakPtrFactory<RequestQueue> weak_ptr_factory_; 105 base::WeakPtrFactory<RequestQueue> weak_ptr_factory_;
100 106
101 DISALLOW_COPY_AND_ASSIGN(RequestQueue); 107 DISALLOW_COPY_AND_ASSIGN(RequestQueue);
102 }; 108 };
103 109
104 } // namespace offline_pages 110 } // namespace offline_pages
105 111
106 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_ 112 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698