blob: e2dbbec3ab9f89744c3f444764938d86cf119cd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// 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.
#include "chrome/installer/util/callback_work_item.h"
#include "base/callback.h"
#include "base/logging.h"
#include "chrome/installer/util/work_item.h"
CallbackWorkItem::CallbackWorkItem(
base::Callback<bool(const CallbackWorkItem&)> callback)
: callback_(callback),
roll_state_(RS_UNDEFINED) {
}
CallbackWorkItem::~CallbackWorkItem() {
}
bool CallbackWorkItem::Do() {
DCHECK_EQ(roll_state_, RS_UNDEFINED);
roll_state_ = RS_FORWARD;
bool result = callback_.Run(*this);
roll_state_ = RS_UNDEFINED;
return result;
}
void CallbackWorkItem::Rollback() {
DCHECK_EQ(roll_state_, RS_UNDEFINED);
roll_state_ = RS_BACKWARD;
ignore_result(callback_.Run(*this));
roll_state_ = RS_UNDEFINED;
}
bool CallbackWorkItem::IsRollback() const {
DCHECK_NE(roll_state_, RS_UNDEFINED);
return roll_state_ == RS_BACKWARD;
}
|