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

Side by Side Diff: chrome/browser/nacl_host/pnacl_translation_cache_unittest.cc

Issue 24208003: Add PNACL_CACHE cache backend type, and allow larger files for this type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/nacl_host/pnacl_translation_cache.cc ('k') | net/base/cache_type.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/nacl_host/pnacl_translation_cache.h" 5 #include "chrome/browser/nacl_host/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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 content::TestBrowserThreadBundle thread_bundle_; 46 content::TestBrowserThreadBundle thread_bundle_;
47 base::ScopedTempDir temp_dir_; 47 base::ScopedTempDir temp_dir_;
48 }; 48 };
49 49
50 void PnaclTranslationCacheTest::InitBackend(bool in_mem) { 50 void PnaclTranslationCacheTest::InitBackend(bool in_mem) {
51 net::TestCompletionCallback init_cb; 51 net::TestCompletionCallback init_cb;
52 if (!in_mem) { 52 if (!in_mem) {
53 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 53 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
54 } 54 }
55 // Use the private init method so we can control the size 55 // Use the private init method so we can control the size
56 int rv = cache_->Init(in_mem ? net::MEMORY_CACHE : net::DISK_CACHE, 56 int rv = cache_->Init(in_mem ? net::MEMORY_CACHE : net::PNACL_CACHE,
57 temp_dir_.path(), 57 temp_dir_.path(),
58 in_mem ? kMaxMemCacheSize : kTestDiskCacheSize, 58 in_mem ? kMaxMemCacheSize : kTestDiskCacheSize,
59 init_cb.callback()); 59 init_cb.callback());
60 if (in_mem) 60 if (in_mem)
61 ASSERT_EQ(net::OK, rv); 61 ASSERT_EQ(net::OK, rv);
62 ASSERT_EQ(net::OK, init_cb.GetResult(rv)); 62 ASSERT_EQ(net::OK, init_cb.GetResult(rv));
63 ASSERT_EQ(0, cache_->Size()); 63 ASSERT_EQ(0, cache_->Size());
64 } 64 }
65 65
66 void PnaclTranslationCacheTest::StoreNexe(const std::string& key, 66 void PnaclTranslationCacheTest::StoreNexe(const std::string& key,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv)); 113 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv));
114 EXPECT_EQ(net::OK, rv); 114 EXPECT_EQ(net::OK, rv);
115 if (buf.get() == NULL) // for some reason ASSERT macros don't work here. 115 if (buf.get() == NULL) // for some reason ASSERT macros don't work here.
116 return std::string(); 116 return std::string();
117 std::string nexe(buf->data(), buf->size()); 117 std::string nexe(buf->data(), buf->size());
118 return nexe; 118 return nexe;
119 } 119 }
120 120
121 static const std::string test_key("1"); 121 static const std::string test_key("1");
122 static const std::string test_store_val("testnexe"); 122 static const std::string test_store_val("testnexe");
123 static const int kLargeNexeSize = 2 * 1024 * 1024; 123 static const int kLargeNexeSize = 8 * 1024 * 1024;
124 124
125 TEST(PnaclTranslationCacheKeyTest, CacheKeyTest) { 125 TEST(PnaclTranslationCacheKeyTest, CacheKeyTest) {
126 nacl::PnaclCacheInfo info; 126 nacl::PnaclCacheInfo info;
127 info.pexe_url = GURL("http://www.google.com"); 127 info.pexe_url = GURL("http://www.google.com");
128 info.abi_version = 0; 128 info.abi_version = 0;
129 info.opt_level = 0; 129 info.opt_level = 0;
130 std::string test_time("Wed, 15 Nov 1995 06:25:24 GMT"); 130 std::string test_time("Wed, 15 Nov 1995 06:25:24 GMT");
131 base::Time::FromString(test_time.c_str(), &info.last_modified); 131 base::Time::FromString(test_time.c_str(), &info.last_modified);
132 // Basic check for URL and time components 132 // Basic check for URL and time components
133 EXPECT_EQ("ABI:0;opt:0;URL:http://www.google.com/;" 133 EXPECT_EQ("ABI:0;opt:0;URL:http://www.google.com/;"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 StoreNexe(test_key, test_store_val); 260 StoreNexe(test_key, test_store_val);
261 TestNexeCallback load_cb; 261 TestNexeCallback load_cb;
262 std::string nexe; 262 std::string nexe;
263 cache_->GetNexe(test_key + "a", load_cb.callback()); 263 cache_->GetNexe(test_key + "a", load_cb.callback());
264 int rv; 264 int rv;
265 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv)); 265 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv));
266 EXPECT_EQ(net::ERR_FAILED, rv); 266 EXPECT_EQ(net::ERR_FAILED, rv);
267 } 267 }
268 268
269 } // namespace pnacl 269 } // namespace pnacl
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/pnacl_translation_cache.cc ('k') | net/base/cache_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698