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

Unified Diff: chrome/browser/chromeos/extensions/networking_private_event_router.h

Issue 12188027: This adds the onNetworkChanged event to networkingPrivate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing virtual keyword Created 7 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/networking_private_event_router.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/extensions/networking_private_event_router.h
diff --git a/chrome/browser/chromeos/extensions/networking_private_event_router.h b/chrome/browser/chromeos/extensions/networking_private_event_router.h
new file mode 100644
index 0000000000000000000000000000000000000000..46c8ffa62c84b0e84f0822616d6614976e739ae9
--- /dev/null
+++ b/chrome/browser/chromeos/extensions/networking_private_event_router.h
@@ -0,0 +1,54 @@
+// Copyright (c) 2013 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 CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_EVENT_ROUTER_H_
+#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_EVENT_ROUTER_H_
+
+#include "chrome/browser/extensions/event_router.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+#include "chromeos/network/network_state_handler_observer.h"
+
+class Profile;
+
+namespace chromeos {
+
+// This is a factory class used by the ProfileDependencyManager to instantiate
+// the event router that will forward events from the NetworkStateHandler to the
+// JavaScript Networking API.
+class NetworkingPrivateEventRouter : public ProfileKeyedService,
+ public extensions::EventRouter::Observer,
+ public NetworkStateHandlerObserver {
+ public:
+ explicit NetworkingPrivateEventRouter(Profile* profile);
+ virtual ~NetworkingPrivateEventRouter();
+
+ protected:
+ // ProfileKeyedService overrides:
+ virtual void Shutdown() OVERRIDE;
+
+ // EventRouter::Observer overrides:
+ virtual void OnListenerAdded(
+ const extensions::EventListenerInfo& details) OVERRIDE;
+ virtual void OnListenerRemoved(
+ const extensions::EventListenerInfo& details) OVERRIDE;
+
+ // NetworkStateHandlerObserver overrides:
+ virtual void NetworkListChanged(const NetworkStateList& networks) OVERRIDE;
+
+ private:
+ // Decide if we should listen for network changes or not. If there are any
+ // JavaScript listeners registered for the onNetworkChanged event, then we
+ // want to register for change notification from the network state handler.
+ // Otherwise, we want to unregister and not be listening to network changes.
+ void StartOrStopListeningForNetworkChanges();
+
+ Profile* profile_;
+ bool listening_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateEventRouter);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_NETWORKING_PRIVATE_EVENT_ROUTER_H_
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/networking_private_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698