OLD | NEW |
| (Empty) |
1 // Copyright 2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 #ifndef OMAHA_GOOPDATE_APP_STATE_ERROR_H_ | |
17 #define OMAHA_GOOPDATE_APP_STATE_ERROR_H_ | |
18 | |
19 #include "base/basictypes.h" | |
20 #include "omaha/goopdate/app_state.h" | |
21 | |
22 namespace omaha { | |
23 | |
24 namespace fsm { | |
25 | |
26 // The error state is idempotent. Further transitions from error state into | |
27 // itself are allowed but have no effect. Therefore, the first error wins. One | |
28 // scenario where this occurs is canceling the app. Canceling the app is not | |
29 // blocking and it moves the app in the error state right away. The Error | |
30 // method is called a second time, as the actual cancel code executes in the | |
31 // thread pool. | |
32 class AppStateError : public AppState { | |
33 public: | |
34 AppStateError(); | |
35 virtual ~AppStateError() {} | |
36 | |
37 virtual const PingEvent* CreatePingEvent(App* app, | |
38 CurrentState previous_state) const; | |
39 | |
40 // These calls are legal in this state but do nothing. This can occur when | |
41 // this app has encountered an error but bundle is still being processed. | |
42 // For instance, when cancelling a bundle during a download, the applications | |
43 // transition right away in the error state. The cancel event is handled at | |
44 // some point in the future. Depending on a race condition, the downloads may | |
45 // have succeeded or failed due to the cancellation. The race condition is | |
46 // resolved when the transition call reaches this object and the call is | |
47 // ignored. | |
48 virtual void DownloadComplete(App* app); | |
49 virtual void MarkReadyToInstall(App* app); | |
50 | |
51 // These calls are legal in this state but do nothing. This can occur when | |
52 // this app has encountered an error or has been canceled but bundle is still | |
53 // being processed. | |
54 virtual void PreUpdateCheck(App* app, xml::UpdateRequest* update_request); | |
55 virtual void PostUpdateCheck(App* app, | |
56 HRESULT result, | |
57 xml::UpdateResponse* update_response); | |
58 virtual void QueueDownload(App* app); | |
59 virtual void QueueDownloadOrInstall(App* app); | |
60 virtual void Download(App* app, DownloadManagerInterface* download_manager); | |
61 virtual void QueueInstall(App* app); | |
62 virtual void Install(App* app, InstallManagerInterface* install_manager); | |
63 | |
64 // Canceling while in a terminal state has no effect. | |
65 virtual void Cancel(App* app); | |
66 | |
67 virtual void Error(App* app, | |
68 const ErrorContext& error_context, | |
69 const CString& message); | |
70 | |
71 private: | |
72 DISALLOW_COPY_AND_ASSIGN(AppStateError); | |
73 }; | |
74 | |
75 } // namespace fsm | |
76 | |
77 } // namespace omaha | |
78 | |
79 #endif // OMAHA_GOOPDATE_APP_STATE_ERROR_H_ | |
OLD | NEW |