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

Side by Side Diff: mojo/public/cpp/bindings/lib/validator_chain.cc

Issue 273233002: Mojo cpp bindings: add support for validating incoming messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase onto the InterfacePtr change 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "mojo/public/cpp/bindings/lib/validator_chain.h"
6
7 #include <algorithm>
8
9 namespace mojo {
10 namespace internal {
11
12 ValidatorChain::ValidatorChain(MessageReceiver* sink) : sink_(sink) {
13 }
14
15 ValidatorChain::ValidatorChain(RValue other) : sink_(other.object->sink_) {
16 other.object->sink_ = NULL;
17 validators_.swap(other.object->validators_);
18 }
19
20 ValidatorChain& ValidatorChain::operator=(RValue other) {
21 std::swap(sink_, other.object->sink_);
22 validators_.swap(other.object->validators_);
23 return *this;
24 }
25
26 ValidatorChain::~ValidatorChain() {
27 for (std::vector<MessageValidator*>::iterator iter = validators_.begin();
28 iter != validators_.end();
29 ++iter) {
30 delete *iter;
31 }
32 }
33
34 ValidatorChain& ValidatorChain::Append(MessageValidator* validator) {
35 if (!validators_.empty())
36 validators_.back()->set_next(validator);
37 validators_.push_back(validator);
38
39 return *this;
40 }
41
42 ValidatorChain& ValidatorChain::Append(NoValidator* validator) {
43 delete validator;
44 return *this;
45 }
46
47 MessageReceiver* ValidatorChain::GetHead() {
48 assert(sink_);
49
50 if (validators_.empty())
51 return sink_;
52
53 validators_.back()->set_next(sink_);
54 return validators_.front();
55 }
56
57 } // namespace internal
58 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698