summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradamk@google.com <adamk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-02 00:01:58 +0000
committeradamk@google.com <adamk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-02 00:01:58 +0000
commitf1c244e1c3d0fc1b44cc3044c1c49b4fe799eb0c (patch)
tree8472a6b1cadfe2ed1cac8b786c63cf494785633d
parentcadea3888ab685b6e88589d008b9537e67a6d256 (diff)
downloadchromium_src-f1c244e1c3d0fc1b44cc3044c1c49b4fe799eb0c.zip
chromium_src-f1c244e1c3d0fc1b44cc3044c1c49b4fe799eb0c.tar.gz
chromium_src-f1c244e1c3d0fc1b44cc3044c1c49b4fe799eb0c.tar.bz2
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
-rw-r--r--chrome/browser/browser_process_impl.cc3
-rw-r--r--chrome/browser/browser_process_impl.h4
-rw-r--r--chrome/browser/speech/speech_input_bubble.cc1
-rw-r--r--chrome/browser/tab_contents/web_drag_dest_gtk.cc1
-rw-r--r--chrome/browser/ui/shell_dialogs.cc1
-rw-r--r--content/browser/net/browser_online_state_observer.cc24
-rw-r--r--content/browser/net/browser_online_state_observer.h27
-rw-r--r--content/browser/renderer_host/browser_render_process_host.cc6
-rw-r--r--content/browser/tab_contents/tab_contents.cc16
-rw-r--r--content/browser/tab_contents/tab_contents.h11
-rw-r--r--content/common/view_messages.h4
-rw-r--r--content/content_browser.gypi2
-rw-r--r--content/renderer/render_thread.cc8
-rw-r--r--content/renderer/render_thread.h1
-rw-r--r--content/renderer/render_view.cc7
-rw-r--r--content/renderer/render_view.h1
16 files changed, 35 insertions, 82 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 4e6bab1..02ff81d 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -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() {
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 57cb891..002e557 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -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);
};
diff --git a/chrome/browser/speech/speech_input_bubble.cc b/chrome/browser/speech/speech_input_bubble.cc
index c0598d0..251c1c3 100644
--- a/chrome/browser/speech/speech_input_bubble.cc
+++ b/chrome/browser/speech/speech_input_bubble.cc
@@ -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"
diff --git a/chrome/browser/tab_contents/web_drag_dest_gtk.cc b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
index 4affb5c..ffddbdd 100644
--- a/chrome/browser/tab_contents/web_drag_dest_gtk.cc
+++ b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
@@ -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"
diff --git a/chrome/browser/ui/shell_dialogs.cc b/chrome/browser/ui/shell_dialogs.cc
index 603c75f..5b9d391 100644
--- a/chrome/browser/ui/shell_dialogs.cc
+++ b/chrome/browser/ui/shell_dialogs.cc
@@ -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"
diff --git a/content/browser/net/browser_online_state_observer.cc b/content/browser/net/browser_online_state_observer.cc
deleted file mode 100644
index 2b0ccd8..0000000
--- a/content/browser/net/browser_online_state_observer.cc
+++ /dev/null
@@ -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));
- }
-}
diff --git a/content/browser/net/browser_online_state_observer.h b/content/browser/net/browser_online_state_observer.h
deleted file mode 100644
index 1e5e71a..0000000
--- a/content/browser/net/browser_online_state_observer.h
+++ /dev/null
@@ -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_
diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc
index 3dfeb2b..aa580dd 100644
--- a/content/browser/renderer_host/browser_render_process_host.cc
+++ b/content/browser/renderer_host/browser_render_process_host.cc
@@ -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.
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index e83fc69..c2ca82d 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -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));
+}
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index dfde09a..458d341 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -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);
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index 52a069a72..7c3ef4a 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -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)
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 8b51378..342722c2 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -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',
diff --git a/content/renderer/render_thread.cc b/content/renderer/render_thread.cc
index 1f9d6da..d9d9d1d 100644
--- a/content/renderer/render_thread.cc
+++ b/content/renderer/render_thread.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());
diff --git a/content/renderer/render_thread.h b/content/renderer/render_thread.h
index d8c3a6f..e73d1c1 100644
--- a/content/renderer/render_thread.h
+++ b/content/renderer/render_thread.h
@@ -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.
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index d881e82..e6724b5 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -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);
+}
diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h
index 25bedcf..444d8555 100644
--- a/content/renderer/render_view.h
+++ b/content/renderer/render_view.h
@@ -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);