Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 // appropriate result. Callback will also return a copy of a request with all | 67 // appropriate result. Callback will also return a copy of a request with all |
| 68 // fields set. | 68 // fields set. |
| 69 void AddRequest(const SavePageRequest& request, | 69 void AddRequest(const SavePageRequest& request, |
| 70 const AddRequestCallback& callback); | 70 const AddRequestCallback& callback); |
| 71 | 71 |
| 72 // Updates a request in the request queue if a request with matching ID | 72 // Updates a request in the request queue if a request with matching ID |
| 73 // exists. Does nothing otherwise. Result is returned through |callback|. | 73 // exists. Does nothing otherwise. Result is returned through |callback|. |
| 74 void UpdateRequest(const SavePageRequest& request, | 74 void UpdateRequest(const SavePageRequest& request, |
| 75 const UpdateRequestCallback& callback); | 75 const UpdateRequestCallback& callback); |
| 76 | 76 |
| 77 // Removes the request matching the |request_id|. Result is returned through | 77 // Removes the requests matching the |request_ids|. Result is returned through |
|
Dmitry Titov
2016/08/10 02:52:14
This returns result from UpdateRequestResult. That
Pete Williamson
2016/08/10 21:15:25
OK, changed the callback to return an array of sta
| |
| 78 // |callback|. | 78 // |callback|. |
| 79 void RemoveRequest(int64_t request_id, const UpdateRequestCallback& callback); | 79 void RemoveRequests(const std::vector<int64_t>& request_ids, |
| 80 | 80 const UpdateRequestCallback& callback); |
| 81 // Removes the requests matching the |client_ids|. Results are returned | |
| 82 // through |callback|. | |
| 83 void RemoveRequestsByClientId(const std::vector<ClientId>& client_id, | |
| 84 const UpdateRequestCallback& callback); | |
| 85 | 81 |
| 86 void GetForUpdateDone( | 82 void GetForUpdateDone( |
| 87 const RequestQueue::UpdateRequestCallback& update_callback, | 83 const RequestQueue::UpdateRequestCallback& update_callback, |
| 88 const SavePageRequest& update_request, | 84 const SavePageRequest& update_request, |
| 89 bool success, | 85 bool success, |
| 90 const std::vector<SavePageRequest>& requests); | 86 const std::vector<SavePageRequest>& requests); |
| 91 | 87 |
| 92 private: | 88 private: |
| 93 // Callback used by |PurgeRequests|. | 89 // Callback used by |PurgeRequests|. |
| 94 typedef base::Callback<void(UpdateRequestResult, | 90 typedef base::Callback<void(UpdateRequestResult, |
| 95 int /* removed requests count */)> | 91 int /* removed requests count */)> |
| 96 PurgeRequestsCallback; | 92 PurgeRequestsCallback; |
| 97 | 93 |
| 98 // Purges the queue, removing the requests that are no longer relevant, e.g. | 94 // Purges the queue, removing the requests that are no longer relevant, e.g. |
| 99 // expired request. Result is returned through |callback| carries the number | 95 // expired request. Result is returned through |callback| carries the number |
| 100 // of removed requests. | 96 // of removed requests. |
| 101 void PurgeRequests(const PurgeRequestsCallback& callback); | 97 void PurgeRequests(const PurgeRequestsCallback& callback); |
| 102 | 98 |
| 103 std::unique_ptr<RequestQueueStore> store_; | 99 std::unique_ptr<RequestQueueStore> store_; |
| 104 | 100 |
| 105 // Allows us to pass a weak pointer to callbacks. | 101 // Allows us to pass a weak pointer to callbacks. |
| 106 base::WeakPtrFactory<RequestQueue> weak_ptr_factory_; | 102 base::WeakPtrFactory<RequestQueue> weak_ptr_factory_; |
| 107 | 103 |
| 108 DISALLOW_COPY_AND_ASSIGN(RequestQueue); | 104 DISALLOW_COPY_AND_ASSIGN(RequestQueue); |
| 109 }; | 105 }; |
| 110 | 106 |
| 111 } // namespace offline_pages | 107 } // namespace offline_pages |
| 112 | 108 |
| 113 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_ | 109 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_ |
| OLD | NEW |