| Index: blimp/net/blimp_connection_details.h
|
| diff --git a/blimp/net/blimp_connection_details.h b/blimp/net/blimp_connection_details.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cbd545b2ee1e21ac8d243486f8a98e30c35991fe
|
| --- /dev/null
|
| +++ b/blimp/net/blimp_connection_details.h
|
| @@ -0,0 +1,75 @@
|
| +// Copyright 2016 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.
|
| +
|
| +#ifndef BLIMP_NET_BLIMP_CONNECTION_DETAILS_H_
|
| +#define BLIMP_NET_BLIMP_CONNECTION_DETAILS_H_
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "blimp/net/blimp_net_export.h"
|
| +
|
| +namespace blimp {
|
| +
|
| +/**
|
| + * Observer to be notified in the event of network activities. Observer methods
|
| + * are to be called on UI thread.
|
| + */
|
| +class NetworkActivityObserver {
|
| + public:
|
| + virtual void UpdateDebugInfo(int received, int sent, int commits) = 0;
|
| +};
|
| +
|
| +// Collects network traffic statistics. Maintains a counter for number of
|
| +// completed commits, bytes sent and received over network and notifies its
|
| +// observers on the main thread. Presents the data on a per navigation basis.
|
| +// This class is supposed to live an entire session, created and destroyed along
|
| +// it.
|
| +class BLIMP_NET_EXPORT BlimpConnectionDetails {
|
| + public:
|
| + BlimpConnectionDetails(
|
| + base::WeakPtr<NetworkActivityObserver> observer,
|
| + const scoped_refptr<base::TaskRunner>& main_thread_task_runner,
|
| + const scoped_refptr<base::TaskRunner>& io_thread_task_runner);
|
| +
|
| + ~BlimpConnectionDetails();
|
| +
|
| + void EnableDebugInfo(bool enable);
|
| +
|
| + // Called on the IO thread.
|
| + void OnPacketReceived(int bytes);
|
| +
|
| + // Called on the IO thread.
|
| + void OnPacketSent(int bytes);
|
| +
|
| + // Called on the main thread.
|
| + void OnCommit();
|
| +
|
| + // Called on the main thread.
|
| + void ResetStats();
|
| +
|
| + private:
|
| + void ResetStatsOnIOThread();
|
| +
|
| + // Flag to show/hide the debug data on blimp view.
|
| + bool debug_info_enabled_;
|
| +
|
| + // Total number of bytes sent/received during a navigation. Accessed on IO
|
| + // thread.
|
| + int bytes_received_;
|
| + int bytes_sent_;
|
| +
|
| + // Total number of commits completed on the client. Accessed on main thread.
|
| + int commits_;
|
| +
|
| + base::WeakPtr<NetworkActivityObserver> observer_;
|
| + scoped_refptr<base::TaskRunner> main_thread_task_runner_;
|
| + scoped_refptr<base::TaskRunner> io_thread_task_runner_;
|
| + base::WeakPtrFactory<BlimpConnectionDetails> weak_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(BlimpConnectionDetails);
|
| +};
|
| +
|
| +} // namespace blimp
|
| +
|
| +#endif // BLIMP_NET_BLIMP_CONNECTION_DETAILS_H_
|
|
|