diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 20:37:41 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 20:37:41 +0000 |
commit | 66e4eb3c01053c6642804a4f8e188bd05aab4790 (patch) | |
tree | fe227c6799230954c48cd70db60d05eae63cbe44 /chrome/browser/extensions/crx_installer.cc | |
parent | a3ed6c82468f9f704a1b7e112ea3c132adb5ea2e (diff) | |
download | chromium_src-66e4eb3c01053c6642804a4f8e188bd05aab4790.zip chromium_src-66e4eb3c01053c6642804a4f8e188bd05aab4790.tar.gz chromium_src-66e4eb3c01053c6642804a4f8e188bd05aab4790.tar.bz2 |
Unrevert again r63919: "Part 2 of immutable Extension refactor."
(Last landing broke chromeos and chromium linux builder.)
I made Extension a refcounted object, and privitized the existing
con/destructor and InitFromValue. The only way to get an Extension is to call
a factory method.
In the next CL, I plan to make the factory method return a const Extension,
to guarantee that no one can modify the Extension object after creation.
Note: There was a tricky part of this CL because of the difference in
semantics between scoped_ptr and scoped_refptr. I had to be careful not to use
ptr.release(), since that would result in leaks (an un-Released AddRef).
BUG=56558
TEST=no functional change
Original Review URL: http://codereview.chromium.org/3982001
TBR=aa
Review URL: http://codereview.chromium.org/4119010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/crx_installer.cc')
-rw-r--r-- | chrome/browser/extensions/crx_installer.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index 4246ffa..07aa3d08 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -147,8 +147,8 @@ void CrxInstaller::InstallUserScript(const FilePath& source_file, void CrxInstaller::ConvertUserScriptOnFileThread() { std::string error; - Extension* extension = ConvertUserScriptToExtension(source_file_, - original_url_, &error); + scoped_refptr<Extension> extension = + ConvertUserScriptToExtension(source_file_, original_url_, &error); if (!extension) { ReportFailureFromFileThread(error); return; @@ -243,7 +243,7 @@ void CrxInstaller::OnUnpackSuccess(const FilePath& temp_dir, DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); // Note: We take ownership of |extension| and |temp_dir|. - extension_.reset(extension); + extension_ = extension; temp_dir_ = temp_dir; // We don't have to delete the unpack dir explicity since it is a child of @@ -357,8 +357,8 @@ void CrxInstaller::CompleteInstall() { // TODO(aa): All paths to resources inside extensions should be created // lazily and based on the Extension's root path at that moment. std::string error; - extension_.reset(extension_file_util::LoadExtension( - version_dir, install_source_, true, &error)); + extension_ = extension_file_util::LoadExtension( + version_dir, install_source_, true, &error); DCHECK(error.empty()); ReportSuccessFromFileThread(); @@ -406,8 +406,8 @@ void CrxInstaller::ReportSuccessFromUIThread() { // Tell the frontend about the installation and hand off ownership of // extension_ to it. - frontend_->OnExtensionInstalled(extension_.release(), - allow_privilege_increase_); + frontend_->OnExtensionInstalled(extension_, allow_privilege_increase_); + extension_ = NULL; // We're done. We don't post any more tasks to ourselves so we are deleted // soon. |