Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/nacl/browser/pnacl_translation_cache.h" | 5 #include "components/nacl/browser/pnacl_translation_cache.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 base::ScopedTempDir temp_dir_; | 53 base::ScopedTempDir temp_dir_; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 void PnaclTranslationCacheTest::InitBackend(bool in_mem) { | 56 void PnaclTranslationCacheTest::InitBackend(bool in_mem) { |
| 57 net::TestCompletionCallback init_cb; | 57 net::TestCompletionCallback init_cb; |
| 58 if (!in_mem) { | 58 if (!in_mem) { |
| 59 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 59 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 60 } | 60 } |
| 61 // Use the private init method so we can control the size | 61 // Use the private init method so we can control the size |
| 62 int rv = cache_->Init(in_mem ? net::MEMORY_CACHE : net::PNACL_CACHE, | 62 int rv = cache_->Init(in_mem ? net::MEMORY_CACHE : net::PNACL_CACHE, |
| 63 temp_dir_.path(), | 63 in_mem ? base::FilePath() : temp_dir_.GetPath(), |
|
vabr (Chromium)
2016/09/14 13:32:41
Before: ScopedTempDir needed to trust InitBackend
Mark Seaborn
2016/09/14 18:27:26
Can you put that note in the commit message, pleas
vabr (Chromium)
2016/09/14 20:14:39
I made an attempt at adding this to the CL. There
| |
| 64 in_mem ? kMaxMemCacheSize : kTestDiskCacheSize, | 64 in_mem ? kMaxMemCacheSize : kTestDiskCacheSize, |
| 65 init_cb.callback()); | 65 init_cb.callback()); |
| 66 if (in_mem) | 66 if (in_mem) |
| 67 ASSERT_EQ(net::OK, rv); | 67 ASSERT_EQ(net::OK, rv); |
| 68 ASSERT_EQ(net::OK, init_cb.GetResult(rv)); | 68 ASSERT_EQ(net::OK, init_cb.GetResult(rv)); |
| 69 ASSERT_EQ(0, cache_->Size()); | 69 ASSERT_EQ(0, cache_->Size()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void PnaclTranslationCacheTest::StoreNexe(const std::string& key, | 72 void PnaclTranslationCacheTest::StoreNexe(const std::string& key, |
| 73 const std::string& nexe) { | 73 const std::string& nexe) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 StoreNexe(test_key, test_store_val); | 295 StoreNexe(test_key, test_store_val); |
| 296 TestNexeCallback load_cb; | 296 TestNexeCallback load_cb; |
| 297 std::string nexe; | 297 std::string nexe; |
| 298 cache_->GetNexe(test_key + "a", load_cb.callback()); | 298 cache_->GetNexe(test_key + "a", load_cb.callback()); |
| 299 int rv; | 299 int rv; |
| 300 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv)); | 300 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv)); |
| 301 EXPECT_EQ(net::ERR_FAILED, rv); | 301 EXPECT_EQ(net::ERR_FAILED, rv); |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace pnacl | 304 } // namespace pnacl |
| OLD | NEW |