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" |
11 #include "components/nacl/common/pnacl_types.h" | 11 #include "components/nacl/common/pnacl_types.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" |
14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
15 #include "net/base/test_completion_callback.h" | 15 #include "net/base/test_completion_callback.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 using content::BrowserThread; | 18 using content::BrowserThread; |
19 using base::FilePath; | 19 using base::FilePath; |
20 | 20 |
21 namespace pnacl { | 21 namespace pnacl { |
22 | 22 |
23 const int kTestDiskCacheSize = 16 * 1024 * 1024; | 23 const int kTestDiskCacheSize = 16 * 1024 * 1024; |
24 | 24 |
25 class PnaclTranslationCacheTest : public testing::Test { | 25 class PnaclTranslationCacheTest : public testing::Test { |
26 protected: | 26 protected: |
27 PnaclTranslationCacheTest() | 27 PnaclTranslationCacheTest() |
28 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} | 28 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} |
29 virtual ~PnaclTranslationCacheTest() {} | 29 ~PnaclTranslationCacheTest() override {} |
30 virtual void SetUp() { cache_.reset(new PnaclTranslationCache()); } | 30 void SetUp() override { cache_.reset(new PnaclTranslationCache()); } |
31 virtual void TearDown() { | 31 void TearDown() override { |
32 // The destructor of PnaclTranslationCacheWriteEntry posts a task to the IO | 32 // The destructor of PnaclTranslationCacheWriteEntry posts a task to the IO |
33 // thread to close the backend cache entry. We want to make sure the entries | 33 // thread to close the backend cache entry. We want to make sure the entries |
34 // are closed before we delete the backend (and in particular the destructor | 34 // are closed before we delete the backend (and in particular the destructor |
35 // for the memory backend has a DCHECK to verify this), so we run the loop | 35 // for the memory backend has a DCHECK to verify this), so we run the loop |
36 // here to ensure the task gets processed. | 36 // here to ensure the task gets processed. |
37 base::RunLoop().RunUntilIdle(); | 37 base::RunLoop().RunUntilIdle(); |
38 cache_.reset(); | 38 cache_.reset(); |
39 } | 39 } |
40 | 40 |
41 void InitBackend(bool in_mem); | 41 void InitBackend(bool in_mem); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 StoreNexe(test_key, test_store_val); | 277 StoreNexe(test_key, test_store_val); |
278 TestNexeCallback load_cb; | 278 TestNexeCallback load_cb; |
279 std::string nexe; | 279 std::string nexe; |
280 cache_->GetNexe(test_key + "a", load_cb.callback()); | 280 cache_->GetNexe(test_key + "a", load_cb.callback()); |
281 int rv; | 281 int rv; |
282 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv)); | 282 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv)); |
283 EXPECT_EQ(net::ERR_FAILED, rv); | 283 EXPECT_EQ(net::ERR_FAILED, rv); |
284 } | 284 } |
285 | 285 |
286 } // namespace pnacl | 286 } // namespace pnacl |
OLD | NEW |