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> |
| 11 #include <string> | |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/callback.h" | 14 #include "base/callback.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 16 #include "components/offline_pages/offline_page_item.h" | 17 #include "components/offline_pages/offline_page_item.h" |
| 17 | 18 |
| 18 namespace offline_pages { | 19 namespace offline_pages { |
| 19 | 20 |
| 20 class RequestQueueStore; | 21 class RequestQueueStore; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 35 // reached a quota of active requests. | 36 // reached a quota of active requests. |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 enum class UpdateRequestResult { | 39 enum class UpdateRequestResult { |
| 39 SUCCESS, | 40 SUCCESS, |
| 40 STORE_FAILURE, | 41 STORE_FAILURE, |
| 41 REQUEST_DOES_NOT_EXIST, // Failed to delete the request because it does not | 42 REQUEST_DOES_NOT_EXIST, // Failed to delete the request because it does not |
| 42 // exist. | 43 // exist. |
| 43 }; | 44 }; |
| 44 | 45 |
| 46 static std::string UpdateRequestResultToString(UpdateRequestResult result) { | |
|
fgorski
2016/08/04 06:01:34
Please consider defining this and the method in of
dougarnett
2016/08/04 16:24:38
Done.
| |
| 47 switch (result) { | |
| 48 case UpdateRequestResult::SUCCESS: return "SUCCESS"; | |
| 49 case UpdateRequestResult::STORE_FAILURE: return "STORE_FAILURE"; | |
| 50 case UpdateRequestResult::REQUEST_DOES_NOT_EXIST: | |
| 51 return "REQUEST_DOES_NOT_EXIST"; | |
| 52 default: | |
| 53 DCHECK(false); | |
| 54 return ""; | |
| 55 } | |
| 56 } | |
| 57 | |
| 45 // Callback used for |GetRequests|. | 58 // Callback used for |GetRequests|. |
| 46 typedef base::Callback<void(GetRequestsResult, | 59 typedef base::Callback<void(GetRequestsResult, |
| 47 const std::vector<SavePageRequest>&)> | 60 const std::vector<SavePageRequest>&)> |
| 48 GetRequestsCallback; | 61 GetRequestsCallback; |
| 49 | 62 |
| 50 // Callback used for |AddRequest|. | 63 // Callback used for |AddRequest|. |
| 51 typedef base::Callback<void(AddRequestResult, const SavePageRequest& request)> | 64 typedef base::Callback<void(AddRequestResult, const SavePageRequest& request)> |
| 52 AddRequestCallback; | 65 AddRequestCallback; |
| 53 | 66 |
| 54 // Callback used by |UdpateRequest| and |RemoveRequest|. | 67 // Callback used by |UdpateRequest| and |RemoveRequest|. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 | 116 |
| 104 // Allows us to pass a weak pointer to callbacks. | 117 // Allows us to pass a weak pointer to callbacks. |
| 105 base::WeakPtrFactory<RequestQueue> weak_ptr_factory_; | 118 base::WeakPtrFactory<RequestQueue> weak_ptr_factory_; |
| 106 | 119 |
| 107 DISALLOW_COPY_AND_ASSIGN(RequestQueue); | 120 DISALLOW_COPY_AND_ASSIGN(RequestQueue); |
| 108 }; | 121 }; |
| 109 | 122 |
| 110 } // namespace offline_pages | 123 } // namespace offline_pages |
| 111 | 124 |
| 112 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_ | 125 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_QUEUE_H_ |
| OLD | NEW |