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

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

Issue 23737002: Use sequenced blocking pool task to create PNaCl's nexe temp file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fuuuuuuuu rietveld 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_host.cc ('k') | no next file » | 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_host.h" 5 #include "chrome/browser/nacl_host/pnacl_host.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 FlushQueues(); 188 FlushQueues();
189 EXPECT_EQ(0U, host_->pending_translations()); 189 EXPECT_EQ(0U, host_->pending_translations());
190 // Check another successful miss 190 // Check another successful miss
191 GET_NEXE_FD(0, 0, false, info, false); 191 GET_NEXE_FD(0, 0, false, info, false);
192 FlushQueues(); 192 FlushQueues();
193 EXPECT_EQ(3, temp_callback_count_); 193 EXPECT_EQ(3, temp_callback_count_);
194 host_->TranslationFinished(0, 0, false); 194 host_->TranslationFinished(0, 0, false);
195 EXPECT_EQ(0U, host_->pending_translations()); 195 EXPECT_EQ(0U, host_->pending_translations());
196 } 196 }
197 197
198 // crbug.com/272492; flaky on all platforms. 198 TEST_F(PnaclHostTest, OverlappedMissesAfterTempReturn) {
199 TEST_F(PnaclHostTest, DISABLED_OverlappedMissesAfterTempReturn) {
200 nacl::PnaclCacheInfo info = GetTestCacheInfo(); 199 nacl::PnaclCacheInfo info = GetTestCacheInfo();
201 GET_NEXE_FD(0, 0, false, info, false); 200 GET_NEXE_FD(0, 0, false, info, false);
202 FlushQueues(); 201 FlushQueues();
203 EXPECT_EQ(1, temp_callback_count_); 202 EXPECT_EQ(1, temp_callback_count_);
204 EXPECT_EQ(1U, host_->pending_translations()); 203 EXPECT_EQ(1U, host_->pending_translations());
205 // Test that a second request for the same nexe while the first one is still 204 // Test that a second request for the same nexe while the first one is still
206 // outstanding eventually hits. 205 // outstanding eventually hits.
207 GET_NEXE_FD(0, 1, false, info, true); 206 GET_NEXE_FD(0, 1, false, info, true);
208 FlushQueues(); 207 FlushQueues();
209 EXPECT_EQ(2U, host_->pending_translations()); 208 EXPECT_EQ(2U, host_->pending_translations());
210 // The temp file should not be returned to the second request until after the 209 // The temp file should not be returned to the second request until after the
211 // first is finished translating. 210 // first is finished translating.
212 EXPECT_EQ(1, temp_callback_count_); 211 EXPECT_EQ(1, temp_callback_count_);
213 host_->TranslationFinished(0, 0, true); 212 host_->TranslationFinished(0, 0, true);
214 FlushQueues(); 213 FlushQueues();
215 EXPECT_EQ(2, temp_callback_count_); 214 EXPECT_EQ(2, temp_callback_count_);
216 EXPECT_EQ(0U, host_->pending_translations()); 215 EXPECT_EQ(0U, host_->pending_translations());
217 } 216 }
218 217
219 // crbug.com/272492; flaky on all platforms. 218 TEST_F(PnaclHostTest, OverlappedMissesBeforeTempReturn) {
220 TEST_F(PnaclHostTest, DISABLED_OverlappedMissesBeforeTempReturn) {
221 nacl::PnaclCacheInfo info = GetTestCacheInfo(); 219 nacl::PnaclCacheInfo info = GetTestCacheInfo();
222 GET_NEXE_FD(0, 0, false, info, false); 220 GET_NEXE_FD(0, 0, false, info, false);
223 // Send the 2nd fd request before the first one returns a temp file. 221 // Send the 2nd fd request before the first one returns a temp file.
224 GET_NEXE_FD(0, 1, false, info, true); 222 GET_NEXE_FD(0, 1, false, info, true);
225 FlushQueues(); 223 FlushQueues();
226 EXPECT_EQ(1, temp_callback_count_); 224 EXPECT_EQ(1, temp_callback_count_);
227 EXPECT_EQ(2U, host_->pending_translations()); 225 EXPECT_EQ(2U, host_->pending_translations());
228 FlushQueues(); 226 FlushQueues();
229 EXPECT_EQ(2U, host_->pending_translations()); 227 EXPECT_EQ(2U, host_->pending_translations());
230 EXPECT_EQ(1, temp_callback_count_); 228 EXPECT_EQ(1, temp_callback_count_);
(...skipping 30 matching lines...) Expand all
261 FlushQueues(); 259 FlushQueues();
262 EXPECT_EQ(0U, host_->pending_translations()); 260 EXPECT_EQ(0U, host_->pending_translations());
263 GET_NEXE_FD(0, 0, false, info, true); 261 GET_NEXE_FD(0, 0, false, info, true);
264 FlushQueues(); 262 FlushQueues();
265 GET_NEXE_FD(0, 1, false, info, true); 263 GET_NEXE_FD(0, 1, false, info, true);
266 FlushQueues(); 264 FlushQueues();
267 EXPECT_EQ(3, temp_callback_count_); 265 EXPECT_EQ(3, temp_callback_count_);
268 EXPECT_EQ(0U, host_->pending_translations()); 266 EXPECT_EQ(0U, host_->pending_translations());
269 } 267 }
270 268
271 // crbug.com/272492; flaky on all platforms. 269 TEST_F(PnaclHostTest, OverlappedMissesRendererClosing) {
272 TEST_F(PnaclHostTest, DISABLED_OverlappedMissesRendererClosing) {
273 nacl::PnaclCacheInfo info = GetTestCacheInfo(); 270 nacl::PnaclCacheInfo info = GetTestCacheInfo();
274 GET_NEXE_FD(0, 0, false, info, false); 271 GET_NEXE_FD(0, 0, false, info, false);
275 // Send the 2nd fd request from a different renderer. 272 // Send the 2nd fd request from a different renderer.
276 // Test that it eventually gets an fd after the first renderer closes. 273 // Test that it eventually gets an fd after the first renderer closes.
277 GET_NEXE_FD(1, 1, false, info, false); 274 GET_NEXE_FD(1, 1, false, info, false);
278 FlushQueues(); 275 FlushQueues();
279 EXPECT_EQ(1, temp_callback_count_); 276 EXPECT_EQ(1, temp_callback_count_);
280 EXPECT_EQ(2U, host_->pending_translations()); 277 EXPECT_EQ(2U, host_->pending_translations());
281 FlushQueues(); 278 FlushQueues();
282 EXPECT_EQ(2U, host_->pending_translations()); 279 EXPECT_EQ(2U, host_->pending_translations());
(...skipping 17 matching lines...) Expand all
300 FlushQueues(); 297 FlushQueues();
301 EXPECT_EQ(2, temp_callback_count_); 298 EXPECT_EQ(2, temp_callback_count_);
302 host_->TranslationFinished(0, 0, true); 299 host_->TranslationFinished(0, 0, true);
303 FlushQueues(); 300 FlushQueues();
304 // Check that an incognito translation can hit from a normal one. 301 // Check that an incognito translation can hit from a normal one.
305 GET_NEXE_FD(0, 0, true, info, true); 302 GET_NEXE_FD(0, 0, true, info, true);
306 FlushQueues(); 303 FlushQueues();
307 EXPECT_EQ(3, temp_callback_count_); 304 EXPECT_EQ(3, temp_callback_count_);
308 } 305 }
309 306
310 // crbug.com/272492; flaky on all platforms. 307 TEST_F(PnaclHostTest, IncognitoOverlappedMiss) {
311 TEST_F(PnaclHostTest, DISABLED_IncognitoOverlappedMiss) {
312 nacl::PnaclCacheInfo info = GetTestCacheInfo(); 308 nacl::PnaclCacheInfo info = GetTestCacheInfo();
313 GET_NEXE_FD(0, 0, true, info, false); 309 GET_NEXE_FD(0, 0, true, info, false);
314 GET_NEXE_FD(0, 1, false, info, false); 310 GET_NEXE_FD(0, 1, false, info, false);
315 FlushQueues(); 311 FlushQueues();
316 // Check that both translations have returned misses, (i.e. that the 312 // Check that both translations have returned misses, (i.e. that the
317 // second one has not blocked on the incognito one) 313 // second one has not blocked on the incognito one)
318 EXPECT_EQ(2, temp_callback_count_); 314 EXPECT_EQ(2, temp_callback_count_);
319 host_->TranslationFinished(0, 0, true); 315 host_->TranslationFinished(0, 0, true);
320 host_->TranslationFinished(0, 1, true); 316 host_->TranslationFinished(0, 1, true);
321 FlushQueues(); 317 FlushQueues();
322 EXPECT_EQ(0U, host_->pending_translations()); 318 EXPECT_EQ(0U, host_->pending_translations());
323 319
324 // Same test, but issue the 2nd request after the first has returned a miss. 320 // Same test, but issue the 2nd request after the first has returned a miss.
325 info.abi_version = 222; 321 info.abi_version = 222;
326 GET_NEXE_FD(0, 0, true, info, false); 322 GET_NEXE_FD(0, 0, true, info, false);
327 FlushQueues(); 323 FlushQueues();
328 EXPECT_EQ(3, temp_callback_count_); 324 EXPECT_EQ(3, temp_callback_count_);
329 GET_NEXE_FD(0, 1, false, info, false); 325 GET_NEXE_FD(0, 1, false, info, false);
330 FlushQueues(); 326 FlushQueues();
331 EXPECT_EQ(4, temp_callback_count_); 327 EXPECT_EQ(4, temp_callback_count_);
332 host_->RendererClosing(0); 328 host_->RendererClosing(0);
333 } 329 }
334 330
335 // crbug.com/272492; flaky on all platforms. 331 TEST_F(PnaclHostTest, IncognitoSecondOverlappedMiss) {
336 TEST_F(PnaclHostTest, DISABLED_IncognitoSecondOverlappedMiss) {
337 // If the non-incognito request comes first, it should 332 // If the non-incognito request comes first, it should
338 // behave exactly like OverlappedMissBeforeTempReturn 333 // behave exactly like OverlappedMissBeforeTempReturn
339 nacl::PnaclCacheInfo info = GetTestCacheInfo(); 334 nacl::PnaclCacheInfo info = GetTestCacheInfo();
340 GET_NEXE_FD(0, 0, false, info, false); 335 GET_NEXE_FD(0, 0, false, info, false);
341 // Send the 2nd fd request before the first one returns a temp file. 336 // Send the 2nd fd request before the first one returns a temp file.
342 GET_NEXE_FD(0, 1, true, info, true); 337 GET_NEXE_FD(0, 1, true, info, true);
343 FlushQueues(); 338 FlushQueues();
344 EXPECT_EQ(1, temp_callback_count_); 339 EXPECT_EQ(1, temp_callback_count_);
345 EXPECT_EQ(2U, host_->pending_translations()); 340 EXPECT_EQ(2U, host_->pending_translations());
346 FlushQueues(); 341 FlushQueues();
(...skipping 22 matching lines...) Expand all
369 // Since we are using a memory backend, the clear should happen immediately. 364 // Since we are using a memory backend, the clear should happen immediately.
370 host_->ClearTranslationCacheEntriesBetween(base::Time(), base::Time(), 365 host_->ClearTranslationCacheEntriesBetween(base::Time(), base::Time(),
371 base::Bind(cb.callback(), 0)); 366 base::Bind(cb.callback(), 0));
372 EXPECT_EQ(0, cb.GetResult(net::ERR_IO_PENDING)); 367 EXPECT_EQ(0, cb.GetResult(net::ERR_IO_PENDING));
373 // Check that the translation cache has been cleared 368 // Check that the translation cache has been cleared
374 EXPECT_EQ(0, GetCacheSize()); 369 EXPECT_EQ(0, GetCacheSize());
375 host_->RendererClosing(0); 370 host_->RendererClosing(0);
376 } 371 }
377 372
378 } // namespace pnacl 373 } // namespace pnacl
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/pnacl_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698