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

Unified Diff: chrome/installer/util/callback_work_item.h

Issue 10916018: Force COM machinery to notice that the path to the DelegateExecute verb handler has changed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed robert's comments Created 8 years, 4 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
« no previous file with comments | « chrome/installer/setup/install_worker.cc ('k') | chrome/installer/util/callback_work_item.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/callback_work_item.h
diff --git a/chrome/installer/util/callback_work_item.h b/chrome/installer/util/callback_work_item.h
new file mode 100644
index 0000000000000000000000000000000000000000..f843de62fd861ec5663f2fad77842b6e9167736b
--- /dev/null
+++ b/chrome/installer/util/callback_work_item.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2012 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_UTIL_CALLBACK_WORK_ITEM_H_
+#define CHROME_INSTALLER_UTIL_CALLBACK_WORK_ITEM_H_
+
+#include "base/callback.h"
+#include "base/compiler_specific.h"
+#include "base/gtest_prod_util.h"
+#include "chrome/installer/util/work_item.h"
+
+// A work item that invokes a callback on Do() and Rollback(). In the following
+// example, the function SomeWorkItemCallback() will be invoked when an item
+// list is processed.
+//
+// // A callback invoked to do some work.
+// bool SomeWorkItemCallback(const CallbackWorkItem& item) {
+// if (item.IsRollback()) {
+// // Rollback work goes here. The return value is ignored in this case.
+// return true;
+// }
+//
+// // Roll forward work goes here. The return value indicates success/failure
+// // of the item.
+// return true;
+// }
+//
+// void SomeFunctionThatAddsItemsToAList(WorkItemList* item_list) {
+// ...
+// item_list->AddCallbackWorkItem(base::Bind(&SomeWorkItemCallback));
+// ...
+// }
+class CallbackWorkItem : public WorkItem {
+ public:
+ virtual ~CallbackWorkItem();
+
+ virtual bool Do() OVERRIDE;
+ virtual void Rollback() OVERRIDE;
+
+ bool IsRollback() const;
+
+ private:
+ friend class WorkItem;
+
+ enum RollState {
+ RS_UNDEFINED,
+ RS_FORWARD,
+ RS_BACKWARD,
+ };
+
+ CallbackWorkItem(base::Callback<bool(const CallbackWorkItem&)> callback);
+
+ base::Callback<bool(const CallbackWorkItem&)> callback_;
+ RollState roll_state_;
+
+ FRIEND_TEST_ALL_PREFIXES(CallbackWorkItemTest, TestFailure);
+ FRIEND_TEST_ALL_PREFIXES(CallbackWorkItemTest, TestForwardBackward);
+};
+
+#endif // CHROME_INSTALLER_UTIL_CALLBACK_WORK_ITEM_H_
« no previous file with comments | « chrome/installer/setup/install_worker.cc ('k') | chrome/installer/util/callback_work_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698