Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: client/bundle_installer.h

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/bundle_creator_test.cc ('k') | client/bundle_installer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2009-2010 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
17 #ifndef OMAHA_CLIENT_BUNDLE_INSTALLER_H_
18 #define OMAHA_CLIENT_BUNDLE_INSTALLER_H_
19
20 #include <windows.h>
21 #include <atlstr.h>
22 #include <vector>
23 #include "base/basictypes.h"
24 #include "base/scoped_ptr.h"
25 #include "omaha/base/safe_format.h"
26 #include "omaha/base/wtl_atlapp_wrapper.h"
27 #include "goopdate/omaha3_idl.h"
28 #include "omaha/client/install_progress_observer.h"
29
30 namespace omaha {
31
32 // TODO(omaha): These should be declared in their own file.
33 namespace internal {
34
35 CString GetAppDisplayName(IApp* app);
36
37 // Builds a list of app names of the format "one, two, three".
38 // TODO(omaha): If this does not end up using AppCompletionInfo, move it to
39 // client_utils.
40 CString BuildAppNameList(const std::vector<CString>& app_names);
41
42 // Helper function that returns the error information from the ICurrentState.
43 HRESULT GetCompletionInformation(IApp* app,
44 CurrentState* current_state,
45 AppCompletionInfo* app_info);
46
47 // Gets the completion message for an app.
48 void GetAppCompletionMessage(IApp* app,
49 AppCompletionInfo* app_info);
50
51 // Gets the completion message for the bundle.
52 // If the bundle name cannot be obtained, pass an empty string in bundle_name.
53 // TODO(omaha): If AppCompletionInfo is exposed, maybe move to client_utils.
54 CString GetBundleCompletionMessage(
55 const CString& bundle_name,
56 const std::vector<AppCompletionInfo>& apps_info,
57 bool is_only_no_update,
58 bool is_canceled);
59
60 } // namespace internal
61
62 class HelpUrlBuilder;
63 class ShutdownCallback;
64
65 class BundleInstaller
66 : public CWindowImpl<BundleInstaller,
67 CWindow,
68 CWinTraits<WS_OVERLAPPED, WS_EX_TOOLWINDOW> > {
69 public:
70 // Takes ownership of help_url_builder.
71 BundleInstaller(HelpUrlBuilder* help_url_builder,
72 bool is_update_all_apps,
73 bool is_update_check_only,
74 bool is_browser_type_supported);
75 ~BundleInstaller();
76
77 HRESULT Initialize();
78 void Uninitialize();
79
80 // Installs a bundle. The installer takes the ownership of the bundle and
81 // releases the inteface before function returns.
82 HRESULT InstallBundle(bool is_machine,
83 bool listen_to_shutdown_event,
84 IAppBundle* app_bundle,
85 InstallProgressObserver* observer);
86
87 void SetBundleParentWindow(HWND parent_window);
88
89 // Message loop that pumps messages during installation.
90 CMessageLoop* message_loop() { return &message_loop_; }
91
92 // Handles asynchronous requests for the application to close.
93 void DoClose();
94
95 // Handles requests to exit the BundleInstaller message loop. Should only be
96 // called after the BundleInstaller is in the kComplete state, i.e., after
97 // OnComplete().
98 void DoExit();
99
100 // Handles asynchronous requests to cancel install.
101 void DoCancel();
102
103 // Polls the COM server and advances the install state appropriately.
104 // Returns true if the caller should continue polling.
105 bool PollServer();
106
107 HRESULT result();
108
109 private:
110 enum State {
111 kInit,
112 kProcessing,
113 kComplete,
114 };
115
116 // Contains additional information about the bundle completion.
117 struct BundleCompletionInfo {
118 CompletionCodes completion_code;
119 HRESULT bundle_result; // Result to return up call stack on completion.
120 CString bundle_completion_message;
121 std::vector<AppCompletionInfo> apps_info;
122
123 BundleCompletionInfo(CompletionCodes code,
124 HRESULT result,
125 const CString& message)
126 : completion_code(code),
127 bundle_result(result),
128 bundle_completion_message(message) {}
129
130 #ifdef DEBUG
131 CString ToString() const {
132 CString result;
133 SafeCStringFormat(&result, _T("[BundleCompletionInfo][%d][0x%x][%s]"),
134 completion_code,
135 bundle_result,
136 bundle_completion_message);
137 for (size_t i = 0; i < apps_info.size(); ++i) {
138 SafeCStringAppendFormat(&result, _T("[%s]"), apps_info[i].ToString());
139 }
140 return result;
141 }
142 #endif
143 };
144
145 // Does the work for PollServer.
146 HRESULT DoPollServer();
147
148 // Performs the polling while checking for update.
149 HRESULT HandleUpdateAvailable();
150
151 // Handles the first call to PollServer().
152 HRESULT HandleInitState();
153
154 // Performs all subsequent calls to PollServer() until the state is complete.
155 HRESULT HandleProcessingState();
156
157 // Makes installer listen to the shutdown event.
158 HRESULT ListenToShutdownEvent(bool is_machine);
159
160 // Stops listening to the shutdown event if the installer is currently
161 // listening. Otherwise no effect.
162 void StopListenToShutdownEvent(bool is_machine);
163
164 // These functions update the UI during HandleProcessingState().
165 // TODO(omaha): Rename these to Notify*.
166 HRESULT NotifyUpdateAvailable(IApp* app);
167 HRESULT NotifyDownloadProgress(IApp* app, ICurrentState* icurrent_state);
168 HRESULT NotifyWaitingToInstall(IApp* app);
169 HRESULT NotifyInstallProgress(IApp* app, ICurrentState* icurrent_state);
170 HRESULT NotifyBundleUpdateCheckOnlyComplete();
171 HRESULT NotifyBundleInstallComplete();
172
173 // Helper functions for the Notify* functions.
174 HRESULT HandleUpdateCheckResults(int* num_updates);
175 void GetAppDownloadProgress(ICurrentState* icurrent_state,
176 int* time_remaining_ms,
177 int* percentage,
178 time64* next_retry_time);
179
180 void CancelBundle();
181
182 // Sets the state to complete and informs the UI.
183 void Complete(const BundleCompletionInfo& bundle_info);
184
185 BEGIN_MSG_MAP(BundleInstaller)
186 MESSAGE_HANDLER(WM_CLOSE, OnClose)
187 MESSAGE_HANDLER(WM_TIMER, OnTimer)
188 END_MSG_MAP()
189
190 static const int kPollingTimerId = 1;
191 static const int kPollingTimerPeriodMs = 100;
192
193 // The main use case for this OnClose() handler is the shutdown handler via a
194 // PostMessage in the /UA scenario.
195 LRESULT OnClose(UINT msg,
196 WPARAM wparam,
197 LPARAM lparam,
198 BOOL& handled); // NOLINT
199
200 // Calls BundleInstaller::PollServer() at periodic intervals.
201 LRESULT OnTimer(UINT msg,
202 WPARAM wparam,
203 LPARAM lparam,
204 BOOL& handled); // NOLINT
205
206 void ReleaseAppBundle();
207
208 InstallProgressObserver* observer_;
209 scoped_ptr<HelpUrlBuilder> help_url_builder_;
210
211 // The bundle to be installed.
212 CComPtr<IAppBundle> app_bundle_;
213
214 // Bundle parent window.
215 HWND parent_window_;
216
217 // Message loop that pumps messages during installation.
218 CMessageLoop message_loop_;
219
220 // Shutdown event listener.
221 scoped_ptr<ShutdownCallback> shutdown_callback_;
222
223 // The apps in app_bundle_. Allows easier and quicker access to the apps than
224 // going through app_bundle_.
225 typedef CComPtr<IApp> ComPtrIApp;
226 typedef CAdapt<ComPtrIApp> AdaptIApp;
227 std::vector<AdaptIApp> apps_;
228
229 State state_;
230 HRESULT result_;
231 bool is_canceled_;
232
233 const bool is_update_all_apps_;
234 const bool is_update_check_only_; // Only used by legacy OnDemand.
235 const bool is_browser_type_supported_;
236
237 DISALLOW_IMPLICIT_CONSTRUCTORS(BundleInstaller);
238 };
239
240 } // namespace omaha
241
242 #endif // OMAHA_CLIENT_BUNDLE_INSTALLER_H_
OLDNEW
« no previous file with comments | « client/bundle_creator_test.cc ('k') | client/bundle_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698