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

Side by Side Diff: chrome/installer/setup/setup_singleton.h

Issue 2333853002: Support --delete-old-versions in setup.exe. (Closed)
Patch Set: CR grt/rkaplow #8-9 Created 4 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 | « chrome/installer/setup/setup_main.cc ('k') | chrome/installer/setup/setup_singleton.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_INSTALLER_SETUP_SETUP_SINGLETON_H_ 5 #ifndef CHROME_INSTALLER_SETUP_SETUP_SINGLETON_H_
6 #define CHROME_INSTALLER_SETUP_SETUP_SINGLETON_H_ 6 #define CHROME_INSTALLER_SETUP_SETUP_SINGLETON_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 InstallationState* original_state, 42 InstallationState* original_state,
43 InstallerState* installer_state); 43 InstallerState* installer_state);
44 44
45 // Releases the exclusive right to modify the Chrome installation. 45 // Releases the exclusive right to modify the Chrome installation.
46 ~SetupSingleton(); 46 ~SetupSingleton();
47 47
48 // Waits until |max_time| has passed or another process tries to acquire a 48 // Waits until |max_time| has passed or another process tries to acquire a
49 // SetupSingleton for the same Chrome installation. In the latter case, the 49 // SetupSingleton for the same Chrome installation. In the latter case, the
50 // method returns true and this SetupSingleton should be released as soon as 50 // method returns true and this SetupSingleton should be released as soon as
51 // possible to unblock the other process. 51 // possible to unblock the other process.
52 bool WaitForInterrupt(const base::TimeDelta& max_time); 52 bool WaitForInterrupt(const base::TimeDelta& max_time) const;
53 53
54 private: 54 private:
55 class ScopedHoldMutex { 55 class ScopedHoldMutex {
56 public: 56 public:
57 ScopedHoldMutex(); 57 ScopedHoldMutex();
58 ~ScopedHoldMutex(); 58 ~ScopedHoldMutex();
59 59
60 // Waits up to a certain amount of time to acquire |mutex|. Returns true on 60 // Waits up to a certain amount of time to acquire |mutex|. Returns true on
61 // success. |mutex| will be released in the destructor. 61 // success. |mutex| will be released in the destructor.
62 bool Acquire(HANDLE mutex); 62 bool Acquire(HANDLE mutex);
63 63
64 private: 64 private:
65 HANDLE mutex_ = INVALID_HANDLE_VALUE; 65 HANDLE mutex_ = INVALID_HANDLE_VALUE;
66 66
67 DISALLOW_COPY_AND_ASSIGN(ScopedHoldMutex); 67 DISALLOW_COPY_AND_ASSIGN(ScopedHoldMutex);
68 }; 68 };
69 69
70 SetupSingleton(base::win::ScopedHandle setup_mutex, 70 SetupSingleton(base::win::ScopedHandle setup_mutex,
71 base::win::ScopedHandle exit_event); 71 base::win::ScopedHandle exit_event);
72 72
73 // A mutex that must be held to modify the Chrome installation directory. 73 // A mutex that must be held to modify the Chrome installation directory.
74 base::win::ScopedHandle setup_mutex_; 74 base::win::ScopedHandle setup_mutex_;
75 75
76 // Holds |setup_mutex_| throughout the lifetime of this SetupSingleton. 76 // Holds |setup_mutex_| throughout the lifetime of this SetupSingleton.
77 ScopedHoldMutex scoped_hold_setup_mutex_; 77 ScopedHoldMutex scoped_hold_setup_mutex_;
78 78
79 // An event signaled to ask the owner of |setup_mutex_| to release it as soon 79 // An event signaled to ask the owner of |setup_mutex_| to release it as soon
80 // as possible. 80 // as possible.
81 base::WaitableEvent exit_event_; 81 mutable base::WaitableEvent exit_event_;
82 82
83 DISALLOW_COPY_AND_ASSIGN(SetupSingleton); 83 DISALLOW_COPY_AND_ASSIGN(SetupSingleton);
84 }; 84 };
85 85
86 } // namespace installer 86 } // namespace installer
87 87
88 #endif // CHROME_INSTALLER_SETUP_SETUP_SINGLETON_H_ 88 #endif // CHROME_INSTALLER_SETUP_SETUP_SINGLETON_H_
OLDNEW
« no previous file with comments | « chrome/installer/setup/setup_main.cc ('k') | chrome/installer/setup/setup_singleton.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698