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

Side by Side Diff: setup/setup.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 | « setup/msi_test_utils.cc ('k') | setup/setup.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 2007-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 // There are two phases of setup. Both are done in an instance running from a
17 // temp location.
18 // 1) Copy the Google Update files to the install location.
19 // 2) Do everything else to install Google Update.
20 // * Executed by SetupGoogleUpdate().
21 //
22 // Uninstall() undoes both phases of setup.
23 // All methods assume the instance is running with the correct permissions.
24
25 #ifndef OMAHA_SETUP_SETUP_H__
26 #define OMAHA_SETUP_SETUP_H__
27
28 #include <windows.h>
29 #include <atlstr.h>
30 #include <vector>
31 #include "base/basictypes.h"
32 #include "base/scoped_ptr.h"
33 #include "omaha/base/scoped_any.h"
34
35 namespace omaha {
36
37 class GLock;
38 class HighresTimer;
39 struct NamedObjectAttributes;
40
41 class SetupFiles;
42
43 class Setup {
44 public:
45 explicit Setup(bool is_machine);
46 ~Setup();
47
48 // Installs Omaha if necessary.
49 HRESULT Install(bool set_keepalive);
50
51 // Acquires the Setup Lock and uninstalls all Omaha versions if Omaha can be
52 // uninstalled.
53 HRESULT Uninstall(bool send_uninstall_ping);
54
55 // Verifies that Omaha is either properly installed or uninstalled completely.
56 // TODO(omaha): Consider making this and did_uninstall_ non-static after
57 // refactoring Setup phases. May require a Setup member in Goopdate.
58 static void CheckInstallStateConsistency(bool is_machine);
59
60 int extra_code1() const { return extra_code1_; }
61
62 void set_is_self_update(bool is_self_update) {
63 is_self_update_ = is_self_update;
64 }
65
66 private:
67 typedef std::vector<uint32> Pids;
68
69 // Completes installation.
70 HRESULT SetupGoogleUpdate();
71
72 // Handles Setup lock acquisition failures and returns the error to report.
73 HRESULT HandleLockFailed(int lock_version);
74
75 // Does the install work within all necessary locks, which have already been
76 // acquired.
77 HRESULT DoProtectedInstall(bool set_keepalive);
78
79 // Uninstalls all Google Update versions after checking if Google Update can
80 // be uninstalled.
81 HRESULT DoProtectedUninstall(bool send_uninstall_ping);
82
83 // Returns whether Google Update should be installed.
84 bool ShouldInstall(SetupFiles* setup_files);
85
86 // Returns whether the same version of Google Update should be over-installed.
87 bool ShouldOverinstallSameVersion(SetupFiles* setup_files);
88
89 HRESULT DoProtectedGoogleUpdateInstall(SetupFiles* setup_files);
90
91 // Rolls back the changes made during DoProtectedGoogleUpdateInstall().
92 // Call when that method fails.
93 void RollBack(SetupFiles* setup_files);
94
95 // Tells other instances to stop.
96 HRESULT StopGoogleUpdate();
97
98 // Tells other instances to stop then waits for them to exit.
99 HRESULT StopGoogleUpdateAndWait();
100
101 // Sets the shutdown event to signal other instances for this user or machine
102 // to exit.
103 HRESULT SignalShutdownEvent();
104
105 // Releases all the shutdown events.
106 void ReleaseShutdownEvents();
107
108 // Waits for other instances of GoogleUpdate.exe to exit.
109 HRESULT WaitForOtherInstancesToExit(const Pids& pids);
110
111 // Gets the list of all the GoogleUpdate.exe processes to wait for.
112 HRESULT GetPidsToWaitFor(Pids* pids) const;
113
114 // Gets a list of GoogleUpdate.exe processes for user or machine that are
115 // running from the respective official directory, except "/install" or
116 // "/registerproduct" instances.
117 // In the machine case we search in all the accounts since the workers can be
118 // running in any admin account and the machine update worker runs as SYSTEM.
119 // In the user case, we only search the user's account.
120 // In both cases, the command line location is used to determine the
121 // machine/user cases.
122 HRESULT GetPidsToWaitForUsingCommandLine(Pids* pids) const;
123
124 // Returns whether elevation is required to perform this install.
125 bool IsElevationRequired() const;
126
127 // TODO(omaha3): Support offline builds. Prefer to detect and maybe copy outside
128 // Setup.
129 #if 0
130 // Given a guid, finds and copies the offline manifest and binaries from the
131 // current module directory to the offline_dir passed in. offline_dir is
132 // typically the Google\Update\Offline\ directory. The offline manifest is
133 // copied to offline_dir\{GUID}.gup. The binaries are in the format
134 // "Installer.msi.{GUID}", and they are copied to the offline_dir under the
135 // subdirectory {GUID}, as Installer.msi.
136 static HRESULT CopyOfflineFilesForGuid(const CString& app_guid,
137 const CString& offline_dir);
138
139 // For all the applications that have been requested, copy the offline
140 // binaries. Calls CopyOfflineFilesForGuid() for each app_guid.
141 bool CopyOfflineFiles(const CString& offline_dir);
142 #endif
143
144 // Starts the core.
145 HRESULT StartMachineCoreProcess() const;
146 HRESULT StartUserCoreProcess(const CString& core_cmd_line) const;
147
148 // Returns the pids of running Omaha 2 Core processes for this user/system.
149 HRESULT FindCoreProcesses(Pids* found_core_pids) const;
150
151 // Forcefully kills appropriate core processes using ::TerminateProcess().
152 HRESULT TerminateCoreProcesses() const;
153
154 // Verifies that the appropriate core is running.
155 bool IsCoreProcessRunning() const;
156
157 // Starts the long-lived Core process.
158 HRESULT StartCore() const;
159
160 // Returns the SID to use for process searches, mutexes, etc. during this
161 // installation.
162 HRESULT GetAppropriateSid(CString* sid) const;
163
164 // Initializes the Setup Lock with correct name and security attributes.
165 static bool InitSetupLock(bool is_machine, GLock* setup_lock);
166
167 // Returns true if GoogleUpdate can be uninstalled now.
168 bool CanUninstallGoogleUpdate() const;
169
170 // Control the state of the DelayUninstall flag. If set, uninstall will
171 // be delayed for at least 24 hours after initial install.
172 bool ShouldDelayUninstall() const;
173 HRESULT SetDelayUninstall(bool should_delay) const;
174
175 // Sends the uninstall ping and waits for the ping to be sent.
176 HRESULT SendUninstallPing();
177
178 const bool is_machine_;
179 bool is_self_update_;
180 CString saved_version_; // Previous version saved for roll back.
181 scoped_event shutdown_event_;
182 int extra_code1_;
183
184 scoped_ptr<HighresTimer> metrics_timer_;
185
186 // Whether this process uninstalled Google Update for any reason.
187 // Access must be protected by the Setup Lock.
188 static bool did_uninstall_;
189
190 friend class SetupTest;
191 friend class SetupOfflineInstallerTest;
192 DISALLOW_EVIL_CONSTRUCTORS(Setup);
193 };
194
195 } // namespace omaha
196
197 #endif // OMAHA_SETUP_SETUP_H__
198
OLDNEW
« no previous file with comments | « setup/msi_test_utils.cc ('k') | setup/setup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698