OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_ACTION_PROCESSOR_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_ACTION_PROCESSOR_H__ |
6 #define CHROMEOS_PLATFORM_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" |
(...skipping 25 matching lines...) Expand all Loading... |
36 kActionCodeDownloadHashMismatchError = 10, | 36 kActionCodeDownloadHashMismatchError = 10, |
37 }; | 37 }; |
38 | 38 |
39 class AbstractAction; | 39 class AbstractAction; |
40 class ActionProcessorDelegate; | 40 class ActionProcessorDelegate; |
41 | 41 |
42 class ActionProcessor { | 42 class ActionProcessor { |
43 public: | 43 public: |
44 ActionProcessor(); | 44 ActionProcessor(); |
45 | 45 |
46 ~ActionProcessor(); | 46 virtual ~ActionProcessor(); |
47 | 47 |
48 // Starts processing the first Action in the queue. If there's a delegate, | 48 // Starts processing the first Action in the queue. If there's a delegate, |
49 // when all processing is complete, ProcessingDone() will be called on the | 49 // when all processing is complete, ProcessingDone() will be called on the |
50 // delegate. | 50 // delegate. |
51 void StartProcessing(); | 51 virtual void StartProcessing(); |
52 | 52 |
53 // Aborts processing. If an Action is running, it will have | 53 // Aborts processing. If an Action is running, it will have |
54 // TerminateProcessing() called on it. The Action that was running | 54 // TerminateProcessing() called on it. The Action that was running |
55 // will be lost and must be re-enqueued if this Processor is to use it. | 55 // will be lost and must be re-enqueued if this Processor is to use it. |
56 void StopProcessing(); | 56 void StopProcessing(); |
57 | 57 |
58 // Returns true iff an Action is currently processing. | 58 // Returns true iff an Action is currently processing. |
59 bool IsRunning() const { return NULL != current_action_; } | 59 bool IsRunning() const { return NULL != current_action_; } |
60 | 60 |
61 // Adds another Action to the end of the queue. | 61 // Adds another Action to the end of the queue. |
62 void EnqueueAction(AbstractAction* action); | 62 virtual void EnqueueAction(AbstractAction* action); |
63 | 63 |
64 // Sets the current delegate. Set to NULL to remove a delegate. | 64 // Sets/gets the current delegate. Set to NULL to remove a delegate. |
| 65 ActionProcessorDelegate* delegate() const { return delegate_; } |
65 void set_delegate(ActionProcessorDelegate *delegate) { | 66 void set_delegate(ActionProcessorDelegate *delegate) { |
66 delegate_ = delegate; | 67 delegate_ = delegate; |
67 } | 68 } |
68 | 69 |
69 // Returns a pointer to the current Action that's processing. | 70 // Returns a pointer to the current Action that's processing. |
70 AbstractAction* current_action() const { | 71 AbstractAction* current_action() const { |
71 return current_action_; | 72 return current_action_; |
72 } | 73 } |
73 | 74 |
74 // Called by an action to notify processor that it's done. Caller passes self. | 75 // Called by an action to notify processor that it's done. Caller passes self. |
(...skipping 30 matching lines...) Expand all Loading... |
105 // Called whenever an action has finished processing, either successfully | 106 // Called whenever an action has finished processing, either successfully |
106 // or otherwise. | 107 // or otherwise. |
107 virtual void ActionCompleted(ActionProcessor* processor, | 108 virtual void ActionCompleted(ActionProcessor* processor, |
108 AbstractAction* action, | 109 AbstractAction* action, |
109 ActionExitCode code) {} | 110 ActionExitCode code) {} |
110 }; | 111 }; |
111 | 112 |
112 } // namespace chromeos_update_engine | 113 } // namespace chromeos_update_engine |
113 | 114 |
114 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_ACTION_PROCESSOR_H__ | 115 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_ACTION_PROCESSOR_H__ |
OLD | NEW |