From 4c9870e75333c720018e71c0ed3bea9b548217d5 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Tue, 4 Jun 2013 14:17:16 -0400 Subject: [PATCH] Fix debug assertion about performing IO on the UI thread We were querying the application's FILEVERSIONINFO every time we needed to figure out the path for storing BrowserContext data. Now we cache the path the first time we need it, which is during application initialization and before IO prohibitions begin. --- brightray/browser/browser_context.cc | 6 +++++- brightray/browser/browser_context.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index c8b923977d..17ff9b2269 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -72,9 +72,13 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext(content::Prot } base::FilePath BrowserContext::GetPath() { + if (!path_.empty()) + return path_; + base::FilePath path; CHECK(PathService::Get(base::DIR_APP_DATA, &path)); - return path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); + path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); + return path_; } bool BrowserContext::IsOffTheRecord() const { diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index 47feccd042..a83e016e43 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -46,6 +46,7 @@ private: virtual content::SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; + base::FilePath path_; scoped_ptr resource_context_; scoped_refptr url_request_getter_; scoped_ptr prefs_;