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

Unified Diff: chrome/browser/chromeos/net/network_change_notifier_chromeos.cc

Issue 7029019: Added ChromeOS-specific NetworkChangeNotifier specialization that is wired directly to flimflam. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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/net/network_change_notifier_chromeos.cc
===================================================================
--- chrome/browser/chromeos/net/network_change_notifier_chromeos.cc (revision 0)
+++ chrome/browser/chromeos/net/network_change_notifier_chromeos.cc (revision 0)
@@ -0,0 +1,78 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
Sam Leffler 2011/05/17 02:34:28 it's 2011
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/net/network_change_notifier_chromeos.h"
+
+#include <errno.h>
+#include <sys/socket.h>
+
+#include "base/compiler_specific.h"
oshima 2011/05/17 17:33:05 move this to header (for OVERRIDE)
zel 2011/05/18 00:43:33 Done.
+#include "base/eintr_wrapper.h"
+#include "base/task.h"
oshima 2011/05/17 17:33:05 is this used?
zel 2011/05/18 00:43:33 Done.
+#include "base/threading/thread.h"
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "net/base/net_errors.h"
+
+namespace net {
+
+namespace {
+
+const int kInvalidSocket = -1;
Sam Leffler 2011/05/17 02:34:28 don't see this used
zel 2011/05/18 00:43:33 Done.
+
+} // namespace
+
+NetworkChangeNotifierCros::NetworkChangeNotifierCros()
+ : connected_(false),
+ has_active_network_(false),
+ connectivity_state_(chromeos::CONN_STATE_UNKNOWN) {
+
+ chromeos::NetworkLibrary* lib =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ lib->AddNetworkManagerObserver(this);
+ UpdateNetworkState(lib);
+}
+
+NetworkChangeNotifierCros::~NetworkChangeNotifierCros() {
+ chromeos::NetworkLibrary* lib =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ lib->RemoveNetworkManagerObserver(this);
+}
+
+void NetworkChangeNotifierCros::OnNetworkManagerChanged(
+ chromeos::NetworkLibrary* cros) {
+ UpdateNetworkState(cros);
+}
+
+bool NetworkChangeNotifierCros::IsCurrentlyOffline() const {
+ return connectivity_state_ != chromeos::CONN_STATE_UNRESTRICTED;
+}
+
+void NetworkChangeNotifierCros::UpdateNetworkState(
+ chromeos::NetworkLibrary* lib) {
+ const chromeos::Network* network = lib->active_network();
+ // Check if the active network, its IP address or its connectivity status had
+ // changed.
+ if ((network && !has_active_network_) || (!network && has_active_network_) ||
+ (network && (network->service_path() != service_path_ ||
+ network->connectivity_state() != connectivity_state_)) ||
+ lib->IPAddress() != ip_address_) {
oshima 2011/05/17 17:33:05 since the condition is a bit complicated, we need
oshima 2011/05/18 01:28:45 The code looks correct, but I'm still concerned ab
+ if (network) {
+ has_active_network_ = true;
+ service_path_ = network->service_path();
+ } else {
+ has_active_network_ = false;
+ service_path_.clear();
+ }
+ ip_address_ = lib->IPAddress();
Sam Leffler 2011/05/17 02:34:28 I'm not familiar with this stuff but how do these
zel 2011/05/18 00:43:33 Yes, on ChromeOS side this notification should be
+ NotifyObserversOfIPAddressChange();
+ }
+ if ((network && network->connectivity_state() != connectivity_state_) &&
Sam Leffler 2011/05/17 02:34:28 Again, not familiar with semantics here, but flimf
oshima 2011/05/17 17:33:05 If network can be null, don't we have to notify of
zel 2011/05/18 00:43:33 This part is rewritten now. Please take a look at
+ lib->Connected() != connected_) {
+ connectivity_state_ = network->connectivity_state();
+ connected_ = lib->Connected();
+ NotifyObserversOfOnlineStateChange();
oshima 2011/05/17 17:33:05 I believe NetworkChangeNotifier clients expect to
zel 2011/05/18 00:43:33 Done.
+ }
+}
+
+} // namespace net
Property changes on: chrome/browser/chromeos/net/network_change_notifier_chromeos.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698