From b3186d020039b47b57a41a2f64ad10d0059a9e20 Mon Sep 17 00:00:00 2001 From: "pkasting@chromium.org" Date: Mon, 15 Sep 2008 20:33:14 +0000 Subject: Fix unittest bustage due to NULL pointer deref (only in unittest mode, I hope). Also commit some comment changes which were supposed to go in my original patch but missed it. TBR=sky BUG=1291 Review URL: http://codereview.chromium.org/2870 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2233 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/profile.h | 20 +++++++++++--------- chrome/browser/template_url_model.cc | 8 +++++--- chrome/browser/template_url_model.h | 2 ++ 3 files changed, 18 insertions(+), 12 deletions(-) (limited to 'chrome/browser') diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h index 83dcdec..2d7dbac 100644 --- a/chrome/browser/profile.h +++ b/chrome/browser/profile.h @@ -69,13 +69,13 @@ class Profile { // Create a new profile given a path. static Profile* CreateProfile(const std::wstring& path); - // Returns the request context for the "default" profile. This is a temporary - // measure while we still only support 1 profile. Consumers of this will need - // to figure out what to do when we start having multiple profiles. This may - // be called from any thread. + // Returns the request context for the "default" profile. This may be called + // from any thread. This CAN return NULL if a first request context has not + // yet been created. If necessary, listen on the UI thread for + // NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE. // - // This object is NOT THREADSAFE and must be used and destroyed only on the - // I/O thread. + // The returned object is ref'd by the profile. Callers who AddRef() it (to + // keep it alive longer than the profile) must Release() it on the I/O thread. static URLRequestContext* GetDefaultRequestContext(); // Returns the path of the directory where this profile's data is stored. @@ -135,10 +135,12 @@ class Profile { virtual DownloadManager* GetDownloadManager() = 0; virtual bool HasCreatedDownloadManager() const = 0; - // Returns the request context information associated with this profile. + // Returns the request context information associated with this profile. Call + // this only on the UI thread, since it can send notifications that should + // happen on the UI thread. // - // This object is NOT THREADSAFE and must be used and destroyed only on the - // I/O thread. + // The returned object is ref'd by the profile. Callers who AddRef() it (to + // keep it alive longer than the profile) must Release() it on the I/O thread. virtual URLRequestContext* GetRequestContext() = 0; // Returns the session service for this profile. This may return NULL. If diff --git a/chrome/browser/template_url_model.cc b/chrome/browser/template_url_model.cc index 8a2be29..b10d08d 100644 --- a/chrome/browser/template_url_model.cc +++ b/chrome/browser/template_url_model.cc @@ -135,9 +135,11 @@ void TemplateURLModel::Init(const Initializer* initializers, // Request a server check for the correct Google URL if Google is the default // search engine. const TemplateURL* default_provider = GetDefaultSearchProvider(); - const TemplateURLRef* default_provider_ref = default_provider->url(); - if (default_provider_ref && default_provider_ref->HasGoogleBaseURLs()) - GoogleURLTracker::RequestServerCheck(); + if (default_provider) { + const TemplateURLRef* default_provider_ref = default_provider->url(); + if (default_provider_ref && default_provider_ref->HasGoogleBaseURLs()) + GoogleURLTracker::RequestServerCheck(); + } } // static diff --git a/chrome/browser/template_url_model.h b/chrome/browser/template_url_model.h index ff97d37..d540f89 100644 --- a/chrome/browser/template_url_model.h +++ b/chrome/browser/template_url_model.h @@ -156,6 +156,8 @@ class TemplateURLModel : public WebDataServiceConsumer, // Returns the default search provider. If the TemplateURLModel hasn't been // loaded, the default search provider is pulled from preferences. + // + // NOTE: At least in unittest mode, this may return NULL. const TemplateURL* GetDefaultSearchProvider(); // Observers used to listen for changes to the model. -- cgit v1.1