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

Unified Diff: mojo/public/cpp/bindings/strong_binding_set.h

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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/public/cpp/bindings/strong_binding.h ('k') | mojo/public/cpp/bindings/struct_ptr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/strong_binding_set.h
diff --git a/mojo/public/cpp/bindings/strong_binding_set.h b/mojo/public/cpp/bindings/strong_binding_set.h
deleted file mode 100644
index ef8236f5dc78e8d413e6f6cc9fbaaf9fa0a7091e..0000000000000000000000000000000000000000
--- a/mojo/public/cpp/bindings/strong_binding_set.h
+++ /dev/null
@@ -1,76 +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_PUBLIC_CPP_BINDINGS_STRONG_BINDING_SET_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_SET_H_
-
-#include <assert.h>
-
-#include <algorithm>
-#include <memory>
-#include <vector>
-
-#include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/public/cpp/system/macros.h"
-
-namespace mojo {
-
-// Use this class to manage a set of strong bindings each of which is
-// owned by the pipe it is bound to. The set takes ownership of the
-// interfaces and will delete them when the bindings are closed.
-template <typename Interface>
-class StrongBindingSet {
- public:
- StrongBindingSet() {}
- ~StrongBindingSet() { CloseAllBindings(); }
-
- // Adds a binding to the list and arranges for it to be removed when
- // a connection error occurs. Takes ownership of |impl|, which
- // will be deleted when the binding is closed.
- 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);
- });
- assert(it != bindings_.end());
- delete binding->impl();
- bindings_.erase(it);
- });
- }
-
- // Removes all bindings for the specified interface implementation.
- // The implementation object is not destroyed.
- void RemoveBindings(Interface* impl) {
- bindings_.erase(
- std::remove_if(bindings_.begin(), bindings_.end(),
- [impl](const std::unique_ptr<Binding<Interface>>& b) {
- return (b->impl() == impl);
- }));
- }
-
- // Closes all bindings and deletes their associated interfaces.
- void CloseAllBindings() {
- for (auto it = bindings_.begin(); it != bindings_.end(); ++it) {
- delete (*it)->impl();
- }
- bindings_.clear();
- }
-
- size_t size() const { return bindings_.size(); }
-
- private:
- std::vector<std::unique_ptr<Binding<Interface>>> bindings_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(StrongBindingSet);
-};
-
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_SET_H_
« no previous file with comments | « mojo/public/cpp/bindings/strong_binding.h ('k') | mojo/public/cpp/bindings/struct_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698