diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-01 15:19:40 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-01 15:19:40 +0000 |
commit | b2fcd0e0c8850eda2135b6fe270af5f453682f23 (patch) | |
tree | 2858497a3551d59093a5dfd233bf3550d40a4e8d /chrome/browser/io_thread.cc | |
parent | 087a03f6aeded6397081304e191b1ac027b8e134 (diff) | |
download | chromium_src-b2fcd0e0c8850eda2135b6fe270af5f453682f23.zip chromium_src-b2fcd0e0c8850eda2135b6fe270af5f453682f23.tar.gz chromium_src-b2fcd0e0c8850eda2135b6fe270af5f453682f23.tar.bz2 |
Update NetLog to be threadsafe.
The ChromeNetLog is now owned by the browser process,
and passed to the IOThread on creation.
NetLog entries can be added from any thread.
Observers must be able to handle having log entries added
from any thread. Observers can add/remove themselves on any
thread.
BUG=63334
TEST=None, yet
Review URL: http://codereview.chromium.org/4118004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67851 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/io_thread.cc')
-rw-r--r-- | chrome/browser/io_thread.cc | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 94d3126..b9e8ef9 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -214,8 +214,9 @@ IOThread::Globals::~Globals() {} // |local_state| is passed in explicitly in order to (1) reduce implicit // dependencies and (2) make IOThread more flexible for testing. -IOThread::IOThread(PrefService* local_state) +IOThread::IOThread(PrefService* local_state, ChromeNetLog* net_log) : BrowserProcessSubThread(BrowserThread::IO), + net_log_(net_log), globals_(NULL), speculative_interceptor_(NULL), predictor_(NULL) { @@ -245,6 +246,10 @@ IOThread::Globals* IOThread::globals() { return globals_; } +ChromeNetLog* IOThread::net_log() { + return net_log_; +} + void IOThread::InitNetworkPredictor( bool prefetching_enabled, base::TimeDelta max_dns_queue_delay, @@ -320,16 +325,14 @@ void IOThread::Init() { DCHECK(!globals_); globals_ = new Globals; - globals_->net_log.reset(new ChromeNetLog()); - // Add an observer that will emit network change events to the ChromeNetLog. // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be // logging the network change before other IO thread consumers respond to it. network_change_observer_.reset( - new LoggingNetworkChangeObserver(globals_->net_log.get())); + new LoggingNetworkChangeObserver(net_log_)); globals_->host_resolver.reset( - CreateGlobalHostResolver(globals_->net_log.get())); + CreateGlobalHostResolver(net_log_)); globals_->dnsrr_resolver.reset(new net::DnsRRResolver); globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( globals_->host_resolver.get())); @@ -416,10 +419,6 @@ void IOThread::CleanUp() { globals_->host_resolver.get()->GetAsHostResolverImpl()->Shutdown(); } - // We will delete the NetLog as part of CleanUpAfterMessageLoopDestruction() - // in case any of the message loop destruction observers try to access it. - deferred_net_log_to_delete_.reset(globals_->net_log.release()); - delete globals_; globals_ = NULL; @@ -427,12 +426,6 @@ void IOThread::CleanUp() { } void IOThread::CleanUpAfterMessageLoopDestruction() { - // TODO(eroman): get rid of this special case for 39723. If we could instead - // have a method that runs after the message loop destruction observers have - // run, but before the message loop itself is destroyed, we could safely - // combine the two cleanups. - deferred_net_log_to_delete_.reset(); - // This will delete the |notification_service_|. Make sure it's done after // anything else can reference it. BrowserProcessSubThread::CleanUpAfterMessageLoopDestruction(); @@ -529,5 +522,5 @@ void IOThread::ChangedToOnTheRecordOnIOThread() { // Clear all of the passively logged data. // TODO(eroman): this is a bit heavy handed, really all we need to do is // clear the data pertaining to off the record context. - globals_->net_log->passive_collector()->Clear(); + net_log_->ClearAllPassivelyCapturedEvents(); } |