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

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

Issue 1223953003: Introduce UpdateActiveSetupVersionWorkItem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a1_active_setup_onosup_addCB_API
Patch Set: Composition instead of inheritance Created 5 years, 5 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_INSTALLER_SETUP_UPDATE_ACTIVE_SETUP_VERSION_WORK_ITEM_H_
6 #define CHROME_INSTALLER_SETUP_UPDATE_ACTIVE_SETUP_VERSION_WORK_ITEM_H_
7
8 #include "base/macros.h"
9 #include "base/strings/string16.h"
10 #include "chrome/installer/util/set_reg_value_work_item.h"
11 #include "chrome/installer/util/work_item.h"
12
13 // A WorkItem that updates (or installs if not present) the Active Setup
14 // "Version" field in the registry. Optionally bumping the OS_UPGRADES component
15 // on demand. This WorkItem is only viable on machine-wide installs.
16 // TODO(gab): This would be cleaner if UpdateActiveSetupVersionWorkItem
grt (UTC plus 2) 2015/07/13 16:47:04 nit: stale comment
gab 2015/07/13 16:58:01 Oops, done.
17 // embedded a SetRegValueWorkItem instead of being one, but this is not possible
18 // in today's "private constructor + creator friends" WorkItem model :-(.
19 class UpdateActiveSetupVersionWorkItem : public WorkItem {
20 public:
21 // The operation to be performed by this UpdateActiveSetupVersionWorkItem.
22 enum Operation {
23 // Update (or install if not present) the Active Setup "Version" in the
24 // registry.
25 UPDATE,
26 // Also bump the OS_UPGRADES component on top of updating the version
27 // (will default to 1 if the version was absent or invalid).
28 UPDATE_AND_BUMP_OS_UPGRADES_COMPONENT,
29 };
30
31 // Constructs an UpdateActiveSetupVersionWorkItem that will perform
32 // |operation| on the |active_setup_path| key in the registry. This key needs
33 // to exist when this WorkItem is ran.
34 UpdateActiveSetupVersionWorkItem(const base::string16& active_setup_path,
35 Operation operation);
36
37 // Overriden from WorkItem.
38 bool Do() override;
39 void Rollback() override;
40
41 private:
42 // The components of the Active Setup Version entry, in order.
43 enum ActiveSetupVersionComponent {
44 // The major version.
45 MAJOR,
46 // Unused component, always 0 for now.
47 UNUSED1,
48 // Number of OS upgrades handled since original install.
49 OS_UPGRADES,
50 // Unused component, always 0 for now.
51 UNUSED2,
52 };
53
54 // Returns the updated Active Setup version to be used based on the
55 // |existing_version|.
56 base::string16 GetUpdatedActiveSetupVersion(
57 const base::string16& existing_version);
58
59 // The underlying WorkItem re-used to operate forward and backward on the
60 // registry.
61 SetRegValueWorkItem set_reg_value_work_item_;
62
63 // The Operation to be performed by this WorkItem when executed.
64 const Operation operation_;
65
66 DISALLOW_COPY_AND_ASSIGN(UpdateActiveSetupVersionWorkItem);
67 };
68
69 #endif // CHROME_INSTALLER_SETUP_UPDATE_ACTIVE_SETUP_VERSION_WORK_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698