| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/path_service.h" | 5 #include "base/path_service.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/background/background_contents_service.h" | 8 #include "chrome/browser/background/background_contents_service.h" |
| 9 #include "chrome/browser/background/background_contents_service_factory.h" | 9 #include "chrome/browser/background/background_contents_service_factory.h" |
| 10 #include "chrome/browser/background/background_mode_manager.h" | 10 #include "chrome/browser/background/background_mode_manager.h" |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 #define MAYBE_BackgroundKeepaliveActive DISABLED_BackgroundKeepaliveActive | 607 #define MAYBE_BackgroundKeepaliveActive DISABLED_BackgroundKeepaliveActive |
| 608 #else | 608 #else |
| 609 #define MAYBE_BackgroundKeepaliveActive BackgroundKeepaliveActive | 609 #define MAYBE_BackgroundKeepaliveActive BackgroundKeepaliveActive |
| 610 #endif | 610 #endif |
| 611 IN_PROC_BROWSER_TEST_F(AppBackgroundPageNaClTest, | 611 IN_PROC_BROWSER_TEST_F(AppBackgroundPageNaClTest, |
| 612 MAYBE_BackgroundKeepaliveActive) { | 612 MAYBE_BackgroundKeepaliveActive) { |
| 613 #if !defined(DISABLE_NACL) | 613 #if !defined(DISABLE_NACL) |
| 614 ExtensionTestMessageListener nacl_modules_loaded("nacl_modules_loaded", true); | 614 ExtensionTestMessageListener nacl_modules_loaded("nacl_modules_loaded", true); |
| 615 LaunchTestingApp(); | 615 LaunchTestingApp(); |
| 616 extensions::ProcessManager* manager = | 616 extensions::ProcessManager* manager = |
| 617 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); | 617 extensions::ProcessManager::Get(browser()->profile()); |
| 618 ImpulseCallbackCounter active_impulse_counter(manager, extension()->id()); | 618 ImpulseCallbackCounter active_impulse_counter(manager, extension()->id()); |
| 619 EXPECT_TRUE(nacl_modules_loaded.WaitUntilSatisfied()); | 619 EXPECT_TRUE(nacl_modules_loaded.WaitUntilSatisfied()); |
| 620 | 620 |
| 621 // Target .5 seconds: .5 seconds / 50ms throttle * 2 embeds == 20 impulses. | 621 // Target .5 seconds: .5 seconds / 50ms throttle * 2 embeds == 20 impulses. |
| 622 manager->SetKeepaliveImpulseCallbackForTesting( | 622 manager->SetKeepaliveImpulseCallbackForTesting( |
| 623 active_impulse_counter.SetGoalAndGetCallback(20)); | 623 active_impulse_counter.SetGoalAndGetCallback(20)); |
| 624 active_impulse_counter.Wait(); | 624 active_impulse_counter.Wait(); |
| 625 #endif | 625 #endif |
| 626 } | 626 } |
| 627 | 627 |
| 628 // Verify that nacl modules that go idle will not send keepalive impulses. | 628 // Verify that nacl modules that go idle will not send keepalive impulses. |
| 629 // Disabled on windows due to Win XP failures: | 629 // Disabled on windows due to Win XP failures: |
| 630 // DesktopWindowTreeHostWin::HandleCreate not implemented. crbug.com/331954 | 630 // DesktopWindowTreeHostWin::HandleCreate not implemented. crbug.com/331954 |
| 631 #if defined(OS_WIN) | 631 #if defined(OS_WIN) |
| 632 #define MAYBE_BackgroundKeepaliveIdle DISABLED_BackgroundKeepaliveIdle | 632 #define MAYBE_BackgroundKeepaliveIdle DISABLED_BackgroundKeepaliveIdle |
| 633 #else | 633 #else |
| 634 // ASAN errors appearing: https://crbug.com/332440 | 634 // ASAN errors appearing: https://crbug.com/332440 |
| 635 #define MAYBE_BackgroundKeepaliveIdle DISABLED_BackgroundKeepaliveIdle | 635 #define MAYBE_BackgroundKeepaliveIdle DISABLED_BackgroundKeepaliveIdle |
| 636 #endif | 636 #endif |
| 637 IN_PROC_BROWSER_TEST_F(AppBackgroundPageNaClTest, | 637 IN_PROC_BROWSER_TEST_F(AppBackgroundPageNaClTest, |
| 638 MAYBE_BackgroundKeepaliveIdle) { | 638 MAYBE_BackgroundKeepaliveIdle) { |
| 639 #if !defined(DISABLE_NACL) | 639 #if !defined(DISABLE_NACL) |
| 640 ExtensionTestMessageListener nacl_modules_loaded("nacl_modules_loaded", true); | 640 ExtensionTestMessageListener nacl_modules_loaded("nacl_modules_loaded", true); |
| 641 LaunchTestingApp(); | 641 LaunchTestingApp(); |
| 642 extensions::ProcessManager* manager = | 642 extensions::ProcessManager* manager = |
| 643 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); | 643 extensions::ProcessManager::Get(browser()->profile()); |
| 644 ImpulseCallbackCounter idle_impulse_counter(manager, extension()->id()); | 644 ImpulseCallbackCounter idle_impulse_counter(manager, extension()->id()); |
| 645 EXPECT_TRUE(nacl_modules_loaded.WaitUntilSatisfied()); | 645 EXPECT_TRUE(nacl_modules_loaded.WaitUntilSatisfied()); |
| 646 | 646 |
| 647 manager->SetKeepaliveImpulseDecrementCallbackForTesting( | 647 manager->SetKeepaliveImpulseDecrementCallbackForTesting( |
| 648 idle_impulse_counter.SetGoalAndGetCallback(1)); | 648 idle_impulse_counter.SetGoalAndGetCallback(1)); |
| 649 nacl_modules_loaded.Reply("be idle"); | 649 nacl_modules_loaded.Reply("be idle"); |
| 650 idle_impulse_counter.Wait(); | 650 idle_impulse_counter.Wait(); |
| 651 #endif | 651 #endif |
| 652 } | 652 } |
| OLD | NEW |