| Index: src/byte_counter.h
|
| diff --git a/src/byte_counter.h b/src/byte_counter.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f9346071dfad1c032e18159819d94467af369fa1
|
| --- /dev/null
|
| +++ b/src/byte_counter.h
|
| @@ -0,0 +1,52 @@
|
| +// Copyright (c) 2010 The Chromium OS 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 SRC_BYTE_COUNTER_H_
|
| +#define SRC_BYTE_COUNTER_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include <base/basictypes.h> // NOLINT
|
| +
|
| +namespace cashew {
|
| +
|
| +class ByteCounterDelegate;
|
| +
|
| +// interface for byte counter
|
| +class ByteCounter {
|
| + public:
|
| + virtual ~ByteCounter() {}
|
| +
|
| + // to what interface is this counter attached?
|
| + virtual const std::string& GetInterface() const = 0;
|
| +
|
| + // received bytes
|
| + virtual uint64 GetRxBytes() const = 0;
|
| +
|
| + // transmitted bytes
|
| + virtual uint64 GetTxBytes() const = 0;
|
| +
|
| + // set delegate interface that will receive counter updates
|
| + // it's ok to clear this by setting it to NULL
|
| + virtual void SetDelegate(ByteCounterDelegate *delegate) = 0;
|
| +
|
| + // factory
|
| + // return appropriate concrete impl
|
| + // caller owns returned ByteCounter and is responsible for deleting it
|
| + static ByteCounter* NewByteCounter(const std::string& interface);
|
| +};
|
| +
|
| +// interface for delegates
|
| +class ByteCounterDelegate {
|
| + public:
|
| + virtual ~ByteCounterDelegate() {}
|
| +
|
| + // called when byte counter is updated
|
| + virtual void OnByteCounterUpdate(const ByteCounter *counter,
|
| + uint64 rx_bytes, uint64 tx_bytes) = 0;
|
| +};
|
| +
|
| +} // namespace cashew
|
| +
|
| +#endif // SRC_BYTE_COUNTER_H_
|
|
|