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

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

Issue 2463713003: [Offline Pages] Converts MarkAttemptCompleted to use TaskQueue (Closed)
Patch Set: Fixed some lint Created 4 years, 1 month 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>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 // Adds |request| to the request queue. Result is returned through |callback|. 74 // Adds |request| to the request queue. Result is returned through |callback|.
75 // In case adding the request violates policy, the result will fail with 75 // In case adding the request violates policy, the result will fail with
76 // appropriate result. Callback will also return a copy of a request with all 76 // appropriate result. Callback will also return a copy of a request with all
77 // fields set. 77 // fields set.
78 void AddRequest(const SavePageRequest& request, 78 void AddRequest(const SavePageRequest& request,
79 const AddRequestCallback& callback); 79 const AddRequestCallback& callback);
80 80
81 // Updates a request in the request queue if a request with matching ID 81 // Updates a request in the request queue if a request with matching ID
82 // exists. Does nothing otherwise. Result is returned through |callback|. 82 // exists. Does nothing otherwise. Result is returned through |callback|.
83 void UpdateRequest(const SavePageRequest& request, 83 void UpdateRequest(const SavePageRequest& request,
fgorski 2016/10/31 20:33:50 Please check if this could be removed with the cha
dougarnett 2016/10/31 22:05:52 Done.
84 const UpdateRequestCallback& callback); 84 const UpdateRequestCallback& callback);
85 85
86 // Removes the requests matching the |request_ids|. Result is returned through 86 // Removes the requests matching the |request_ids|. Result is returned through
87 // |callback|. If a request id cannot be removed, this will still remove the 87 // |callback|. If a request id cannot be removed, this will still remove the
88 // others. 88 // others.
89 void RemoveRequests(const std::vector<int64_t>& request_ids, 89 void RemoveRequests(const std::vector<int64_t>& request_ids,
90 const UpdateCallback& callback); 90 const UpdateCallback& callback);
91 91
92 // Changes the state to |new_state| for requests matching the 92 // Changes the state to |new_state| for requests matching the
93 // |request_ids|. Results are returned through |callback|. 93 // |request_ids|. Results are returned through |callback|.
94 void ChangeRequestsState(const std::vector<int64_t>& request_ids, 94 void ChangeRequestsState(const std::vector<int64_t>& request_ids,
95 const SavePageRequest::RequestState new_state, 95 const SavePageRequest::RequestState new_state,
96 const UpdateCallback& callback); 96 const UpdateCallback& callback);
97 97
98 // Marks attempt with |request_id| as started. Results are returned through 98 // Marks attempt with |request_id| as started. Results are returned through
99 // |callback|. 99 // |callback|.
100 void MarkAttemptStarted(int64_t request_id, const UpdateCallback& callback); 100 void MarkAttemptStarted(int64_t request_id, const UpdateCallback& callback);
101 101
102 // Marks attempt with |request_id| as aborted. Results are returned through 102 // Marks attempt with |request_id| as aborted. Results are returned through
103 // |callback|. 103 // |callback|.
104 void MarkAttemptAborted(int64_t request_id, const UpdateCallback& callback); 104 void MarkAttemptAborted(int64_t request_id, const UpdateCallback& callback);
105 105
106 // Marks attempt with |request_id| as completed. The attempt may have
107 // completed with either success or failure (not denoted here). Results
108 // are returned through |callback|.
109 void MarkAttemptCompleted(int64_t request_id, const UpdateCallback& callback);
110
106 void GetForUpdateDone( 111 void GetForUpdateDone(
107 const RequestQueue::UpdateRequestCallback& update_callback, 112 const RequestQueue::UpdateRequestCallback& update_callback,
108 const SavePageRequest& update_request, 113 const SavePageRequest& update_request,
109 bool success, 114 bool success,
110 std::vector<std::unique_ptr<SavePageRequest>> requests); 115 std::vector<std::unique_ptr<SavePageRequest>> requests);
111 116
112 private: 117 private:
113 // Callback used by |PurgeRequests|. 118 // Callback used by |PurgeRequests|.
114 typedef base::Callback<void(UpdateRequestResult, 119 typedef base::Callback<void(UpdateRequestResult,
115 int /* removed requests count */)> 120 int /* removed requests count */)>
(...skipping 11 matching lines...) Expand all
127 132
128 // Allows us to pass a weak pointer to callbacks. 133 // Allows us to pass a weak pointer to callbacks.
129 base::WeakPtrFactory<RequestQueue> weak_ptr_factory_; 134 base::WeakPtrFactory<RequestQueue> weak_ptr_factory_;
130 135
131 DISALLOW_COPY_AND_ASSIGN(RequestQueue); 136 DISALLOW_COPY_AND_ASSIGN(RequestQueue);
132 }; 137 };
133 138
134 } // namespace offline_pages 139 } // namespace offline_pages
135 140
136 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_ 141 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698