blob: 2cfc1a3c170b09b87ec2ccb51d17c1f071f2681c [file] [log] [blame]
mukesh agrawal46c27cc2013-07-10 16:39:10 -07001// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "shill/result_aggregator.h"
6
7#include "shill/logging.h"
8
9namespace shill {
10
11ResultAggregator::ResultAggregator(const ResultCallback &callback)
12 : callback_(callback), got_result_(false) {
13 CHECK(!callback.is_null());
14}
15
16ResultAggregator::~ResultAggregator() {
17 if (got_result_) {
18 callback_.Run(error_);
19 }
20}
21
22void ResultAggregator::ReportResult(const Error &error) {
23 CHECK(!error.IsOngoing()); // We want the final result.
24 got_result_ = true;
25 if (error_.IsSuccess()) { // Only copy first |error|.
26 error_.CopyFrom(error);
27 }
28}
29
30} // namespace shill