summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-13 23:32:01 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-13 23:32:01 +0000
commitd393a0fdb47c3416153589b5acfc6ccaae280477 (patch)
tree4fad2a87a450cac90f5c0c4594eca7737a56c3a6
parent042070d932d4689d2f2e7907348ecd3b52aba3be (diff)
downloadchromium_src-d393a0fdb47c3416153589b5acfc6ccaae280477.zip
chromium_src-d393a0fdb47c3416153589b5acfc6ccaae280477.tar.gz
chromium_src-d393a0fdb47c3416153589b5acfc6ccaae280477.tar.bz2
Ensure that IO thread is not called in last actions by SDCH shutdown
Unregister the sdch_dictionary_fetcher so that it destroys any pending URLFetcher instances when we are nearing shutdown time. Dictionaries are only *potentially* useful (and not needed) for future SDCH fetches, so abandoning any pending items is safe and harmless. b=9669 r=wtc Review URL: http://codereview.chromium.org/113235 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16015 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_process_impl.cc11
-rw-r--r--chrome/browser/net/sdch_dictionary_fetcher.h4
-rw-r--r--net/base/sdch_manager.cc7
-rw-r--r--net/base/sdch_manager.h3
4 files changed, 23 insertions, 2 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index a031374..759934b 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/google_url_tracker.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/net/dns_global.h"
+#include "chrome/browser/net/sdch_dictionary_fetcher.h"
#include "chrome/browser/plugin_service.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
@@ -143,10 +144,16 @@ BrowserProcessImpl::~BrowserProcessImpl() {
// this destructor is run.
automation_provider_list_.reset();
+ // We need to shutdown the SdchDictionaryFetcher as it regularly holds
+ // a pointer to a URLFetcher, and that URLFetcher (upon destruction) will do
+ // a PostDelayedTask onto the IO thread. This shutdown call will both discard
+ // any pending URLFetchers, and avoid creating any more.
+ SdchDictionaryFetcher::Shutdown();
+
// We need to destroy the MetricsService and GoogleURLTracker before the
// io_thread_ gets destroyed, since both destructors can call the URLFetcher
- // destructor, which does an InvokeLater operation on the IO thread. (The IO
- // thread will handle that URLFetcher operation before going away.)
+ // destructor, which does an PostDelayedTask operation on the IO thread. (The
+ // IO thread will handle that URLFetcher operation before going away.)
metrics_service_.reset();
google_url_tracker_.reset();
diff --git a/chrome/browser/net/sdch_dictionary_fetcher.h b/chrome/browser/net/sdch_dictionary_fetcher.h
index a0a9e2f..e9e092c 100644
--- a/chrome/browser/net/sdch_dictionary_fetcher.h
+++ b/chrome/browser/net/sdch_dictionary_fetcher.h
@@ -31,6 +31,10 @@ class SdchDictionaryFetcher : public URLFetcher::Delegate,
// SdchManager class with the dictionary's text.
virtual void Schedule(const GURL& dictionary_url);
+ // Stop fetching dictionaries, and abandon any current URLFetcheer operations
+ // so that the IO thread can be stopped.
+ static void Shutdown() { SdchManager::Shutdown(); }
+
private:
// Delay in ms between Schedule and actual download.
// This leaves the URL in a queue, which is de-duped, so that there is less
diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc
index 30995a8..05b6475 100644
--- a/net/base/sdch_manager.cc
+++ b/net/base/sdch_manager.cc
@@ -82,6 +82,13 @@ SdchManager::~SdchManager() {
}
// static
+void SdchManager::Shutdown() {
+ if (!global_ )
+ return;
+ global_->fetcher_.reset(NULL);
+}
+
+// static
void SdchManager::BlacklistDomain(const GURL& url) {
if (!global_ )
return;
diff --git a/net/base/sdch_manager.h b/net/base/sdch_manager.h
index e8329e1..43fa484 100644
--- a/net/base/sdch_manager.h
+++ b/net/base/sdch_manager.h
@@ -217,6 +217,9 @@ class SdchManager {
SdchManager();
~SdchManager();
+ // Discontinue fetching of dictionaries, as we're now shutting down.
+ static void Shutdown();
+
// Provide access to the single instance of this class.
static SdchManager* Global();