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/common/config_manager.h" | |
17 #include "omaha/goopdate/app_state_install_complete.h" | |
18 #include "omaha/base/logging.h" | |
19 #include "omaha/goopdate/model.h" | |
20 #include "omaha/goopdate/worker.h" | |
21 | |
22 namespace omaha { | |
23 | |
24 namespace fsm { | |
25 | |
26 AppStateInstallComplete::AppStateInstallComplete(App* app) | |
27 : AppState(STATE_INSTALL_COMPLETE) { | |
28 ASSERT1(app); | |
29 | |
30 // Start the crash handler if an installer has indicated that it requires OOP | |
31 // crash handling. | |
32 bool is_machine = app->app_bundle()->is_machine(); | |
33 if (ConfigManager::Instance()->CanCollectStats(is_machine) && | |
34 (!is_machine || user_info::IsRunningAsSystem())) { | |
35 VERIFY1(SUCCEEDED(goopdate_utils::StartCrashHandler(is_machine))); | |
36 } | |
37 | |
38 VERIFY1(SUCCEEDED(app->model()->PurgeAppLowerVersions( | |
39 app->app_guid_string(), app->next_version()->version()))); | |
40 } | |
41 | |
42 // Omaha installs and updates are two-step processes. Omaha is handled as a | |
43 // special case in both installs and updates. | |
44 // | |
45 // In the install case, Omaha itself is installed by the /install process, which | |
46 // is responsible for pinging. Omaha is never part of the bundle in this case. | |
47 // | |
48 // In update case, the Omaha update is run as a /update process first. | |
49 // The install manager does not wait for that process to complete and, if the | |
50 // launch of it was successful, it transitions the Omaha app into the install | |
51 // complete state. No ping should be sent in this case. Next, the update process | |
52 // runs, finishes the update of Omaha, and then it sends the | |
53 // EVENT_UPDATE_COMPLETE ping. | |
54 const PingEvent* AppStateInstallComplete::CreatePingEvent( | |
55 App* app, | |
56 CurrentState previous_state) const { | |
57 ASSERT1(app); | |
58 UNREFERENCED_PARAMETER(previous_state); | |
59 | |
60 const PingEvent::Types event_type(app->is_update() ? | |
61 PingEvent::EVENT_UPDATE_COMPLETE : | |
62 PingEvent::EVENT_INSTALL_COMPLETE); | |
63 | |
64 const bool is_omaha = !!::IsEqualGUID(kGoopdateGuid, app->app_guid()); | |
65 | |
66 const bool can_ping = !is_omaha; | |
67 | |
68 const HRESULT error_code(app->error_code()); | |
69 ASSERT1(SUCCEEDED(error_code)); | |
70 | |
71 return can_ping ? | |
72 new PingEvent(event_type, GetCompletionResult(*app), error_code, 0) : | |
73 NULL; | |
74 } | |
75 | |
76 // Canceling while in a terminal state has no effect. | |
77 void AppStateInstallComplete::Cancel(App* app) { | |
78 CORE_LOG(L3, (_T("[AppStateInstallComplete::Cancel][0x%p]"), app)); | |
79 UNREFERENCED_PARAMETER(app); | |
80 } | |
81 | |
82 // Terminal states should not transition to error. | |
83 void AppStateInstallComplete::Error(App* app, | |
84 const ErrorContext& error_context, | |
85 const CString& message) { | |
86 UNREFERENCED_PARAMETER(error_context); | |
87 UNREFERENCED_PARAMETER(message); | |
88 HandleInvalidStateTransition(app, _T(__FUNCTION__)); | |
89 } | |
90 | |
91 } // namespace fsm | |
92 | |
93 } // namespace omaha | |
OLD | NEW |