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

Unified Diff: chrome/browser/chromeos/cros_network_library.h

Issue 315008: New wifi icons animation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months 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
Index: chrome/browser/chromeos/cros_network_library.h
===================================================================
--- chrome/browser/chromeos/cros_network_library.h (revision 30284)
+++ chrome/browser/chromeos/cros_network_library.h (working copy)
@@ -12,6 +12,8 @@
#include "base/platform_thread.h"
#include "base/singleton.h"
#include "base/string16.h"
+#include "base/timer.h"
+#include "net/url_request/url_request_job_tracker.h"
#include "third_party/cros/chromeos_network.h"
struct WifiNetwork {
@@ -51,11 +53,22 @@
// This class handles the interaction with the ChromeOS network library APIs.
// Classes can add themselves as observers. Users can get an instance of this
// library class like this: CrosNetworkLibrary::Get()
-class CrosNetworkLibrary {
+class CrosNetworkLibrary : public URLRequestJobTracker::JobObserver {
public:
class Observer {
public:
+ // A bitfield mask for traffic types.
+ enum TrafficTypes {
+ TRAFFIC_DOWNLOAD = 0x1,
+ TRAFFIC_UPLOAD = 0x2,
+ } TrafficTypeMasks;
+
+ // Called when the network has changed. (wifi networks, and ethernet)
virtual void NetworkChanged(CrosNetworkLibrary* obj) = 0;
+
+ // Called when network traffic has been detected.
+ // Takes a bitfield of TrafficTypeMasks.
+ virtual void NetworkTraffic(CrosNetworkLibrary* obj, int traffic_type) = 0;
};
// This gets the singleton CrosNetworkLibrary
@@ -64,6 +77,14 @@
// Returns true if the ChromeOS library was loaded.
static bool loaded();
+ // URLRequestJobTracker::JobObserver methods (called on the IO thread):
+ virtual void OnJobAdded(URLRequestJob* job);
+ virtual void OnJobRemoved(URLRequestJob* job);
+ virtual void OnJobDone(URLRequestJob* job, const URLRequestStatus& status);
+ virtual void OnJobRedirect(URLRequestJob* job, const GURL& location,
+ int status_code);
+ virtual void OnBytesRead(URLRequestJob* job, int byte_count);
+
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
@@ -104,8 +125,35 @@
void UpdateNetworkStatus(const WifiNetworkVector& networks,
bool ethernet_connected);
+ // Checks network traffic to see if there is any uploading.
+ // If there is download traffic, then true is passed in for download.
+ // If there is network traffic then start timer that invokes
+ // NetworkTrafficTimerFired.
+ void CheckNetworkTraffic(bool download);
+
+ // Called when the timer fires and we need to send out NetworkTraffic
+ // notifications.
+ void NetworkTrafficTimerFired();
+
+ // This is a helper method to notify the observers on the UI thread.
+ void NotifyNetworkTraffic(int traffic_type);
+
+ // This will notify all obeservers on the UI thread.
+ void NotifyObservers();
+
ObserverList<Observer> observers_;
+ // The amount of time to wait between each NetworkTraffic notifications.
+ static const int kNetworkTrafficeTimerSecs;
+
+ // Timer for sending NetworkTraffic notification every
+ // kNetworkTrafficeTimerSecs seconds.
+ base::OneShotTimer<CrosNetworkLibrary> timer_;
+
+ // The current traffic type that will be sent out for the next NetworkTraffic
+ // notification. This is a bitfield of TrafficTypeMasks.
+ int traffic_type_;
+
// The network status connection for monitoring network status changes.
chromeos::NetworkStatusConnection network_status_connection_;

Powered by Google App Engine
This is Rietveld 408576698