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

Unified Diff: components/download/internal/entry_utils.cc

Issue 2895953004: Add initial Controller to DownloadService (Closed)
Patch Set: Rebased Created 3 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/download/internal/entry_utils.h ('k') | components/download/internal/entry_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c5b38aa8e8f5146d2283437bc43470ab285c7336
--- /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>> MapEntriesToClients(
+ 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;
+}
+
+} // namespace util
+} // namespace download
« no previous file with comments | « components/download/internal/entry_utils.h ('k') | components/download/internal/entry_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698