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

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

Issue 2895953004: Add initial Controller to DownloadService (Closed)
Patch Set: Moved stats out 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
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

Powered by Google App Engine
This is Rietveld 408576698