Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: src/byte_counter.h

Issue 5180003: cashew: add local byte counters (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Address jglasgow and zelidrag (offline) code review comments Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/Makefile.am ('k') | src/byte_counter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « src/Makefile.am ('k') | src/byte_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698