OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 #ifndef SRC_BYTE_COUNTER_H_ | 5 #ifndef SRC_BYTE_COUNTER_H_ |
6 #define SRC_BYTE_COUNTER_H_ | 6 #define SRC_BYTE_COUNTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include <base/basictypes.h> // NOLINT | 10 #include <base/basictypes.h> // NOLINT |
11 | 11 |
12 namespace cashew { | 12 namespace cashew { |
13 | 13 |
14 class ByteCounterDelegate; | 14 class ByteCounterDelegate; |
15 | 15 |
16 // interface for byte counter | 16 // interface for byte counter |
17 class ByteCounter { | 17 class ByteCounter { |
18 public: | 18 public: |
19 virtual ~ByteCounter() {} | 19 virtual ~ByteCounter() {} |
20 | 20 |
21 // to what interface is this counter attached? | 21 // to what interface is this counter attached? |
22 virtual const std::string& GetInterface() const = 0; | 22 virtual const std::string& GetInterface() const = 0; |
23 | 23 |
24 // received bytes | 24 // received bytes |
25 virtual uint64 GetRxBytes() const = 0; | 25 virtual uint64 GetRxBytes() const = 0; |
| 26 virtual void SetRxBytes(uint64 rx_bytes) = 0; |
26 | 27 |
27 // transmitted bytes | 28 // transmitted bytes |
28 virtual uint64 GetTxBytes() const = 0; | 29 virtual uint64 GetTxBytes() const = 0; |
| 30 virtual void SetTxBytes(uint64 tx_bytes) = 0; |
29 | 31 |
30 // set delegate interface that will receive counter updates | 32 // set delegate interface that will receive counter updates |
31 // it's ok to clear this by setting it to NULL | 33 // it's ok to clear this by setting it to NULL |
32 virtual void SetDelegate(ByteCounterDelegate *delegate) = 0; | 34 virtual void SetDelegate(ByteCounterDelegate *delegate) = 0; |
33 | 35 |
34 // factory | 36 // factory |
35 // return appropriate concrete impl | 37 // return appropriate concrete impl |
36 // caller owns returned ByteCounter and is responsible for deleting it | 38 // caller owns returned ByteCounter and is responsible for deleting it |
37 static ByteCounter* NewByteCounter(const std::string& interface); | 39 static ByteCounter* NewByteCounter(const std::string& interface); |
38 }; | 40 }; |
39 | 41 |
40 // interface for delegates | 42 // interface to be implemented by delegates |
41 class ByteCounterDelegate { | 43 class ByteCounterDelegate { |
42 public: | 44 public: |
43 virtual ~ByteCounterDelegate() {} | 45 virtual ~ByteCounterDelegate() {} |
44 | 46 |
45 // called when byte counter is updated | 47 // called when byte counter is updated |
46 virtual void OnByteCounterUpdate(const ByteCounter *counter, | 48 virtual void OnByteCounterUpdate(const ByteCounter *counter, |
47 uint64 rx_bytes, uint64 tx_bytes) = 0; | 49 uint64 rx_bytes, uint64 tx_bytes) = 0; |
48 }; | 50 }; |
49 | 51 |
50 } // namespace cashew | 52 } // namespace cashew |
51 | 53 |
52 #endif // SRC_BYTE_COUNTER_H_ | 54 #endif // SRC_BYTE_COUNTER_H_ |
OLD | NEW |