diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-23 22:19:32 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-23 22:19:32 +0000 |
commit | c6bbd46c7a5b0d8b74a180e06cd45f6dd8ac18a4 (patch) | |
tree | 13ea96d790fdc45b170d6f16bbb25f0498a11f0a /chrome | |
parent | 769a530e1017bbfad56115ff80cc1a0c6b8c6979 (diff) | |
download | chromium_src-c6bbd46c7a5b0d8b74a180e06cd45f6dd8ac18a4.zip chromium_src-c6bbd46c7a5b0d8b74a180e06cd45f6dd8ac18a4.tar.gz chromium_src-c6bbd46c7a5b0d8b74a180e06cd45f6dd8ac18a4.tar.bz2 |
I'm relanding the UserDataManager leak fix. I didn't realize we had
stubs for mac which needed to be updated too. This time I'll wait for
the bots to finish compiling before committing.
BUG=none
TEST=none
TBR=munjal
Review URL: http://codereview.chromium.org/18566
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_main.cc | 3 | ||||
-rw-r--r-- | chrome/browser/user_data_manager.cc | 5 | ||||
-rw-r--r-- | chrome/browser/user_data_manager.h | 2 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.cpp | 3 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.h | 2 |
5 files changed, 9 insertions, 6 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 29d984e..b492380 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -309,7 +309,7 @@ int BrowserMain(const MainFunctionParams& parameters) { StatisticsRecorder statistics; // Initialize the shared instance of user data manager. - UserDataManager::Create(); + scoped_ptr<UserDataManager> user_data_manager(UserDataManager::Create()); // Try to create/load the profile. ProfileManager* profile_manager = browser_process->profile_manager(); @@ -546,4 +546,3 @@ int BrowserMain(const MainFunctionParams& parameters) { return result_code; } - diff --git a/chrome/browser/user_data_manager.cc b/chrome/browser/user_data_manager.cc index 554c53f..bc078db 100644 --- a/chrome/browser/user_data_manager.cc +++ b/chrome/browser/user_data_manager.cc @@ -91,11 +91,12 @@ static const wchar_t kProfileFolderSeparator[] = L"-"; UserDataManager* UserDataManager::instance_ = NULL; // static -void UserDataManager::Create() { +UserDataManager* UserDataManager::Create() { DCHECK(!instance_); std::wstring user_data; PathService::Get(chrome::DIR_USER_DATA, &user_data); instance_ = new UserDataManager(user_data); + return instance_; } // static @@ -123,6 +124,8 @@ UserDataManager::UserDataManager(const std::wstring& user_data_root) } UserDataManager::~UserDataManager() { + if (instance_ == this) + instance_ = NULL; } // static diff --git a/chrome/browser/user_data_manager.h b/chrome/browser/user_data_manager.h index f5e4522..f688448 100644 --- a/chrome/browser/user_data_manager.h +++ b/chrome/browser/user_data_manager.h @@ -27,7 +27,7 @@ class UserDataManager { public: // Creates the shared instance of this class. This method is not thread-safe, // so the shared instance should be created on the main thread. - static void Create(); + static UserDataManager* Create(); // Returns the shared instance. CreateInstance must be called before callling // this method. diff --git a/chrome/common/temp_scaffolding_stubs.cpp b/chrome/common/temp_scaffolding_stubs.cpp index 301d935..1228938 100644 --- a/chrome/common/temp_scaffolding_stubs.cpp +++ b/chrome/common/temp_scaffolding_stubs.cpp @@ -109,11 +109,12 @@ bool BrowserInit::LaunchBrowserImpl(const CommandLine& parsed_command_line, UserDataManager* UserDataManager::instance_ = NULL; -void UserDataManager::Create() { +UserDataManager* UserDataManager::Create() { DCHECK(!instance_); std::wstring user_data; PathService::Get(chrome::DIR_USER_DATA, &user_data); instance_ = new UserDataManager(user_data); + return instance_; } UserDataManager* UserDataManager::Get() { diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h index 8870522..97de3fb0 100644 --- a/chrome/common/temp_scaffolding_stubs.h +++ b/chrome/common/temp_scaffolding_stubs.h @@ -155,7 +155,7 @@ class FirstRunBrowserProcess : public BrowserProcessImpl { class UserDataManager { public: - static void Create(); + static UserDataManager* Create(); static UserDataManager* Get(); explicit UserDataManager(const std::wstring& user_data_root) { } |