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

Unified Diff: mojo/public/cpp/bindings/lib/filter_chain.cc

Issue 291583005: Change FilterChain::Append() to a template method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « mojo/public/cpp/bindings/lib/filter_chain.h ('k') | mojo/public/cpp/bindings/lib/interface_impl_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/filter_chain.cc
diff --git a/mojo/public/cpp/bindings/lib/filter_chain.cc b/mojo/public/cpp/bindings/lib/filter_chain.cc
index 7101eff13ff7aeb99be84acb6e1f246cf1e9d9f9..efd4ba19875317042b9c1a37186e6a621e759c96 100644
--- a/mojo/public/cpp/bindings/lib/filter_chain.cc
+++ b/mojo/public/cpp/bindings/lib/filter_chain.cc
@@ -4,6 +4,8 @@
#include "mojo/public/cpp/bindings/lib/filter_chain.h"
+#include <assert.h>
+
#include <algorithm>
namespace mojo {
@@ -31,27 +33,16 @@ FilterChain::~FilterChain() {
}
}
-FilterChain& FilterChain::Append(MessageFilter* filter) {
+void FilterChain::SetSink(MessageReceiver* sink) {
+ assert(!sink_);
+ sink_ = sink;
if (!filters_.empty())
- filters_.back()->set_sink(filter);
- filters_.push_back(filter);
-
- return *this;
-}
-
-FilterChain& FilterChain::Append(PassThroughFilter* filter) {
- delete filter;
- return *this;
+ filters_.back()->set_sink(sink);
}
MessageReceiver* FilterChain::GetHead() {
assert(sink_);
-
- if (filters_.empty())
- return sink_;
-
- filters_.back()->set_sink(sink_);
- return filters_.front();
+ return filters_.empty() ? sink_ : filters_.front();
}
} // namespace internal
« no previous file with comments | « mojo/public/cpp/bindings/lib/filter_chain.h ('k') | mojo/public/cpp/bindings/lib/interface_impl_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698