OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 #ifndef UPDATE_ENGINE_ACTION_PROCESSOR_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_ACTION_PROCESSOR_H__ |
6 #define UPDATE_ENGINE_ACTION_PROCESSOR_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_ACTION_PROCESSOR_H__ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 | 11 |
12 // The structure of these classes (Action, ActionPipe, ActionProcessor, etc.) | 12 // The structure of these classes (Action, ActionPipe, ActionProcessor, etc.) |
13 // is based on the KSAction* classes from the Google Update Engine code at | 13 // is based on the KSAction* classes from the Google Update Engine code at |
14 // http://code.google.com/p/update-engine/ . The author of this file sends | 14 // http://code.google.com/p/update-engine/ . The author of this file sends |
15 // a big thanks to that team for their high quality design, implementation, | 15 // a big thanks to that team for their high quality design, implementation, |
16 // and documentation. | 16 // and documentation. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void set_delegate(ActionProcessorDelegate *delegate) { | 50 void set_delegate(ActionProcessorDelegate *delegate) { |
51 delegate_ = delegate; | 51 delegate_ = delegate; |
52 } | 52 } |
53 | 53 |
54 // Returns a pointer to the current Action that's processing. | 54 // Returns a pointer to the current Action that's processing. |
55 AbstractAction* current_action() const { | 55 AbstractAction* current_action() const { |
56 return current_action_; | 56 return current_action_; |
57 } | 57 } |
58 | 58 |
59 // Called by an action to notify processor that it's done. Caller passes self. | 59 // Called by an action to notify processor that it's done. Caller passes self. |
60 void ActionComplete(const AbstractAction* actionptr, bool success); | 60 void ActionComplete(AbstractAction* actionptr, bool success); |
61 | 61 |
62 private: | 62 private: |
63 // Actions that have not yet begun processing, in the order in which | 63 // Actions that have not yet begun processing, in the order in which |
64 // they'll be processed. | 64 // they'll be processed. |
65 std::deque<AbstractAction*> actions_; | 65 std::deque<AbstractAction*> actions_; |
66 | 66 |
67 // A pointer to the currrently processing Action, if any. | 67 // A pointer to the currrently processing Action, if any. |
68 AbstractAction* current_action_; | 68 AbstractAction* current_action_; |
69 | 69 |
70 // A pointer to the delegate, or NULL if none. | 70 // A pointer to the delegate, or NULL if none. |
71 ActionProcessorDelegate *delegate_; | 71 ActionProcessorDelegate *delegate_; |
72 DISALLOW_COPY_AND_ASSIGN(ActionProcessor); | 72 DISALLOW_COPY_AND_ASSIGN(ActionProcessor); |
73 }; | 73 }; |
74 | 74 |
75 // A delegate object can be used to be notified of events that happen | 75 // A delegate object can be used to be notified of events that happen |
76 // in an ActionProcessor. An instance of this class can be passed to an | 76 // in an ActionProcessor. An instance of this class can be passed to an |
77 // ActionProcessor to register itself. | 77 // ActionProcessor to register itself. |
78 class ActionProcessorDelegate { | 78 class ActionProcessorDelegate { |
79 public: | 79 public: |
80 // Called when all processing in an ActionProcessor has completed. A pointer | 80 // Called when all processing in an ActionProcessor has completed. A pointer |
81 // to the ActionProcessor is passed. | 81 // to the ActionProcessor is passed. |
82 virtual void ProcessingDone(const ActionProcessor* processor) {} | 82 virtual void ProcessingDone(const ActionProcessor* processor) {} |
83 | 83 |
84 // Called when processing has stopped. Does not mean that all Actions have | 84 // Called when processing has stopped. Does not mean that all Actions have |
85 // completed. If/when all Actions complete, ProcessingDone() will be called. | 85 // completed. If/when all Actions complete, ProcessingDone() will be called. |
86 virtual void ProcessingStopped(const ActionProcessor* processor) {} | 86 virtual void ProcessingStopped(const ActionProcessor* processor) {} |
87 | 87 |
88 // Called whenever an action has finished processing, either successfully | 88 // Called whenever an action has finished processing, either successfully |
89 // or otherwise. | 89 // or otherwise. |
90 virtual void ActionCompleted(const ActionProcessor* processor, | 90 virtual void ActionCompleted(ActionProcessor* processor, |
91 const AbstractAction* action, | 91 AbstractAction* action, |
92 bool success) {} | 92 bool success) {} |
93 }; | 93 }; |
94 | 94 |
95 } // namespace chromeos_update_engine | 95 } // namespace chromeos_update_engine |
96 | 96 |
97 #endif // UPDATE_ENGINE_ACTION_PROCESSOR_H__ | 97 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_ACTION_PROCESSOR_H__ |
OLD | NEW |