| Index: chrome/browser/chromeos/network_state_notifier.cc | 
| diff --git a/chrome/browser/chromeos/network_state_notifier.cc b/chrome/browser/chromeos/network_state_notifier.cc | 
| index 2d1303048fde05193849d8784547260f8ccd9696..3ee696c1bf8db805f5d03dbcde757311291297a9 100644 | 
| --- a/chrome/browser/chromeos/network_state_notifier.cc | 
| +++ b/chrome/browser/chromeos/network_state_notifier.cc | 
| @@ -2,23 +2,38 @@ | 
| // Use of this source code is governed by a BSD-style license that can be | 
| // found in the LICENSE file. | 
|  | 
| +#include "chrome/browser/chromeos/network_state_notifier.h" | 
| + | 
| +#include "base/message_loop.h" | 
| +#include "base/time.h" | 
| #include "chrome/browser/chrome_thread.h" | 
| #include "chrome/browser/chromeos/cros/cros_library.h" | 
| -#include "chrome/browser/chromeos/network_state_notifier.h" | 
| #include "chrome/common/notification_service.h" | 
| #include "chrome/common/notification_type.h" | 
|  | 
| -#include "base/message_loop.h" | 
| - | 
| namespace chromeos { | 
|  | 
| +using base::Time; | 
| +using base::TimeDelta; | 
| + | 
| +// static | 
| NetworkStateNotifier* NetworkStateNotifier::Get() { | 
| return Singleton<NetworkStateNotifier>::get(); | 
| } | 
|  | 
| +// static | 
| +TimeDelta NetworkStateNotifier::GetOfflineDuration() { | 
| +  DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 
| +  // TODO(oshima): make this instance method so that | 
| +  // we can mock this for ui_tests. | 
| +  // http://crbug.com/4825 . | 
| +  return base::Time::Now() - Get()->offline_start_time_; | 
| +} | 
| + | 
| NetworkStateNotifier::NetworkStateNotifier() | 
| -    : task_factory_(this) { | 
| -  state_ = RetrieveState(); | 
| +    : ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), | 
| +      state_(RetrieveState()), | 
| +      offline_start_time_(Time::Now()) { | 
| } | 
|  | 
| void NetworkStateNotifier::NetworkChanged(NetworkLibrary* cros) { | 
| @@ -37,6 +52,11 @@ void NetworkStateNotifier::UpdateNetworkState( | 
| NetworkStateDetails::State new_state) { | 
| DLOG(INFO) << "UpdateNetworkState: new=" | 
| << new_state << ", old=" << state_; | 
| +  if (state_ == NetworkStateDetails::CONNECTED && | 
| +      new_state != NetworkStateDetails::CONNECTED) { | 
| +    offline_start_time_ = Time::Now(); | 
| +  } | 
| + | 
| state_ = new_state; | 
| NetworkStateDetails details(state_); | 
| NotificationService::current()->Notify( | 
|  |