Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2159)

Unified Diff: chrome/browser/nacl_host/pnacl_translation_cache_unittest.cc

Issue 16295020: Fix leak in pnacl translation cache and remove check suppressions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/nacl_host/pnacl_translation_cache.cc ('k') | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/nacl_host/pnacl_translation_cache_unittest.cc
diff --git a/chrome/browser/nacl_host/pnacl_translation_cache_unittest.cc b/chrome/browser/nacl_host/pnacl_translation_cache_unittest.cc
index 69b79e6475f73e48db96e5c5b2e915c872834ad7..902d9a3207c6ba939ff709d4eb6f9ad475e71f3e 100644
--- a/chrome/browser/nacl_host/pnacl_translation_cache_unittest.cc
+++ b/chrome/browser/nacl_host/pnacl_translation_cache_unittest.cc
@@ -7,6 +7,7 @@
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/message_loop.h"
+#include "base/run_loop.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread.h"
#include "net/base/test_completion_callback.h"
@@ -23,7 +24,15 @@ class PNaClTranslationCacheTest : public testing::Test {
io_thread_(BrowserThread::IO, &message_loop_) {}
virtual ~PNaClTranslationCacheTest() {}
virtual void SetUp() { cache_ = new PNaClTranslationCache(); }
- virtual void TearDown() { delete cache_; }
+ virtual void TearDown() {
+ // The destructor of PNaClTranslationCacheWriteEntry posts a task to the IO
+ // thread to close the backend cache entry. We want to make sure the entries
+ // are closed before we delete the backend (and in particular the destructor
+ // for the memory backend has a DCHECK to verify this), so we run the loop
+ // here to ensure the task gets processed.
+ base::RunLoop().RunUntilIdle();
+ delete cache_;
+ }
protected:
PNaClTranslationCache* cache_;
@@ -71,6 +80,8 @@ TEST_F(PNaClTranslationCacheTest, InMemSizeLimit) {
net::TestCompletionCallback store_cb;
cache_->StoreNexe("1", large_buffer, store_cb.callback());
EXPECT_EQ(net::ERR_FAILED, store_cb.GetResult(net::ERR_IO_PENDING));
+ base::RunLoop().RunUntilIdle(); // Ensure the entry is closed.
+ EXPECT_EQ(0, cache_->Size());
}
} // namespace nacl_cache
« no previous file with comments | « chrome/browser/nacl_host/pnacl_translation_cache.cc ('k') | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698