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 #include "omaha/goopdate/app_state_no_update.h" | |
17 #include "omaha/base/debug.h" | |
18 #include "omaha/base/error.h" | |
19 #include "omaha/base/logging.h" | |
20 #include "omaha/goopdate/model.h" | |
21 | |
22 namespace omaha { | |
23 | |
24 namespace fsm { | |
25 | |
26 AppStateNoUpdate::AppStateNoUpdate() : AppState(STATE_NO_UPDATE) { | |
27 } | |
28 | |
29 const PingEvent* AppStateNoUpdate::CreatePingEvent( | |
30 App* app, | |
31 CurrentState previous_state) const { | |
32 ASSERT1(app); | |
33 UNREFERENCED_PARAMETER(previous_state); | |
34 | |
35 // This state corresponds to the update case only. 'No updates' scenario in | |
36 // the installed case should be handled as errors by the state machine. | |
37 ASSERT1(app->is_update()); | |
38 | |
39 const PingEvent::Results completion_result = GetCompletionResult(*app); | |
40 ASSERT1(completion_result == PingEvent::EVENT_RESULT_SUCCESS || | |
41 completion_result == PingEvent::EVENT_RESULT_UPDATE_DEFERRED); | |
42 | |
43 // Creates a ping for deferred updates only. | |
44 if (completion_result == PingEvent::EVENT_RESULT_UPDATE_DEFERRED) { | |
45 // Omaha updates should never be deferred. | |
46 ASSERT1(!::IsEqualGUID(kGoopdateGuid, app->app_guid())); | |
47 | |
48 const PingEvent::Types event_type(PingEvent::EVENT_UPDATE_COMPLETE); | |
49 | |
50 const HRESULT error_code(app->error_code()); | |
51 ASSERT1(error_code == GOOPDATE_E_UPDATE_DEFERRED); | |
52 | |
53 return new PingEvent(event_type, completion_result, error_code, 0); | |
54 } | |
55 | |
56 return NULL; | |
57 } | |
58 | |
59 void AppStateNoUpdate::QueueDownload(App* app) { | |
60 CORE_LOG(L4, (_T("[AppStateNoUpdate::QueueDownload][%p]"), app)); | |
61 ASSERT1(app); | |
62 UNREFERENCED_PARAMETER(app); | |
63 } | |
64 | |
65 void AppStateNoUpdate::QueueDownloadOrInstall(App* app) { | |
66 CORE_LOG(L4, (_T("[AppStateNoUpdate::QueueDownloadOrInstall][%p]"), app)); | |
67 ASSERT1(app); | |
68 UNREFERENCED_PARAMETER(app); | |
69 } | |
70 | |
71 void AppStateNoUpdate::Download( | |
72 App* app, | |
73 DownloadManagerInterface* download_manager) { | |
74 CORE_LOG(L4, (_T("[AppStateNoUpdate::Download][0x%p]"), app)); | |
75 ASSERT1(app); | |
76 ASSERT1(download_manager); | |
77 UNREFERENCED_PARAMETER(app); | |
78 UNREFERENCED_PARAMETER(download_manager); | |
79 } | |
80 | |
81 void AppStateNoUpdate::QueueInstall(App* app) { | |
82 CORE_LOG(L4, (_T("[AppStateNoUpdate::QueueInstall][%p]"), app)); | |
83 ASSERT1(app); | |
84 UNREFERENCED_PARAMETER(app); | |
85 } | |
86 | |
87 void AppStateNoUpdate::Install( | |
88 App* app, | |
89 InstallManagerInterface* install_manager) { | |
90 CORE_LOG(L4, (_T("[AppStateNoUpdate::Install][0x%p]"), app)); | |
91 ASSERT1(app); | |
92 ASSERT1(install_manager); | |
93 UNREFERENCED_PARAMETER(app); | |
94 UNREFERENCED_PARAMETER(install_manager); | |
95 } | |
96 | |
97 // Canceling while in a terminal state has no effect. | |
98 void AppStateNoUpdate::Cancel(App* app) { | |
99 CORE_LOG(L4, (_T("[AppStateNoUpdate::Cancel][0x%p]"), app)); | |
100 ASSERT1(app); | |
101 UNREFERENCED_PARAMETER(app); | |
102 } | |
103 | |
104 // Terminal states should not transition to error. | |
105 void AppStateNoUpdate::Error(App* app, | |
106 const ErrorContext& error_context, | |
107 const CString& message) { | |
108 ASSERT1(app); | |
109 UNREFERENCED_PARAMETER(error_context); | |
110 UNREFERENCED_PARAMETER(message); | |
111 HandleInvalidStateTransition(app, _T(__FUNCTION__)); | |
112 } | |
113 | |
114 } // namespace fsm | |
115 | |
116 } // namespace omaha | |
OLD | NEW |