| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <list> | 5 #include <list> |
| 6 | 6 |
| 7 #include "services/media/factory_service/rule_set.h" | 7 #include "services/media/factory_service/rule_set.h" |
| 8 | 8 |
| 9 namespace mojo { | 9 namespace mojo { |
| 10 namespace media { | 10 namespace media { |
| 11 | 11 |
| 12 RuleSet::RuleSet() {} | 12 RuleSet::RuleSet() {} |
| 13 | 13 |
| 14 RuleSet::~RuleSet() {} | 14 RuleSet::~RuleSet() {} |
| 15 | 15 |
| 16 Event RuleSet::AddRule(const Condition& condition) { | 16 Event RuleSet::AddRule(const Condition& condition) { |
| 17 Event event = Event::Create(); | 17 Event event = Event::Create(); |
| 18 | 18 |
| 19 if (condition()) { | 19 if (condition()) { |
| 20 event.Occur(); | 20 event.Occur(); |
| 21 } else { | 21 } else { |
| 22 CheckRules(); // To purge occurred/cancelled events. | 22 CheckRules(); // To purge occurred/cancelled events. |
| 23 rules_.push_back(Rule(condition, event)); | 23 rules_.push_back(Rule(condition, event)); |
| 24 } | 24 } |
| 25 | 25 |
| 26 return event; | 26 return event; |
| 27 } | 27 } |
| 28 | 28 |
| 29 void RuleSet::CheckRules() { | 29 void RuleSet::CheckRules() { |
| 30 Event to_occur; | 30 Event to_occur; |
| 31 std::unique_ptr<std::list<Event>> more_to_occur; | 31 std::unique_ptr<std::list<Event>> more_to_occur; |
| 32 | 32 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 59 | 59 |
| 60 if (more_to_occur) { | 60 if (more_to_occur) { |
| 61 for (const Event& event : *more_to_occur) { | 61 for (const Event& event : *more_to_occur) { |
| 62 event.Occur(); | 62 event.Occur(); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace media | 67 } // namespace media |
| 68 } // namespace mojo | 68 } // namespace mojo |
| OLD | NEW |