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_installing.h" | |
17 #include "omaha/base/debug.h" | |
18 #include "omaha/base/logging.h" | |
19 #include "omaha/goopdate/app_state_error.h" | |
20 #include "omaha/goopdate/app_state_install_complete.h" | |
21 #include "omaha/goopdate/model.h" | |
22 | |
23 namespace omaha { | |
24 | |
25 namespace fsm { | |
26 | |
27 AppStateInstalling::AppStateInstalling() | |
28 : AppState(STATE_INSTALLING) { | |
29 } | |
30 | |
31 const PingEvent* AppStateInstalling::CreatePingEvent( | |
32 App* app, | |
33 CurrentState previous_state) const { | |
34 ASSERT1(app); | |
35 UNREFERENCED_PARAMETER(previous_state); | |
36 | |
37 const PingEvent::Types event_type(app->is_update() ? | |
38 PingEvent::EVENT_UPDATE_INSTALLER_START : | |
39 PingEvent::EVENT_INSTALL_INSTALLER_START); | |
40 | |
41 | |
42 const HRESULT error_code = app->error_code(); | |
43 ASSERT1(SUCCEEDED(error_code)); | |
44 | |
45 return new PingEvent(event_type, GetCompletionResult(*app), error_code, 0); | |
46 } | |
47 | |
48 // The state does not change if already in the Installing state. | |
49 void AppStateInstalling::Installing(App* app) { | |
50 CORE_LOG(L3, (_T("[AppStateInstalling::Installing][0x%p]"), app)); | |
51 ASSERT1(app); | |
52 ASSERT(false, (_T("This might be valid when we support install progress."))); | |
53 | |
54 UNREFERENCED_PARAMETER(app); | |
55 } | |
56 | |
57 void AppStateInstalling::ReportInstallerComplete( | |
58 App* app, | |
59 const InstallerResultInfo& result_info) { | |
60 CORE_LOG(L3, (_T("[AppStateInstalling::ReportInstallerComplete][%p]"), app)); | |
61 ASSERT1(app); | |
62 | |
63 app->SetInstallerResult(result_info); | |
64 | |
65 ChangeState(app, result_info.type == INSTALLER_RESULT_SUCCESS ? | |
66 static_cast<AppState*>(new AppStateInstallComplete(app)) : | |
67 static_cast<AppState*>(new AppStateError)); | |
68 } | |
69 | |
70 // Cancel in installing state has no effect because currently we cannot cancel | |
71 // installers.. Override the function to avoid moving app into error state. | |
72 // The app will automatically enter the completion state when the installer | |
73 // completes. | |
74 void AppStateInstalling::Cancel(App* app) { | |
75 CORE_LOG(L3, (_T("[AppStateInstalling::Cancel][0x%p]"), app)); | |
76 ASSERT1(app); | |
77 | |
78 UNREFERENCED_PARAMETER(app); | |
79 } | |
80 | |
81 } // namespace fsm | |
82 | |
83 } // namespace omaha | |
OLD | NEW |