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

Unified Diff: mojo/common/weak_binding_set.h

Issue 1250463002: Renames WeakBindingSet to BindingSet. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebasing Created 5 years, 5 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 | « mojo/common/binding_set_unittest.cc ('k') | mojo/common/weak_binding_set_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/common/weak_binding_set.h
diff --git a/mojo/common/weak_binding_set.h b/mojo/common/weak_binding_set.h
deleted file mode 100644
index 203e8c3242ec2cc22f65fd17ff41fa54c2da690b..0000000000000000000000000000000000000000
--- a/mojo/common/weak_binding_set.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2014 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.
-
-#ifndef MOJO_COMMON_WEAK_BINDING_SET_H_
-#define MOJO_COMMON_WEAK_BINDING_SET_H_
-
-#include <algorithm>
-#include <vector>
-
-#include "base/memory/weak_ptr.h"
-#include "mojo/public/cpp/bindings/binding.h"
-
-namespace mojo {
-
-// Use this class to manage a set of bindings each of which is
-// owned by the pipe it is bound to.
-template <typename Interface>
-class WeakBindingSet {
- public:
- WeakBindingSet() {}
- ~WeakBindingSet() { CloseAllBindings(); }
-
- void AddBinding(Interface* impl, InterfaceRequest<Interface> request) {
- bindings_.emplace_back(new Binding<Interface>(impl, request.Pass()));
- auto* binding = bindings_.back().get();
- // Set the connection error handler for the newly added Binding to be a
- // function that will erase it from the vector.
- binding->set_connection_error_handler([this, binding]() {
- auto it =
- std::find_if(bindings_.begin(), bindings_.end(),
- [binding](const std::unique_ptr<Binding<Interface>>& b) {
- return (b.get() == binding);
- });
- DCHECK(it != bindings_.end());
- bindings_.erase(it);
- });
- }
-
- void CloseAllBindings() {
- bindings_.clear();
- }
-
- size_t size() const { return bindings_.size(); }
-
- private:
- std::vector<std::unique_ptr<Binding<Interface>>> bindings_;
-
- DISALLOW_COPY_AND_ASSIGN(WeakBindingSet);
-};
-
-} // namespace mojo
-
-#endif // MOJO_COMMON_WEAK_BINDING_SET_H_
« no previous file with comments | « mojo/common/binding_set_unittest.cc ('k') | mojo/common/weak_binding_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698