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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/setup/update_active_setup_version_work_item.h
diff --git a/chrome/installer/setup/update_active_setup_version_work_item.h b/chrome/installer/setup/update_active_setup_version_work_item.h
new file mode 100644
index 0000000000000000000000000000000000000000..50820a0ea99438938f81a11deab18511572724e6
--- /dev/null
+++ b/chrome/installer/setup/update_active_setup_version_work_item.h
@@ -0,0 +1,69 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_INSTALLER_SETUP_UPDATE_ACTIVE_SETUP_VERSION_WORK_ITEM_H_
+#define CHROME_INSTALLER_SETUP_UPDATE_ACTIVE_SETUP_VERSION_WORK_ITEM_H_
+
+#include "base/macros.h"
+#include "base/strings/string16.h"
+#include "chrome/installer/util/set_reg_value_work_item.h"
+#include "chrome/installer/util/work_item.h"
+
+// A WorkItem that updates (or installs if not present) the Active Setup
+// "Version" field in the registry. Optionally bumping the OS_UPGRADES component
+// on demand. This WorkItem is only viable on machine-wide installs.
+// 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.
+// embedded a SetRegValueWorkItem instead of being one, but this is not possible
+// in today's "private constructor + creator friends" WorkItem model :-(.
+class UpdateActiveSetupVersionWorkItem : public WorkItem {
+ public:
+ // The operation to be performed by this UpdateActiveSetupVersionWorkItem.
+ enum Operation {
+ // Update (or install if not present) the Active Setup "Version" in the
+ // registry.
+ UPDATE,
+ // Also bump the OS_UPGRADES component on top of updating the version
+ // (will default to 1 if the version was absent or invalid).
+ UPDATE_AND_BUMP_OS_UPGRADES_COMPONENT,
+ };
+
+ // Constructs an UpdateActiveSetupVersionWorkItem that will perform
+ // |operation| on the |active_setup_path| key in the registry. This key needs
+ // to exist when this WorkItem is ran.
+ UpdateActiveSetupVersionWorkItem(const base::string16& active_setup_path,
+ Operation operation);
+
+ // Overriden from WorkItem.
+ bool Do() override;
+ void Rollback() override;
+
+ private:
+ // The components of the Active Setup Version entry, in order.
+ enum ActiveSetupVersionComponent {
+ // The major version.
+ MAJOR,
+ // Unused component, always 0 for now.
+ UNUSED1,
+ // Number of OS upgrades handled since original install.
+ OS_UPGRADES,
+ // Unused component, always 0 for now.
+ UNUSED2,
+ };
+
+ // Returns the updated Active Setup version to be used based on the
+ // |existing_version|.
+ base::string16 GetUpdatedActiveSetupVersion(
+ const base::string16& existing_version);
+
+ // The underlying WorkItem re-used to operate forward and backward on the
+ // registry.
+ SetRegValueWorkItem set_reg_value_work_item_;
+
+ // The Operation to be performed by this WorkItem when executed.
+ const Operation operation_;
+
+ DISALLOW_COPY_AND_ASSIGN(UpdateActiveSetupVersionWorkItem);
+};
+
+#endif // CHROME_INSTALLER_SETUP_UPDATE_ACTIVE_SETUP_VERSION_WORK_ITEM_H_

Powered by Google App Engine
This is Rietveld 408576698