1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
9 #include "mojo/public/cpp/environment/logging.h"
14 FilterChain::FilterChain(MessageReceiver* sink) : sink_(sink) {
17 FilterChain::FilterChain(RValue other) : sink_(other.object->sink_) {
18 other.object->sink_ = NULL;
19 filters_.swap(other.object->filters_);
22 FilterChain& FilterChain::operator=(RValue other) {
23 std::swap(sink_, other.object->sink_);
24 filters_.swap(other.object->filters_);
28 FilterChain::~FilterChain() {
29 for (std::vector<MessageFilter*>::iterator iter = filters_.begin();
30 iter != filters_.end();
36 void FilterChain::SetSink(MessageReceiver* sink) {
39 if (!filters_.empty())
40 filters_.back()->set_sink(sink);
43 MessageReceiver* FilterChain::GetHead() {
45 return filters_.empty() ? sink_ : filters_.front();
48 } // namespace internal