diff options
author | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-15 22:13:33 +0000 |
---|---|---|
committer | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-15 22:13:33 +0000 |
commit | 0374b165987b53354edca740082640315091fd95 (patch) | |
tree | c915943d1e5ac2dbf61c34390ea21b668aa3a23d /chrome/browser/extensions | |
parent | b6cf240f37f8e953558b1c24bff3568debc76d3f (diff) | |
download | chromium_src-0374b165987b53354edca740082640315091fd95.zip chromium_src-0374b165987b53354edca740082640315091fd95.tar.gz chromium_src-0374b165987b53354edca740082640315091fd95.tar.bz2 |
Initialize the NetworkDelayListener to allow requests rather than deny them.
This is necessary for Chrome Frame, which doesn't load extensions.
We're relying on the Profile being created (and thus loading extensions) before the session is restored on startup. And as a result, we don't need to watch for NOTIFICATION_EXTENSIONS_READY anymore, nor test that.
TBR=aa
BUG=99450
TEST=NetworkDelayListener unit tests pass, and chrome_frame_net_tests don't time out
Review URL: http://codereview.chromium.org/8314005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/network_delay_listener.cc | 11 | ||||
-rw-r--r-- | chrome/browser/extensions/network_delay_listener.h | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/network_delay_listener_unittest.cc | 28 |
3 files changed, 7 insertions, 38 deletions
diff --git a/chrome/browser/extensions/network_delay_listener.cc b/chrome/browser/extensions/network_delay_listener.cc index 8865c61..09873d9 100644 --- a/chrome/browser/extensions/network_delay_listener.cc +++ b/chrome/browser/extensions/network_delay_listener.cc @@ -19,7 +19,7 @@ NetworkDelayListener::NetworkDelayListener() : resource_queue_(NULL), - extensions_ready_(false), + extensions_ready_(true), recorded_startup_delay_(false) { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -29,8 +29,6 @@ NetworkDelayListener::NetworkDelayListener() NotificationService::AllSources()); registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, NotificationService::AllSources()); - registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, - NotificationService::AllSources()); AddRef(); // Will be balanced in Cleanup(). } @@ -165,13 +163,6 @@ void NetworkDelayListener::Observe(int type, break; } - case chrome::NOTIFICATION_EXTENSIONS_READY: { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&NetworkDelayListener::StartDelayedRequestsIfReady, this)); - break; - } - default: NOTREACHED(); } diff --git a/chrome/browser/extensions/network_delay_listener.h b/chrome/browser/extensions/network_delay_listener.h index 45784d2..9df06d1 100644 --- a/chrome/browser/extensions/network_delay_listener.h +++ b/chrome/browser/extensions/network_delay_listener.h @@ -71,6 +71,12 @@ class NetworkDelayListener // True if the extensions are ready for network requests to proceed. In // practice this means that the background pages of any pending extensions // have been run. + // This flag starts out true, until the first extension that is registered to + // delay network requests starts loading. That's safe because the profile + // must be created, and thus extensions loaded, before a browser session is + // restored. It's also necessary, because Chrome Frame doesn't support + // extensions, and therefore doesn't send any notification that they're all + // done loading. bool extensions_ready_; // Which extension IDs have registered to delay network requests on startup, diff --git a/chrome/browser/extensions/network_delay_listener_unittest.cc b/chrome/browser/extensions/network_delay_listener_unittest.cc index 5622428..fb6f1f2 100644 --- a/chrome/browser/extensions/network_delay_listener_unittest.cc +++ b/chrome/browser/extensions/network_delay_listener_unittest.cc @@ -141,14 +141,6 @@ class NetworkDelayListenerTest MessageLoop::current()->RunAllPending(); } - void SendExtensionsReadyNotification() { - NotificationService::current()->Notify( - chrome::NOTIFICATION_EXTENSIONS_READY, - Source<Profile>(profile_.get()), - NotificationService::NoDetails()); - MessageLoop::current()->RunAllPending(); - } - scoped_refptr<NetworkDelayListener> listener_; // Weak reference. @@ -234,29 +226,11 @@ TEST_F(NetworkDelayListenerTest, ExtensionReadyTwice) { MessageLoop::current()->RunAllPending(); } -// Tests that the misleadingly named NOTIFICATION_EXTENSIONS_READY doesn't -// release network requests. -TEST_F(NetworkDelayListenerTest, ExtensionsReadyNotReady) { - LoadTestExtension1(); - - TestDelegate delegate; - scoped_ptr<TestURLRequest> request(StartTestRequest(&delegate, kTestUrl)); - ASSERT_FALSE(request->is_pending()); - - SendExtensionsReadyNotification(); - ASSERT_FALSE(request->is_pending()); - - SendExtensionLoadedNotification(extension1_); - EXPECT_EQ(kTestData, delegate.data_received()); -} - // Tests that there's no delay if no loaded extension needs one. TEST_F(NetworkDelayListenerTest, NoDelayNoWebRequest) { LoadTestExtension(kTestExtensionNoNetworkDelay); ASSERT_FALSE(service_->extensions()->empty()); - SendExtensionsReadyNotification(); - TestDelegate delegate; scoped_ptr<TestURLRequest> request(StartTestRequest(&delegate, kTestUrl)); @@ -269,8 +243,6 @@ TEST_F(NetworkDelayListenerTest, NoDelayNoWebRequest) { // Tests that there's no delay if no extensions are loaded. TEST_F(NetworkDelayListenerTest, NoDelayNoExtensions) { - SendExtensionsReadyNotification(); - TestDelegate delegate; scoped_ptr<TestURLRequest> request(StartTestRequest(&delegate, kTestUrl)); |