summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 17:46:52 +0000
committerpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 17:46:52 +0000
commitcef49836ac72092482edab557acc1274bb54c5e1 (patch)
tree0faa755555282bbc9334166d12bd558040bac0b9
parentfa8543dea596ab76cced0a2d3a26891b90585d4b (diff)
downloadchromium_src-cef49836ac72092482edab557acc1274bb54c5e1.zip
chromium_src-cef49836ac72092482edab557acc1274bb54c5e1.tar.gz
chromium_src-cef49836ac72092482edab557acc1274bb54c5e1.tar.bz2
Remove NetworkStateInformerDelegate which has lifetime issues.
In the old code, network_state_informer_->SetDelegate(signin_screen_handler_); was called and never reset, but network_state_informer_ outlives signin_screen_handler_. BUG=NONE R=ygorshenin@chromium.org Review URL: https://codereview.chromium.org/15899005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202122 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/webui/chromeos/login/network_state_informer.cc13
-rw-r--r--chrome/browser/ui/webui/chromeos/login/network_state_informer.h13
-rw-r--r--chrome/browser/ui/webui/chromeos/login/oobe_ui.cc2
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h4
4 files changed, 7 insertions, 25 deletions
diff --git a/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc b/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
index 555239d..1601a66 100644
--- a/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
+++ b/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
@@ -24,8 +24,7 @@ const int kNetworkStateCheckDelaySec = 3;
namespace chromeos {
NetworkStateInformer::NetworkStateInformer()
- : state_(OFFLINE),
- delegate_(NULL) {
+ : state_(OFFLINE) {
}
NetworkStateInformer::~NetworkStateInformer() {
@@ -53,10 +52,6 @@ void NetworkStateInformer::Init() {
content::NotificationService::AllSources());
}
-void NetworkStateInformer::SetDelegate(NetworkStateInformerDelegate* delegate) {
- delegate_ = delegate;
-}
-
void NetworkStateInformer::AddObserver(NetworkStateInformerObserver* observer) {
if (!observers_.HasObserver(observer))
observers_.AddObserver(observer);
@@ -147,8 +142,10 @@ bool NetworkStateInformer::UpdateState() {
if (state_ != OFFLINE)
last_connected_service_path_ = last_network_service_path_;
- if (updated && state_ == ONLINE && delegate_)
- delegate_->OnNetworkReady();
+ if (updated && state_ == ONLINE) {
+ FOR_EACH_OBSERVER(NetworkStateInformerObserver, observers_,
+ OnNetworkReady());
+ }
return updated;
}
diff --git a/chrome/browser/ui/webui/chromeos/login/network_state_informer.h b/chrome/browser/ui/webui/chromeos/login/network_state_informer.h
index 180cb3b..c722ab1 100644
--- a/chrome/browser/ui/webui/chromeos/login/network_state_informer.h
+++ b/chrome/browser/ui/webui/chromeos/login/network_state_informer.h
@@ -24,15 +24,6 @@ namespace chromeos {
class NetworkState;
-class NetworkStateInformerDelegate {
- public:
- NetworkStateInformerDelegate() {}
- virtual ~NetworkStateInformerDelegate() {}
-
- // Called when network is connected.
- virtual void OnNetworkReady() = 0;
-};
-
// Class which observes network state changes and calls registered callbacks.
// State is considered changed if connection or the active network has been
// changed. Also, it answers to the requests about current network state.
@@ -59,14 +50,13 @@ class NetworkStateInformer
virtual void UpdateState(State state,
ErrorScreenActor::ErrorReason reason) = 0;
+ virtual void OnNetworkReady() {}
};
NetworkStateInformer();
void Init();
- void SetDelegate(NetworkStateInformerDelegate* delegate);
-
// Adds observer to be notified when network state has been changed.
void AddObserver(NetworkStateInformerObserver* observer);
@@ -134,7 +124,6 @@ class NetworkStateInformer
content::NotificationRegistrar registrar_;
State state_;
- NetworkStateInformerDelegate* delegate_;
ObserverList<NetworkStateInformerObserver> observers_;
std::string last_online_service_path_;
std::string last_connected_service_path_;
diff --git a/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc b/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
index 818042e..c103fa4 100644
--- a/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
@@ -226,8 +226,6 @@ OobeUI::OobeUI(content::WebUI* web_ui)
kiosk_app_menu_handler_ = new KioskAppMenuHandler;
web_ui->AddMessageHandler(kiosk_app_menu_handler_);
- network_state_informer_->SetDelegate(signin_screen_handler_);
-
base::DictionaryValue localized_strings;
GetLocalizedStrings(&localized_strings);
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
index 9dc56bc..0890457 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
@@ -160,7 +160,6 @@ class SigninScreenHandler
public LoginDisplayWebUIHandler,
public SystemKeyEventListener::CapsLockObserver,
public content::NotificationObserver,
- public NetworkStateInformerDelegate,
public NetworkStateInformer::NetworkStateInformerObserver {
public:
SigninScreenHandler(
@@ -181,10 +180,9 @@ class SigninScreenHandler
void SetNativeWindowDelegate(NativeWindowDelegate* native_window_delegate);
- // NetworkStateInformerDelegate implementation:
+ // NetworkStateInformer::NetworkStateInformerObserver implementation:
virtual void OnNetworkReady() OVERRIDE;
- // NetworkStateInformer::NetworkStateInformerObserver implementation:
virtual void UpdateState(NetworkStateInformer::State state,
ErrorScreenActor::ErrorReason reason) OVERRIDE;