summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-05 21:02:28 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-05 21:02:28 +0000
commit38f285a515082e15e9be1a07985b2d1a37da4d9f (patch)
tree34bd260ee5f4aaa7ba39c8ba0cfad7d1d1aa7342 /chrome/browser/extensions
parent40e4bb53e1ed9f16f2ed9b5a10195f2a475ca169 (diff)
downloadchromium_src-38f285a515082e15e9be1a07985b2d1a37da4d9f.zip
chromium_src-38f285a515082e15e9be1a07985b2d1a37da4d9f.tar.gz
chromium_src-38f285a515082e15e9be1a07985b2d1a37da4d9f.tar.bz2
Delete temp extension directory on the file thread.
BUG=61922 Review URL: http://codereview.chromium.org/4506001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65250 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker.cc12
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc10
2 files changed, 16 insertions, 6 deletions
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.cc b/chrome/browser/extensions/sandboxed_extension_unpacker.cc
index 48daa6a..c1702b1 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker.cc
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker.cc
@@ -9,10 +9,10 @@
#include "base/base64.h"
#include "base/crypto/signature_verifier.h"
#include "base/file_util.h"
+#include "base/file_util_proxy.h"
#include "base/message_loop.h"
#include "base/scoped_handle.h"
#include "base/task.h"
-#include "base/thread_restrictions.h"
#include "base/utf_string_conversions.h" // TODO(viettrungluu): delete me.
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/extensions/extensions_service.h"
@@ -118,11 +118,11 @@ void SandboxedExtensionUnpacker::Start() {
}
SandboxedExtensionUnpacker::~SandboxedExtensionUnpacker() {
- // temp_dir_'s destructor will delete a directory on the file thread. Do
- // this on another thread to avoid slowing the UI thread.
- // http://crbug.com/61922
- base::ThreadRestrictions::ScopedAllowIO allow_io;
- temp_dir_.Delete();
+ base::FileUtilProxy::Delete(
+ BrowserThread::GetMessageLoopProxyForThread(thread_identifier_),
+ temp_dir_.Take(),
+ true,
+ NULL);
}
void SandboxedExtensionUnpacker::StartProcessOnIOThread(
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
index 4d893e1..1842e00 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
@@ -51,12 +51,17 @@ class MockSandboxedExtensionUnpackerClient
class SandboxedExtensionUnpackerTest : public testing::Test {
public:
virtual void SetUp() {
+ file_thread_.reset(new BrowserThread(BrowserThread::FILE, &loop_));
// It will delete itself.
client_ = new MockSandboxedExtensionUnpackerClient;
client_->DelegateToFake();
}
virtual void TearDown() {
+ // Need to destruct SandboxedExtensionUnpacker before the message loop since
+ // it posts a task to it.
+ sandboxed_unpacker_ = NULL;
+ loop_.RunAllPending();
// Clean up finally.
ASSERT_TRUE(file_util::Delete(install_dir_, true)) <<
install_dir_.value();
@@ -93,6 +98,9 @@ class SandboxedExtensionUnpackerTest : public testing::Test {
sandboxed_unpacker_ =
new SandboxedExtensionUnpacker(crx_path, temp_dir_, NULL, client_);
+ // Hack since SandboxedExtensionUnpacker gets its background thread id from
+ // the Start call, but we don't call it here.
+ sandboxed_unpacker_->thread_identifier_ = BrowserThread::FILE;
PrepareUnpackerEnv();
}
@@ -144,6 +152,8 @@ class SandboxedExtensionUnpackerTest : public testing::Test {
MockSandboxedExtensionUnpackerClient* client_;
scoped_ptr<ExtensionUnpacker> unpacker_;
scoped_refptr<SandboxedExtensionUnpacker> sandboxed_unpacker_;
+ MessageLoop loop_;
+ scoped_ptr<BrowserThread> file_thread_;
};
TEST_F(SandboxedExtensionUnpackerTest, NoCatalogsSuccess) {