| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_DOWNLOAD_PUBLIC_DOWNLOAD_PARAMS_H_ | 5 #ifndef COMPONENTS_DOWNLOAD_PUBLIC_DOWNLOAD_PARAMS_H_ |
| 6 #define COMPONENTS_DOWNLOAD_PUBLIC_DOWNLOAD_PARAMS_H_ | 6 #define COMPONENTS_DOWNLOAD_PUBLIC_DOWNLOAD_PARAMS_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "components/download/public/clients.h" | 10 #include "components/download/public/clients.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // The |client| needs to be properly created and registered for this service for | 95 // The |client| needs to be properly created and registered for this service for |
| 96 // the download to be accepted. | 96 // the download to be accepted. |
| 97 struct DownloadParams { | 97 struct DownloadParams { |
| 98 enum StartResult { | 98 enum StartResult { |
| 99 // The download is accepted and persisted. | 99 // The download is accepted and persisted. |
| 100 ACCEPTED, | 100 ACCEPTED, |
| 101 | 101 |
| 102 // The DownloadService has too many downloads. Backoff and retry. | 102 // The DownloadService has too many downloads. Backoff and retry. |
| 103 BACKOFF, | 103 BACKOFF, |
| 104 | 104 |
| 105 // Failed to create the download. Invalid input parameters. | 105 // The DownloadService has no knowledge of the DownloadClient associated |
| 106 BAD_PARAMETERS, | 106 // with this request. |
| 107 UNEXPECTED_CLIENT, |
| 108 |
| 109 // Failed to create the download. The guid is already in use. |
| 110 UNEXPECTED_GUID, |
| 111 |
| 112 // The download was cancelled by the Client while it was being persisted. |
| 113 CLIENT_CANCELLED, |
| 114 |
| 115 // The DownloadService was unable to accept and persist this download due to |
| 116 // an internal error like the underlying DB store failing to write to disk. |
| 117 INTERNAL_ERROR, |
| 107 | 118 |
| 108 // TODO(dtrainor): Add more error codes. | 119 // TODO(dtrainor): Add more error codes. |
| 109 }; | 120 }; |
| 110 | 121 |
| 122 using StartCallback = base::Callback<void(const std::string&, StartResult)>; |
| 123 |
| 111 DownloadParams(); | 124 DownloadParams(); |
| 112 DownloadParams(const DownloadParams& other); | 125 DownloadParams(const DownloadParams& other); |
| 113 ~DownloadParams(); | 126 ~DownloadParams(); |
| 114 | 127 |
| 115 // The feature that is requesting this download. | 128 // The feature that is requesting this download. |
| 116 DownloadClient client; | 129 DownloadClient client; |
| 117 | 130 |
| 118 // A unique GUID that represents this download. See |base::GenerateGUID()|. | 131 // A unique GUID that represents this download. See |base::GenerateGUID()|. |
| 119 std::string guid; | 132 std::string guid; |
| 120 | 133 |
| 121 // A callback that will be notified if this download has been accepted and | 134 // A callback that will be notified if this download has been accepted and |
| 122 // persisted by the DownloadService. | 135 // persisted by the DownloadService. |
| 123 base::Callback<void(const DownloadParams&, StartResult)> callback; | 136 StartCallback callback; |
| 124 | 137 |
| 125 // The parameters that determine under what device conditions this download | 138 // The parameters that determine under what device conditions this download |
| 126 // will occur. | 139 // will occur. |
| 127 SchedulingParams scheduling_params; | 140 SchedulingParams scheduling_params; |
| 128 | 141 |
| 129 // The parameters that define the actual download request to make. | 142 // The parameters that define the actual download request to make. |
| 130 RequestParams request_params; | 143 RequestParams request_params; |
| 131 }; | 144 }; |
| 132 | 145 |
| 133 } // namespace download | 146 } // namespace download |
| 134 | 147 |
| 135 #endif // COMPONENTS_DOWNLOAD_PUBLIC_DOWNLOAD_PARAMS_H_ | 148 #endif // COMPONENTS_DOWNLOAD_PUBLIC_DOWNLOAD_PARAMS_H_ |
| OLD | NEW |