OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // DeclarativeRule<>, DeclarativeConditionSet<>, and DeclarativeActionSet<> | 5 // DeclarativeRule<>, DeclarativeConditionSet<>, and DeclarativeActionSet<> |
6 // templates usable with multiple different declarativeFoo systems. These are | 6 // templates usable with multiple different declarativeFoo systems. These are |
7 // templated on the Condition and Action types that define the behavior of a | 7 // templated on the Condition and Action types that define the behavior of a |
8 // particular declarative event. | 8 // particular declarative event. |
9 | 9 |
10 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ | 10 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 const base::Time& extension_install_time, | 156 const base::Time& extension_install_time, |
157 typename ActionT::ApplyInfo* apply_info) const; | 157 typename ActionT::ApplyInfo* apply_info) const; |
158 | 158 |
159 // Rules call this method when they have stateful conditions, and those | 159 // Rules call this method when they have stateful conditions, and those |
160 // conditions stop being fulfilled. Rules with event-based conditions (e.g. a | 160 // conditions stop being fulfilled. Rules with event-based conditions (e.g. a |
161 // network request happened) will never Revert() an action. | 161 // network request happened) will never Revert() an action. |
162 void Revert(const std::string& extension_id, | 162 void Revert(const std::string& extension_id, |
163 const base::Time& extension_install_time, | 163 const base::Time& extension_install_time, |
164 typename ActionT::ApplyInfo* apply_info) const; | 164 typename ActionT::ApplyInfo* apply_info) const; |
165 | 165 |
166 // Rules call this method when their conditions are checked and were already | |
167 // fulfilled previously. | |
168 void Reapply(const std::string& extension_id, | |
not at google - send to devlin
2014/08/21 00:32:56
nit: put this between Apply and Revert, since that
Mark Dittmer
2014/08/21 01:08:48
Done.
| |
169 const base::Time& extension_install_time, | |
170 typename ActionT::ApplyInfo* apply_info) const; | |
171 | |
166 // Returns the minimum priority of rules that may be evaluated after | 172 // Returns the minimum priority of rules that may be evaluated after |
167 // this rule. Defaults to MIN_INT. | 173 // this rule. Defaults to MIN_INT. |
168 int GetMinimumPriority() const; | 174 int GetMinimumPriority() const; |
169 | 175 |
170 const Actions& actions() const { return actions_; } | 176 const Actions& actions() const { return actions_; } |
171 | 177 |
172 private: | 178 private: |
173 const Actions actions_; | 179 const Actions actions_; |
174 | 180 |
175 DISALLOW_COPY_AND_ASSIGN(DeclarativeActionSet); | 181 DISALLOW_COPY_AND_ASSIGN(DeclarativeActionSet); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 void DeclarativeActionSet<ActionT>::Revert( | 393 void DeclarativeActionSet<ActionT>::Revert( |
388 const std::string& extension_id, | 394 const std::string& extension_id, |
389 const base::Time& extension_install_time, | 395 const base::Time& extension_install_time, |
390 typename ActionT::ApplyInfo* apply_info) const { | 396 typename ActionT::ApplyInfo* apply_info) const { |
391 for (typename Actions::const_iterator i = actions_.begin(); | 397 for (typename Actions::const_iterator i = actions_.begin(); |
392 i != actions_.end(); ++i) | 398 i != actions_.end(); ++i) |
393 (*i)->Revert(extension_id, extension_install_time, apply_info); | 399 (*i)->Revert(extension_id, extension_install_time, apply_info); |
394 } | 400 } |
395 | 401 |
396 template<typename ActionT> | 402 template<typename ActionT> |
403 void DeclarativeActionSet<ActionT>::Reapply( | |
not at google - send to devlin
2014/08/21 00:32:56
Ditto order.
Mark Dittmer
2014/08/21 01:08:48
Done.
| |
404 const std::string& extension_id, | |
405 const base::Time& extension_install_time, | |
406 typename ActionT::ApplyInfo* apply_info) const { | |
407 for (typename Actions::const_iterator i = actions_.begin(); | |
408 i != actions_.end(); ++i) | |
409 (*i)->Reapply(extension_id, extension_install_time, apply_info); | |
410 } | |
411 | |
412 template<typename ActionT> | |
397 int DeclarativeActionSet<ActionT>::GetMinimumPriority() const { | 413 int DeclarativeActionSet<ActionT>::GetMinimumPriority() const { |
398 int minimum_priority = std::numeric_limits<int>::min(); | 414 int minimum_priority = std::numeric_limits<int>::min(); |
399 for (typename Actions::const_iterator i = actions_.begin(); | 415 for (typename Actions::const_iterator i = actions_.begin(); |
400 i != actions_.end(); ++i) { | 416 i != actions_.end(); ++i) { |
401 minimum_priority = std::max(minimum_priority, (*i)->minimum_priority()); | 417 minimum_priority = std::max(minimum_priority, (*i)->minimum_priority()); |
402 } | 418 } |
403 return minimum_priority; | 419 return minimum_priority; |
404 } | 420 } |
405 | 421 |
406 // | 422 // |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 } | 498 } |
483 | 499 |
484 template<typename ConditionT, typename ActionT> | 500 template<typename ConditionT, typename ActionT> |
485 int DeclarativeRule<ConditionT, ActionT>::GetMinimumPriority() const { | 501 int DeclarativeRule<ConditionT, ActionT>::GetMinimumPriority() const { |
486 return actions_->GetMinimumPriority(); | 502 return actions_->GetMinimumPriority(); |
487 } | 503 } |
488 | 504 |
489 } // namespace extensions | 505 } // namespace extensions |
490 | 506 |
491 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ | 507 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_RULE_H__ |
OLD | NEW |