Revert 91390 (build breakage) - Convert ViewMsg_NetworkStateChanged from routed -> control
allowing it to be sent from BrowserRenderProcessHost::OnProcessLaunched and minimizing the number of required IPCs (since the online state is a per-WebKit singleton). In doing so, I've disentangled online state management from TabContents: it now resides off by itself in BrowserOnlineStateObserver, a tiny class owned by BrowserProcessImpl. BUG=7469,86538 TEST=begin with network disconnected, open new tab, load test page attached to 7469, then re-connect network Review URL: http://codereview.chromium.org/7259004 TBR=eroman@chromium.org Review URL: http://codereview.chromium.org/7300018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91392 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -72,7 +72,6 @@
|
||||
#include "content/browser/debugger/devtools_manager.h"
|
||||
#include "content/browser/debugger/devtools_protocol_handler.h"
|
||||
#include "content/browser/gpu/gpu_process_host_ui_shim.h"
|
||||
#include "content/browser/net/browser_online_state_observer.h"
|
||||
#include "content/browser/plugin_service.h"
|
||||
#include "content/browser/renderer_host/render_process_host.h"
|
||||
#include "content/browser/renderer_host/resource_dispatcher_host.h"
|
||||
@ -147,8 +146,6 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
|
||||
extension_event_router_forwarder_ = new ExtensionEventRouterForwarder;
|
||||
|
||||
ExtensionTabIdMap::GetInstance()->Init();
|
||||
|
||||
online_state_observer_.reset(new BrowserOnlineStateObserver);
|
||||
}
|
||||
|
||||
BrowserProcessImpl::~BrowserProcessImpl() {
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "content/common/notification_registrar.h"
|
||||
#include "ipc/ipc_message.h"
|
||||
|
||||
class BrowserOnlineStateObserver;
|
||||
class ChromeNetLog;
|
||||
class ChromeResourceDispatcherHostDelegate;
|
||||
class CommandLine;
|
||||
@ -318,9 +317,6 @@ class BrowserProcessImpl : public BrowserProcess,
|
||||
chromeos_proxy_config_service_impl_;
|
||||
#endif
|
||||
|
||||
// Per-process listener for online state changes.
|
||||
scoped_ptr<BrowserOnlineStateObserver> online_state_observer_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "chrome/browser/speech/speech_input_bubble.h"
|
||||
#include "content/browser/tab_contents/tab_contents.h"
|
||||
#include "grit/generated_resources.h"
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/file_path.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "chrome/browser/bookmarks/bookmark_node_data.h"
|
||||
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "chrome/browser/ui/shell_dialogs.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/prefs/pref_service.h"
|
||||
#include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
|
||||
|
@ -1,24 +0,0 @@
|
||||
// Copyright (c) 2011 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.
|
||||
|
||||
#include "content/browser/net/browser_online_state_observer.h"
|
||||
|
||||
#include "content/browser/renderer_host/render_process_host.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "net/base/network_change_notifier.h"
|
||||
|
||||
BrowserOnlineStateObserver::BrowserOnlineStateObserver() {
|
||||
net::NetworkChangeNotifier::AddOnlineStateObserver(this);
|
||||
}
|
||||
|
||||
BrowserOnlineStateObserver::~BrowserOnlineStateObserver() {
|
||||
net::NetworkChangeNotifier::RemoveOnlineStateObserver(this);
|
||||
}
|
||||
|
||||
void BrowserOnlineStateObserver::OnOnlineStateChanged(bool online) {
|
||||
for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
|
||||
!it.IsAtEnd(); it.Advance()) {
|
||||
it.GetCurrentValue()->Send(new ViewMsg_NetworkStateChanged(online));
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
// Copyright (c) 2011 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 CONTENT_BROWSER_NET_BROWSER_ONLINE_STATE_OBSERVER_H_
|
||||
#define CONTENT_BROWSER_NET_BROWSER_ONLINE_STATE_OBSERVER_H_
|
||||
#pragma once
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "net/base/network_change_notifier.h"
|
||||
|
||||
// Listens for changes to the online state and manages sending
|
||||
// updates to each RenderProcess via RenderProcessHost IPC.
|
||||
class BrowserOnlineStateObserver
|
||||
: public net::NetworkChangeNotifier::OnlineStateObserver {
|
||||
public:
|
||||
BrowserOnlineStateObserver();
|
||||
virtual ~BrowserOnlineStateObserver();
|
||||
|
||||
// OnlineStateObserver implementation.
|
||||
virtual void OnOnlineStateChanged(bool online);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(BrowserOnlineStateObserver);
|
||||
};
|
||||
|
||||
#endif // CONTENT_BROWSER_NET_BROWSER_ONLINE_STATE_OBSERVER_H_
|
@ -78,7 +78,6 @@
|
||||
#include "ipc/ipc_platform_file.h"
|
||||
#include "ipc/ipc_switches.h"
|
||||
#include "media/base/media_switches.h"
|
||||
#include "net/base/network_change_notifier.h"
|
||||
#include "net/url_request/url_request_context_getter.h"
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
#include "ui/gfx/gl/gl_switches.h"
|
||||
@ -888,11 +887,6 @@ void BrowserRenderProcessHost::OnProcessLaunched() {
|
||||
if (max_page_id_ != -1)
|
||||
Send(new ViewMsg_SetNextPageID(max_page_id_ + 1));
|
||||
|
||||
// WebKit's network state (window.navigator.onLine) defaults to true,
|
||||
// so if we're offline we need to notify the renderer at startup.
|
||||
if (net::NetworkChangeNotifier::IsOffline())
|
||||
Send(new ViewMsg_NetworkStateChanged(false));
|
||||
|
||||
// NOTE: This needs to be before sending queued messages because
|
||||
// ExtensionService uses this notification to initialize the renderer process
|
||||
// with state that must be there before any JavaScript executes.
|
||||
|
@ -201,6 +201,11 @@ TabContents::TabContents(Profile* profile,
|
||||
|
||||
registrar_.Add(this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
|
||||
NotificationService::AllSources());
|
||||
|
||||
// Can only add observers after render_manager_.Init() is called, since that's
|
||||
// what sets up the render_view_host which TabContentObserver's constructor
|
||||
// uses to get the routing_id.
|
||||
AddObservers();
|
||||
}
|
||||
|
||||
TabContents::~TabContents() {
|
||||
@ -246,6 +251,8 @@ TabContents::~TabContents() {
|
||||
|
||||
FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed());
|
||||
|
||||
net::NetworkChangeNotifier::RemoveOnlineStateObserver(this);
|
||||
|
||||
set_delegate(NULL);
|
||||
}
|
||||
|
||||
@ -260,6 +267,10 @@ void TabContents::set_delegate(TabContentsDelegate* delegate) {
|
||||
delegate_->Attach(this);
|
||||
}
|
||||
|
||||
void TabContents::AddObservers() {
|
||||
net::NetworkChangeNotifier::AddOnlineStateObserver(this);
|
||||
}
|
||||
|
||||
bool TabContents::OnMessageReceived(const IPC::Message& message) {
|
||||
if (web_ui() && web_ui()->OnMessageReceived(message))
|
||||
return true;
|
||||
@ -1830,3 +1841,8 @@ void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
|
||||
RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh);
|
||||
rwh_view->SetSize(view()->GetContainerSize());
|
||||
}
|
||||
|
||||
void TabContents::OnOnlineStateChanged(bool online) {
|
||||
render_view_host()->Send(new ViewMsg_NetworkStateChanged(
|
||||
render_view_host()->routing_id(), online));
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "base/basictypes.h"
|
||||
#include "base/gtest_prod_util.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/string16.h"
|
||||
#include "content/browser/javascript_dialogs.h"
|
||||
#include "content/browser/renderer_host/render_view_host_delegate.h"
|
||||
@ -28,6 +27,7 @@
|
||||
#include "content/common/property_bag.h"
|
||||
#include "content/common/renderer_preferences.h"
|
||||
#include "net/base/load_states.h"
|
||||
#include "net/base/network_change_notifier.h"
|
||||
#include "ui/gfx/native_widget_types.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@ -61,7 +61,8 @@ class TabContents : public PageNavigator,
|
||||
public NotificationObserver,
|
||||
public RenderViewHostDelegate,
|
||||
public RenderViewHostManager::Delegate,
|
||||
public content::JavaScriptDialogDelegate {
|
||||
public content::JavaScriptDialogDelegate,
|
||||
public net::NetworkChangeNotifier::OnlineStateObserver {
|
||||
public:
|
||||
// Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it
|
||||
// what has changed. Combine them to update more than one thing.
|
||||
@ -514,6 +515,9 @@ class TabContents : public PageNavigator,
|
||||
// TODO(brettw) TestTabContents shouldn't exist!
|
||||
friend class TestTabContents;
|
||||
|
||||
// Add all the TabContentObservers.
|
||||
void AddObservers();
|
||||
|
||||
// Message handlers.
|
||||
void OnDidStartProvisionalLoadForFrame(int64 frame_id,
|
||||
bool main_frame,
|
||||
@ -700,6 +704,9 @@ class TabContents : public PageNavigator,
|
||||
const NotificationSource& source,
|
||||
const NotificationDetails& details);
|
||||
|
||||
// NetworkChangeNotifier::OnlineStateObserver:
|
||||
virtual void OnOnlineStateChanged(bool online);
|
||||
|
||||
// Adds the given window to the list of child windows. The window will notify
|
||||
// via WillClose() when it is being destroyed.
|
||||
void AddConstrainedDialog(ConstrainedWindow* window);
|
||||
|
@ -1148,8 +1148,8 @@ IPC_MESSAGE_ROUTED3(ViewMsg_AsyncOpenFile_ACK,
|
||||
|
||||
// Tells the renderer that the network state has changed and that
|
||||
// window.navigator.onLine should be updated for all WebViews.
|
||||
IPC_MESSAGE_CONTROL1(ViewMsg_NetworkStateChanged,
|
||||
bool /* online */)
|
||||
IPC_MESSAGE_ROUTED1(ViewMsg_NetworkStateChanged,
|
||||
bool /* online */)
|
||||
|
||||
// Enable accessibility in the renderer process.
|
||||
IPC_MESSAGE_ROUTED0(ViewMsg_EnableAccessibility)
|
||||
|
@ -200,8 +200,6 @@
|
||||
'browser/mach_broker_mac.h',
|
||||
'browser/mime_registry_message_filter.cc',
|
||||
'browser/mime_registry_message_filter.h',
|
||||
'browser/net/browser_online_state_observer.cc',
|
||||
'browser/net/browser_online_state_observer.h',
|
||||
# TODO: These should be moved to test_support (see below), but
|
||||
# are currently used by production code in automation_provider.cc.
|
||||
'browser/net/url_request_failed_dns_job.cc',
|
||||
|
@ -56,7 +56,6 @@
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifier.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageEventDispatcher.h"
|
||||
@ -86,7 +85,6 @@
|
||||
|
||||
using WebKit::WebDocument;
|
||||
using WebKit::WebFrame;
|
||||
using WebKit::WebNetworkStateNotifier;
|
||||
using WebKit::WebRuntimeFeatures;
|
||||
using WebKit::WebScriptController;
|
||||
using WebKit::WebString;
|
||||
@ -399,7 +397,6 @@ bool RenderThread::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(DOMStorageMsg_Event, OnDOMStorageEvent)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
@ -675,11 +672,6 @@ void RenderThread::OnPurgePluginListCache(bool reload_pages) {
|
||||
plugin_refresh_allowed_ = true;
|
||||
}
|
||||
|
||||
void RenderThread::OnNetworkStateChanged(bool online) {
|
||||
EnsureWebKitInitialized();
|
||||
WebNetworkStateNotifier::setOnLine(online);
|
||||
}
|
||||
|
||||
scoped_refptr<base::MessageLoopProxy>
|
||||
RenderThread::GetFileThreadMessageLoopProxy() {
|
||||
DCHECK(message_loop() == MessageLoop::current());
|
||||
|
@ -237,7 +237,6 @@ class RenderThread : public RenderThreadBase,
|
||||
void OnCreateNewView(const ViewMsg_New_Params& params);
|
||||
void OnTransferBitmap(const SkBitmap& bitmap, int resource_id);
|
||||
void OnPurgePluginListCache(bool reload_pages);
|
||||
void OnNetworkStateChanged(bool online);
|
||||
void OnGetAccessibilityTree();
|
||||
|
||||
// We initialize WebKit as late as possible.
|
||||
|
@ -90,6 +90,7 @@
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifier.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
|
||||
@ -190,6 +191,7 @@ using WebKit::WebMediaPlayerAction;
|
||||
using WebKit::WebMediaPlayerClient;
|
||||
using WebKit::WebNavigationPolicy;
|
||||
using WebKit::WebNavigationType;
|
||||
using WebKit::WebNetworkStateNotifier;
|
||||
using WebKit::WebNode;
|
||||
using WebKit::WebPlugin;
|
||||
using WebKit::WebPluginContainer;
|
||||
@ -674,6 +676,7 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) {
|
||||
IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
|
||||
#endif
|
||||
IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed)
|
||||
IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged)
|
||||
// TODO(viettrungluu): Move to a separate message filter.
|
||||
#if defined(ENABLE_FLAPPER_HACKS)
|
||||
IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK)
|
||||
@ -4259,3 +4262,7 @@ void RenderView::OnContextMenuClosed(
|
||||
else
|
||||
context_menu_node_.reset();
|
||||
}
|
||||
|
||||
void RenderView::OnNetworkStateChanged(bool online) {
|
||||
WebNetworkStateNotifier::setOnLine(online);
|
||||
}
|
||||
|
@ -779,6 +779,7 @@ class RenderView : public RenderWidget,
|
||||
const WebKit::WebMediaPlayerAction& action);
|
||||
void OnMoveOrResizeStarted();
|
||||
void OnNavigate(const ViewMsg_Navigate_Params& params);
|
||||
void OnNetworkStateChanged(bool online);
|
||||
void OnPaste();
|
||||
#if defined(OS_MACOSX)
|
||||
void OnPluginImeCompositionCompleted(const string16& text, int plugin_id);
|
||||
|
Reference in New Issue
Block a user