Chromium Code Reviews| Index: components/download/internal/entry_utils.cc |
| diff --git a/components/download/internal/entry_utils.cc b/components/download/internal/entry_utils.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dc1bee7f97e37dc473447e4ff02ec53809a4252f |
| --- /dev/null |
| +++ b/components/download/internal/entry_utils.cc |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/download/internal/entry_utils.h" |
| + |
| +#include "components/download/internal/entry.h" |
| + |
| +namespace download { |
| +namespace util { |
| + |
| +uint32_t GetNumberOfEntriesForClient(DownloadClient client, |
| + const std::vector<Entry*>& entries) { |
| + uint32_t count = 0; |
| + for (auto* entry : entries) |
| + if (entry->client == client) |
| + count++; |
| + |
| + return count; |
| +} |
| + |
| +std::map<DownloadClient, std::vector<std::string>> MapReduceEntriesToClients( |
| + const std::set<DownloadClient>& clients, |
| + const std::vector<Entry*>& entries) { |
| + std::map<DownloadClient, std::vector<std::string>> categorized; |
| + |
| + for (auto* entry : entries) { |
| + DownloadClient client = entry->client; |
| + if (clients.find(client) == clients.end()) |
| + client = DownloadClient::INVALID; |
| + |
| + categorized[client].push_back(entry->guid); |
| + } |
| + |
| + return categorized; |
|
xingliu
2017/05/27 00:25:32
optional nit: this is a cool name, but the caller
David Trainor- moved to gerrit
2017/05/30 18:55:23
Done.
|
| +} |
| + |
| +} // namespace util |
| +} // namespace download |