OLD | NEW |
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::DoImpl() { | 20 bool CallbackWorkItem::Do() { |
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::RollbackImpl() { | 30 void CallbackWorkItem::Rollback() { |
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 } |
OLD | NEW |