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

Side by Side Diff: content/public/test/browser_test_base.cc

Issue 10959020: SystemMonitor refactoring: move power state monitor into a separate class called PowerMonitor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Revert using Singleton pattern for PowerMonitor Created 8 years, 1 month 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/public/test/browser_test_base.h" 5 #include "content/public/test/browser_test_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/stack_trace.h" 9 #include "base/debug/stack_trace.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "content/public/common/content_switches.h" 11 #include "content/public/common/content_switches.h"
12 #include "content/public/common/main_function_params.h" 12 #include "content/public/common/main_function_params.h"
13 13
14 #if defined(OS_MACOSX) 14 #if defined(OS_MACOSX)
15 #include "base/mac/mac_util.h" 15 #include "base/mac/mac_util.h"
16 #include "base/system_monitor/system_monitor.h" 16 #include "base/power_monitor/power_monitor.h"
17 #endif 17 #endif
18 18
19 extern int BrowserMain(const content::MainFunctionParams&); 19 extern int BrowserMain(const content::MainFunctionParams&);
20 20
21 namespace { 21 namespace {
22 22
23 #if defined(OS_POSIX) 23 #if defined(OS_POSIX)
24 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make 24 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make
25 // debugging easier) and also exit with a known error code (so that the test 25 // debugging easier) and also exit with a known error code (so that the test
26 // framework considers this a failure -- http://crbug.com/57578). 26 // framework considers this a failure -- http://crbug.com/57578).
27 // Note: We only want to do this in the browser process, and not forked 27 // Note: We only want to do this in the browser process, and not forked
28 // processes. That might lead to hangs because of locks inside tcmalloc or the 28 // processes. That might lead to hangs because of locks inside tcmalloc or the
29 // OS. See http://crbug.com/141302. 29 // OS. See http://crbug.com/141302.
30 static int g_browser_process_pid; 30 static int g_browser_process_pid;
31 static void DumpStackTraceSignalHandler(int signal) { 31 static void DumpStackTraceSignalHandler(int signal) {
32 if (g_browser_process_pid == base::GetCurrentProcId()) 32 if (g_browser_process_pid == base::GetCurrentProcId())
33 base::debug::StackTrace().PrintBacktrace(); 33 base::debug::StackTrace().PrintBacktrace();
34 _exit(128 + signal); 34 _exit(128 + signal);
35 } 35 }
36 #endif // defined(OS_POSIX) 36 #endif // defined(OS_POSIX)
37 37
38 } // namespace 38 } // namespace
39 39
40 namespace content { 40 namespace content {
41 41
42 BrowserTestBase::BrowserTestBase() { 42 BrowserTestBase::BrowserTestBase() {
43 #if defined(OS_MACOSX) 43 #if defined(OS_MACOSX)
44 base::mac::SetOverrideAmIBundled(true); 44 base::mac::SetOverrideAmIBundled(true);
45 base::SystemMonitor::AllocateSystemIOPorts(); 45 base::PowerMonitor::AllocateSystemIOPorts();
46 #endif 46 #endif
47 47
48 #if defined(OS_POSIX) 48 #if defined(OS_POSIX)
49 handle_sigterm_ = true; 49 handle_sigterm_ = true;
50 #endif 50 #endif
51 } 51 }
52 52
53 BrowserTestBase::~BrowserTestBase() { 53 BrowserTestBase::~BrowserTestBase() {
54 } 54 }
55 55
(...skipping 30 matching lines...) Expand all
86 86
87 void BrowserTestBase::CreateTestServer(const FilePath& test_server_base) { 87 void BrowserTestBase::CreateTestServer(const FilePath& test_server_base) {
88 CHECK(!test_server_.get()); 88 CHECK(!test_server_.get());
89 test_server_.reset(new net::TestServer( 89 test_server_.reset(new net::TestServer(
90 net::TestServer::TYPE_HTTP, 90 net::TestServer::TYPE_HTTP,
91 net::TestServer::kLocalhost, 91 net::TestServer::kLocalhost,
92 test_server_base)); 92 test_server_base));
93 } 93 }
94 94
95 } // namespace content 95 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698