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

Unified Diff: components/download/internal/client_set.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/client_set.h ('k') | components/download/internal/client_set_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/download/internal/client_set.cc
diff --git a/components/download/internal/client_set.cc b/components/download/internal/client_set.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f74834b0d9aca2e55a4e7b3c1a4c1fc6d6b3f1a0
--- /dev/null
+++ b/components/download/internal/client_set.cc
@@ -0,0 +1,30 @@
+// 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/client_set.h"
+
+namespace download {
+
+ClientSet::ClientSet(std::unique_ptr<DownloadClientMap> clients)
+ : clients_(std::move(clients)) {
+ DCHECK(clients_->find(DownloadClient::INVALID) == clients_->end());
+}
+
+ClientSet::~ClientSet() = default;
+
+std::set<DownloadClient> ClientSet::GetRegisteredClients() const {
+ std::set<DownloadClient> clients;
+ for (const auto& it : *clients_) {
+ clients.insert(it.first);
+ }
+
+ return clients;
+}
+
+Client* ClientSet::GetClient(DownloadClient id) const {
+ const auto& it = clients_->find(id);
+ return it == clients_->end() ? nullptr : it->second.get();
+}
+
+} // namespace download
« no previous file with comments | « components/download/internal/client_set.h ('k') | components/download/internal/client_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698