OLD | NEW |
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/test/content_browser_test.h" | 5 #include "content/test/content_browser_test.h" |
6 | 6 |
7 #include "base/debug/stack_trace.h" | 7 #include "base/debug/stack_trace.h" |
8 #include "base/mac/scoped_nsautorelease_pool.h" | |
9 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
10 #include "content/shell/shell.h" | 9 #include "content/shell/shell.h" |
11 #include "content/shell/shell_main_delegate.h" | 10 #include "content/shell/shell_main_delegate.h" |
12 #include "content/test/test_content_client.h" | 11 #include "content/test/test_content_client.h" |
13 | 12 |
| 13 #if defined(OS_MACOSX) |
| 14 #include "base/mac/scoped_nsautorelease_pool.h" |
| 15 #endif |
| 16 |
14 ContentBrowserTest::ContentBrowserTest() { | 17 ContentBrowserTest::ContentBrowserTest() { |
15 } | 18 } |
16 | 19 |
17 ContentBrowserTest::~ContentBrowserTest() { | 20 ContentBrowserTest::~ContentBrowserTest() { |
18 } | 21 } |
19 | 22 |
20 void ContentBrowserTest::SetUp() { | 23 void ContentBrowserTest::SetUp() { |
21 DCHECK(!content::GetContentClient()); | 24 DCHECK(!content::GetContentClient()); |
22 shell_main_delegate_.reset(new ShellMainDelegate); | 25 shell_main_delegate_.reset(new ShellMainDelegate); |
23 shell_main_delegate_->PreSandboxStartup(); | 26 shell_main_delegate_->PreSandboxStartup(); |
(...skipping 15 matching lines...) Expand all Loading... |
39 base::debug::StackTrace().PrintBacktrace(); | 42 base::debug::StackTrace().PrintBacktrace(); |
40 _exit(128 + signal); | 43 _exit(128 + signal); |
41 } | 44 } |
42 #endif // defined(OS_POSIX) | 45 #endif // defined(OS_POSIX) |
43 | 46 |
44 void ContentBrowserTest::RunTestOnMainThreadLoop() { | 47 void ContentBrowserTest::RunTestOnMainThreadLoop() { |
45 #if defined(OS_POSIX) | 48 #if defined(OS_POSIX) |
46 signal(SIGTERM, DumpStackTraceSignalHandler); | 49 signal(SIGTERM, DumpStackTraceSignalHandler); |
47 #endif // defined(OS_POSIX) | 50 #endif // defined(OS_POSIX) |
48 | 51 |
| 52 #if defined(OS_MACOSX) |
49 // On Mac, without the following autorelease pool, code which is directly | 53 // On Mac, without the following autorelease pool, code which is directly |
50 // executed (as opposed to executed inside a message loop) would autorelease | 54 // executed (as opposed to executed inside a message loop) would autorelease |
51 // objects into a higher-level pool. This pool is not recycled in-sync with | 55 // objects into a higher-level pool. This pool is not recycled in-sync with |
52 // the message loops' pools and causes problems with code relying on | 56 // the message loops' pools and causes problems with code relying on |
53 // deallocation via an autorelease pool (such as browser window closure and | 57 // deallocation via an autorelease pool (such as browser window closure and |
54 // browser shutdown). To avoid this, the following pool is recycled after each | 58 // browser shutdown). To avoid this, the following pool is recycled after each |
55 // time code is directly executed. | 59 // time code is directly executed. |
56 base::mac::ScopedNSAutoreleasePool pool; | 60 base::mac::ScopedNSAutoreleasePool pool; |
| 61 #endif |
57 | 62 |
58 // Pump startup related events. | 63 // Pump startup related events. |
59 MessageLoopForUI::current()->RunAllPending(); | 64 MessageLoopForUI::current()->RunAllPending(); |
| 65 |
| 66 #if defined(OS_MACOSX) |
60 pool.Recycle(); | 67 pool.Recycle(); |
| 68 #endif |
61 | 69 |
62 RunTestOnMainThread(); | 70 RunTestOnMainThread(); |
| 71 #if defined(OS_MACOSX) |
63 pool.Recycle(); | 72 pool.Recycle(); |
| 73 #endif |
64 | 74 |
65 MessageLoopForUI::current()->Quit(); | 75 MessageLoopForUI::current()->Quit(); |
| 76 #if defined(OS_MACOSX) |
66 pool.Recycle(); | 77 pool.Recycle(); |
| 78 #endif |
67 } | 79 } |
OLD | NEW |