| 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 #include "content/browser/download/parallel_download_utils.h" | 5 #include "content/browser/download/parallel_download_utils.h" |
| 6 | 6 |
| 7 #include "base/metrics/field_trial_params.h" | 7 #include "base/metrics/field_trial_params.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/public/browser/download_save_info.h" | 10 #include "content/public/browser/download_save_info.h" |
| 11 #include "content/public/common/content_features.h" | 11 #include "content/public/common/content_features.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // Finch parameter key value for minimum slice size in bytes to use parallel | |
| 18 // download. | |
| 19 const char kMinSliceSizeFinchKey[] = "min_slice_size"; | |
| 20 | |
| 21 // Default value for |kMinSliceSizeFinchKey|, when no parameter is specified. | 17 // Default value for |kMinSliceSizeFinchKey|, when no parameter is specified. |
| 22 const int64_t kMinSliceSizeParallelDownload = 2097152; | 18 const int64_t kMinSliceSizeParallelDownload = 2097152; |
| 23 | 19 |
| 24 // Finch parameter key value for number of parallel requests in a parallel | |
| 25 // download, including the original request. | |
| 26 const char kParallelRequestCountFinchKey[] = "request_count"; | |
| 27 | |
| 28 // Default value for |kParallelRequestCountFinchKey|, when no parameter is | 20 // Default value for |kParallelRequestCountFinchKey|, when no parameter is |
| 29 // specified. | 21 // specified. |
| 30 const int kParallelRequestCount = 2; | 22 const int kParallelRequestCount = 2; |
| 31 | 23 |
| 32 // Finch parameter key value for the delay time in milliseconds to send | |
| 33 // parallel requests after response of the original request is handled. | |
| 34 const char kParallelRequestDelayFinchKey[] = "parallel_request_delay"; | |
| 35 | |
| 36 // Finch parameter key value for the remaining time in seconds that is required | |
| 37 // to send parallel requests. | |
| 38 const char kParallelRequestRemainingTimeFinchKey[] = | |
| 39 "parallel_request_remaining_time"; | |
| 40 | |
| 41 // The default remaining download time in seconds required for parallel request | 24 // The default remaining download time in seconds required for parallel request |
| 42 // creation. | 25 // creation. |
| 43 const int kDefaultRemainingTimeInSeconds = 10; | 26 const int kDefaultRemainingTimeInSeconds = 10; |
| 44 | 27 |
| 45 // TODO(qinmin): replace this with a comparator operator in | 28 // TODO(qinmin): replace this with a comparator operator in |
| 46 // DownloadItem::ReceivedSlice. | 29 // DownloadItem::ReceivedSlice. |
| 47 bool compareReceivedSlices(const DownloadItem::ReceivedSlice& lhs, | 30 bool compareReceivedSlices(const DownloadItem::ReceivedSlice& lhs, |
| 48 const DownloadItem::ReceivedSlice& rhs) { | 31 const DownloadItem::ReceivedSlice& rhs) { |
| 49 return lhs.offset < rhs.offset; | 32 return lhs.offset < rhs.offset; |
| 50 } | 33 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 157 |
| 175 int64_t size = 0; | 158 int64_t size = 0; |
| 176 while (iter != slices.end() && iter->offset == size) { | 159 while (iter != slices.end() && iter->offset == size) { |
| 177 size += iter->received_bytes; | 160 size += iter->received_bytes; |
| 178 iter++; | 161 iter++; |
| 179 } | 162 } |
| 180 return size; | 163 return size; |
| 181 } | 164 } |
| 182 | 165 |
| 183 } // namespace content | 166 } // namespace content |
| OLD | NEW |