| Index: mojo/public/cpp/bindings/lib/validator_chain.cc
|
| diff --git a/mojo/public/cpp/bindings/lib/validator_chain.cc b/mojo/public/cpp/bindings/lib/validator_chain.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5298288fccb32c681302be1190e663f43809ed62
|
| --- /dev/null
|
| +++ b/mojo/public/cpp/bindings/lib/validator_chain.cc
|
| @@ -0,0 +1,58 @@
|
| +// 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.
|
| +
|
| +#include "mojo/public/cpp/bindings/lib/validator_chain.h"
|
| +
|
| +#include <algorithm>
|
| +
|
| +namespace mojo {
|
| +namespace internal {
|
| +
|
| +ValidatorChain::ValidatorChain(MessageReceiver* sink) : sink_(sink) {
|
| +}
|
| +
|
| +ValidatorChain::ValidatorChain(RValue other) : sink_(other.object->sink_) {
|
| + other.object->sink_ = NULL;
|
| + validators_.swap(other.object->validators_);
|
| +}
|
| +
|
| +ValidatorChain& ValidatorChain::operator=(RValue other) {
|
| + std::swap(sink_, other.object->sink_);
|
| + validators_.swap(other.object->validators_);
|
| + return *this;
|
| +}
|
| +
|
| +ValidatorChain::~ValidatorChain() {
|
| + for (std::vector<MessageValidator*>::iterator iter = validators_.begin();
|
| + iter != validators_.end();
|
| + ++iter) {
|
| + delete *iter;
|
| + }
|
| +}
|
| +
|
| +ValidatorChain& ValidatorChain::Append(MessageValidator* validator) {
|
| + if (!validators_.empty())
|
| + validators_.back()->set_next(validator);
|
| + validators_.push_back(validator);
|
| +
|
| + return *this;
|
| +}
|
| +
|
| +ValidatorChain& ValidatorChain::Append(NoValidator* validator) {
|
| + delete validator;
|
| + return *this;
|
| +}
|
| +
|
| +MessageReceiver* ValidatorChain::GetHead() {
|
| + assert(sink_);
|
| +
|
| + if (validators_.empty())
|
| + return sink_;
|
| +
|
| + validators_.back()->set_next(sink_);
|
| + return validators_.front();
|
| +}
|
| +
|
| +} // namespace internal
|
| +} // namespace mojo
|
|
|