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

Side by Side Diff: chrome/installer/util/callback_work_item.cc

Issue 1882923003: Add best-effort/allow rollback flags on WorkItem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simple_list_tests
Patch Set: fix build error Created 4 years, 7 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/installer/util/callback_work_item.h" 5 #include "chrome/installer/util/callback_work_item.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/installer/util/work_item.h" 9 #include "chrome/installer/util/work_item.h"
10 10
11 CallbackWorkItem::CallbackWorkItem( 11 CallbackWorkItem::CallbackWorkItem(
12 base::Callback<bool(const CallbackWorkItem&)> callback) 12 base::Callback<bool(const CallbackWorkItem&)> callback)
13 : callback_(callback), 13 : callback_(callback),
14 roll_state_(RS_UNDEFINED) { 14 roll_state_(RS_UNDEFINED) {
15 } 15 }
16 16
17 CallbackWorkItem::~CallbackWorkItem() { 17 CallbackWorkItem::~CallbackWorkItem() {
18 } 18 }
19 19
20 bool CallbackWorkItem::Do() { 20 bool CallbackWorkItem::DoImpl() {
21 DCHECK_EQ(roll_state_, RS_UNDEFINED); 21 DCHECK_EQ(roll_state_, RS_UNDEFINED);
22 22
23 roll_state_ = RS_FORWARD; 23 roll_state_ = RS_FORWARD;
24 bool result = callback_.Run(*this); 24 bool result = callback_.Run(*this);
25 roll_state_ = RS_UNDEFINED; 25 roll_state_ = RS_UNDEFINED;
26 26
27 return result; 27 return result;
28 } 28 }
29 29
30 void CallbackWorkItem::Rollback() { 30 void CallbackWorkItem::RollbackImpl() {
31 DCHECK_EQ(roll_state_, RS_UNDEFINED); 31 DCHECK_EQ(roll_state_, RS_UNDEFINED);
32 32
33 roll_state_ = RS_BACKWARD; 33 roll_state_ = RS_BACKWARD;
34 ignore_result(callback_.Run(*this)); 34 ignore_result(callback_.Run(*this));
35 roll_state_ = RS_UNDEFINED; 35 roll_state_ = RS_UNDEFINED;
36 } 36 }
37 37
38 bool CallbackWorkItem::IsRollback() const { 38 bool CallbackWorkItem::IsRollback() const {
39 DCHECK_NE(roll_state_, RS_UNDEFINED); 39 DCHECK_NE(roll_state_, RS_UNDEFINED);
40 return roll_state_ == RS_BACKWARD; 40 return roll_state_ == RS_BACKWARD;
41 } 41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698