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

Side by Side Diff: content/renderer/render_thread_impl_browsertest.cc

Issue 2552413002: Do not run discardable memory related browser test for official build. (Closed)
Patch Set: Fix a build issue Created 4 years 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
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 "content/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/memory/discardable_memory.h" 14 #include "base/memory/discardable_memory.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/threading/sequenced_worker_pool.h" 18 #include "base/threading/sequenced_worker_pool.h"
19 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
20 #include "build/build_config.h"
21 #include "cc/output/buffer_to_texture_target_map.h" 20 #include "cc/output/buffer_to_texture_target_map.h"
22 #include "components/discardable_memory/client/client_discardable_shared_memory_ manager.h"
23 #include "components/discardable_memory/service/discardable_shared_memory_manage r.h"
24 #include "content/app/mojo/mojo_init.h" 21 #include "content/app/mojo/mojo_init.h"
25 #include "content/child/child_gpu_memory_buffer_manager.h" 22 #include "content/child/child_gpu_memory_buffer_manager.h"
26 #include "content/common/in_process_child_thread_params.h" 23 #include "content/common/in_process_child_thread_params.h"
27 #include "content/common/resource_messages.h" 24 #include "content/common/resource_messages.h"
28 #include "content/common/service_manager/child_connection.h" 25 #include "content/common/service_manager/child_connection.h"
29 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/content_browser_client.h" 27 #include "content/public/browser/content_browser_client.h"
31 #include "content/public/common/content_client.h" 28 #include "content/public/common/content_client.h"
32 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
33 #include "content/public/common/service_manager_connection.h" 30 #include "content/public/common/service_manager_connection.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 ::testing::Combine(::testing::Values(kDisableNativeBuffers, 379 ::testing::Combine(::testing::Values(kDisableNativeBuffers,
383 kEnableNativeBuffers), 380 kEnableNativeBuffers),
384 // These formats are guaranteed to work on all platforms. 381 // These formats are guaranteed to work on all platforms.
385 ::testing::Values(gfx::BufferFormat::R_8, 382 ::testing::Values(gfx::BufferFormat::R_8,
386 gfx::BufferFormat::BGR_565, 383 gfx::BufferFormat::BGR_565,
387 gfx::BufferFormat::RGBA_4444, 384 gfx::BufferFormat::RGBA_4444,
388 gfx::BufferFormat::RGBA_8888, 385 gfx::BufferFormat::RGBA_8888,
389 gfx::BufferFormat::BGRA_8888, 386 gfx::BufferFormat::BGRA_8888,
390 gfx::BufferFormat::YVU_420))); 387 gfx::BufferFormat::YVU_420)));
391 388
392 class RenderThreadImplDiscardableMemoryBrowserTest : public ContentBrowserTest {
393 public:
394 RenderThreadImplDiscardableMemoryBrowserTest()
395 : child_discardable_shared_memory_manager_(nullptr) {}
396
397 // Overridden from BrowserTestBase:
398 void SetUpCommandLine(base::CommandLine* command_line) override {
399 command_line->AppendSwitch(switches::kSingleProcess);
400 }
401 void SetUpOnMainThread() override {
402 NavigateToURL(shell(), GURL(url::kAboutBlankURL));
403 PostTaskToInProcessRendererAndWait(base::Bind(
404 &RenderThreadImplDiscardableMemoryBrowserTest::SetUpOnRenderThread,
405 base::Unretained(this)));
406 }
407
408 discardable_memory::ClientDiscardableSharedMemoryManager*
409 child_discardable_shared_memory_manager() {
410 return child_discardable_shared_memory_manager_;
411 }
412
413 private:
414 void SetUpOnRenderThread() {
415 child_discardable_shared_memory_manager_ =
416 RenderThreadImpl::current()->GetDiscardableSharedMemoryManagerForTest();
417 }
418
419 discardable_memory::ClientDiscardableSharedMemoryManager*
420 child_discardable_shared_memory_manager_;
421 };
422
423 IN_PROC_BROWSER_TEST_F(RenderThreadImplDiscardableMemoryBrowserTest,
424 LockDiscardableMemory) {
425 const size_t kSize = 1024 * 1024; // 1MiB.
426
427 std::unique_ptr<base::DiscardableMemory> memory =
428 child_discardable_shared_memory_manager()
429 ->AllocateLockedDiscardableMemory(kSize);
430
431 ASSERT_TRUE(memory);
432 void* addr = memory->data();
433 ASSERT_NE(nullptr, addr);
434
435 memory->Unlock();
436
437 // Purge all unlocked memory.
438 discardable_memory::DiscardableSharedMemoryManager::GetInstance()
439 ->SetMemoryLimit(0);
440
441 // Should fail as memory should have been purged.
442 EXPECT_FALSE(memory->Lock());
443 }
444
445 // Disable the test for the Android asan build.
446 // See http://crbug.com/667837 for detail.
447 #if !(defined(OS_ANDROID) && defined(ADDRESS_SANITIZER))
448 IN_PROC_BROWSER_TEST_F(RenderThreadImplDiscardableMemoryBrowserTest,
449 DiscardableMemoryAddressSpace) {
450 const size_t kLargeSize = 4 * 1024 * 1024; // 4MiB.
451 const size_t kNumberOfInstances = 1024 + 1; // >4GiB total.
452
453 ScopedVector<base::DiscardableMemory> instances;
454 for (size_t i = 0; i < kNumberOfInstances; ++i) {
455 std::unique_ptr<base::DiscardableMemory> memory =
456 child_discardable_shared_memory_manager()
457 ->AllocateLockedDiscardableMemory(kLargeSize);
458 ASSERT_TRUE(memory);
459 void* addr = memory->data();
460 ASSERT_NE(nullptr, addr);
461 memory->Unlock();
462 instances.push_back(std::move(memory));
463 }
464 }
465 #endif
466
467 IN_PROC_BROWSER_TEST_F(RenderThreadImplDiscardableMemoryBrowserTest,
468 ReleaseFreeDiscardableMemory) {
469 const size_t kSize = 1024 * 1024; // 1MiB.
470
471 std::unique_ptr<base::DiscardableMemory> memory =
472 child_discardable_shared_memory_manager()
473 ->AllocateLockedDiscardableMemory(kSize);
474
475 EXPECT_TRUE(memory);
476 memory.reset();
477
478 EXPECT_GE(discardable_memory::DiscardableSharedMemoryManager::GetInstance()
479 ->GetBytesAllocated(),
480 kSize);
481
482 child_discardable_shared_memory_manager()->ReleaseFreeMemory();
483
484 // Busy wait for host memory usage to be reduced.
485 base::TimeTicks end =
486 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(5);
487 while (base::TimeTicks::Now() < end) {
488 if (!discardable_memory::DiscardableSharedMemoryManager::GetInstance()
489 ->GetBytesAllocated())
490 break;
491 }
492
493 EXPECT_LT(base::TimeTicks::Now(), end);
494 }
495
496 } // namespace 389 } // namespace
497 } // namespace content 390 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698