summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_operation_unittest.cc
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 07:39:21 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 07:39:21 +0000
commite31d4c246deaefc59fe4f4fa66a74cd827694a41 (patch)
tree2481c2ac1d11a5f795c98463f1839627a05802a9 /webkit/fileapi/file_system_operation_unittest.cc
parent11f9de0523fc05d83a0daf8309cca788feb0d23a (diff)
downloadchromium_src-e31d4c246deaefc59fe4f4fa66a74cd827694a41.zip
chromium_src-e31d4c246deaefc59fe4f4fa66a74cd827694a41.tar.gz
chromium_src-e31d4c246deaefc59fe4f4fa66a74cd827694a41.tar.bz2
Leak fix in FileSystemOperationUnitTest.
BUG=83944 TEST=valgrind bots green Review URL: http://codereview.chromium.org/7053029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86792 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_operation_unittest.cc')
-rw-r--r--webkit/fileapi/file_system_operation_unittest.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/webkit/fileapi/file_system_operation_unittest.cc b/webkit/fileapi/file_system_operation_unittest.cc
index 9e4844d..ae80ad9 100644
--- a/webkit/fileapi/file_system_operation_unittest.cc
+++ b/webkit/fileapi/file_system_operation_unittest.cc
@@ -88,10 +88,29 @@ class MockQuotaManagerProxy : public QuotaManagerProxy {
public:
explicit MockQuotaManagerProxy(QuotaManager* quota_manager)
: QuotaManagerProxy(quota_manager,
- base::MessageLoopProxy::CreateForCurrentThread()) {}
+ base::MessageLoopProxy::CreateForCurrentThread()),
+ registered_client_(NULL) {
+ }
+
+ virtual ~MockQuotaManagerProxy() {
+ EXPECT_FALSE(registered_client_);
+ }
+
+ virtual void RegisterClient(QuotaClient* client) {
+ EXPECT_FALSE(registered_client_);
+ registered_client_ = client;
+ }
+
+ void SimulateQuotaManagerDestroyed() {
+ if (registered_client_) {
+ // We cannot call this in the destructor as the client (indirectly)
+ // holds a refptr of the proxy.
+ registered_client_->OnQuotaManagerDestroyed();
+ registered_client_ = NULL;
+ }
+ }
// We don't mock them.
- virtual void RegisterClient(QuotaClient* client) OVERRIDE {}
virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE {}
virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE {}
@@ -120,6 +139,7 @@ class MockQuotaManagerProxy : public QuotaManagerProxy {
MockQuotaManager* mock_manager() const {
return static_cast<MockQuotaManager*>(quota_manager());
}
+ QuotaClient* registered_client_;
};
FilePath ASCIIToFilePath(const std::string& str) {
@@ -287,6 +307,8 @@ void FileSystemOperationTest::SetUp() {
}
void FileSystemOperationTest::TearDown() {
+ // Let the client go away before dropping a ref of the quota manager proxy.
+ quota_manager_proxy()->SimulateQuotaManagerDestroyed();
quota_manager_ = NULL;
quota_manager_proxy_ = NULL;
test_helper_.TearDown();