Commit 8c2a34bd authored by jkarlin@chromium.org's avatar jkarlin@chromium.org

Use the provided connection type to determine if online.

Calling IsOffline() could race and return an answer for a different type.

BUG=381282

Review URL: https://codereview.chromium.org/317933002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276050 0039d316-1c4b-4281-b951-d872f2087c98
parent 3e4de273
......@@ -19,11 +19,9 @@ BrowserOnlineStateObserver::~BrowserOnlineStateObserver() {
void BrowserOnlineStateObserver::OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) {
bool is_online = !net::NetworkChangeNotifier::IsOffline();
for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
!it.IsAtEnd(); it.Advance()) {
it.GetCurrentValue()->Send(
new ViewMsg_NetworkStateChanged(is_online, type));
it.GetCurrentValue()->Send(new ViewMsg_NetworkTypeChanged(type));
}
}
......
......@@ -460,8 +460,9 @@ WebPreferences RenderViewHostImpl::GetWebkitPrefs(const GURL& url) {
prefs.javascript_enabled = true;
}
prefs.is_online = !net::NetworkChangeNotifier::IsOffline();
prefs.connection_type = net::NetworkChangeNotifier::GetConnectionType();
prefs.is_online =
prefs.connection_type != net::NetworkChangeNotifier::CONNECTION_NONE;
prefs.gesture_tap_highlight_enabled = !command_line.HasSwitch(
switches::kDisableGestureTapHighlight);
......
......@@ -837,10 +837,9 @@ IPC_MESSAGE_ROUTED0(ViewMsg_WorkerScriptLoadFailed)
// This message is sent only if the worker successfully loaded the script.
IPC_MESSAGE_ROUTED0(ViewMsg_WorkerConnected)
// Tells the renderer that the network state has changed so that
// navigator.onLine and navigator.connection can be updated.
IPC_MESSAGE_CONTROL2(ViewMsg_NetworkStateChanged,
bool /* is_online */,
// Tells the renderer that the network type has changed so that navigator.onLine
// and navigator.connection can be updated.
IPC_MESSAGE_CONTROL1(ViewMsg_NetworkTypeChanged,
net::NetworkChangeNotifier::ConnectionType /* type */)
// Reply to ViewHostMsg_OpenChannelToPpapiBroker
......
......@@ -1224,7 +1224,7 @@ bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) {
// is there a new non-windows message I should add here?
IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView)
IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache)
IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged)
IPC_MESSAGE_HANDLER(ViewMsg_NetworkTypeChanged, OnNetworkTypeChanged)
IPC_MESSAGE_HANDLER(ViewMsg_TempCrashWithData, OnTempCrashWithData)
IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateNewSharedWorker)
IPC_MESSAGE_HANDLER(ViewMsg_TimezoneChange, OnUpdateTimezone)
......@@ -1355,10 +1355,10 @@ void RenderThreadImpl::OnPurgePluginListCache(bool reload_pages) {
FOR_EACH_OBSERVER(RenderProcessObserver, observers_, PluginListChanged());
}
void RenderThreadImpl::OnNetworkStateChanged(
bool online,
void RenderThreadImpl::OnNetworkTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) {
EnsureWebKitInitialized();
bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE;
WebNetworkStateNotifier::setOnLine(online);
FOR_EACH_OBSERVER(
RenderProcessObserver, observers_, NetworkStateChanged(online));
......
......@@ -434,8 +434,7 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread,
void OnCreateNewView(const ViewMsg_New_Params& params);
void OnTransferBitmap(const SkBitmap& bitmap, int resource_id);
void OnPurgePluginListCache(bool reload_pages);
void OnNetworkStateChanged(bool online,
net::NetworkChangeNotifier::ConnectionType type);
void OnNetworkTypeChanged(net::NetworkChangeNotifier::ConnectionType type);
void OnGetAccessibilityTree();
void OnTempCrashWithData(const GURL& data);
void OnUpdateTimezone();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment