OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <mach/mach.h> | 5 #include <mach/mach.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // the number of open ports. This is used to protect against leaking Mach ports, | 23 // the number of open ports. This is used to protect against leaking Mach ports, |
24 // which was the source of <http://crbug.com/105513>. | 24 // which was the source of <http://crbug.com/105513>. |
25 class MachPortsTest : public InProcessBrowserTest { | 25 class MachPortsTest : public InProcessBrowserTest { |
26 public: | 26 public: |
27 MachPortsTest() { | 27 MachPortsTest() { |
28 embedded_test_server()->ServeFilesFromSourceDirectory( | 28 embedded_test_server()->ServeFilesFromSourceDirectory( |
29 "data/mach_ports/moz"); | 29 "data/mach_ports/moz"); |
30 } | 30 } |
31 | 31 |
32 void SetUpOnMainThread() override { | 32 void SetUpOnMainThread() override { |
33 InProcessBrowserTest::SetUpOnMainThread(); | |
34 ASSERT_TRUE(embedded_test_server()->Start()); | 33 ASSERT_TRUE(embedded_test_server()->Start()); |
35 } | 34 } |
36 | 35 |
37 void TearDown() override { | 36 void TearDown() override { |
38 std::string ports; | 37 std::string ports; |
39 for (std::vector<int>::iterator it = port_counts_.begin(); | 38 for (std::vector<int>::iterator it = port_counts_.begin(); |
40 it != port_counts_.end(); ++it) { | 39 it != port_counts_.end(); ++it) { |
41 base::StringAppendF(&ports, "%d,", *it); | 40 base::StringAppendF(&ports, "%d,", *it); |
42 } | 41 } |
43 perf_test::PrintResultList("mach_ports", "", "", ports, "ports", true); | 42 perf_test::PrintResultList("mach_ports", "", "", ports, "ports", true); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Close each tab, recording the number of ports after each. Do not close the | 103 // Close each tab, recording the number of ports after each. Do not close the |
105 // last tab, which is about:blank. | 104 // last tab, which is about:blank. |
106 for (int i = 0; i < tab_count - 1; ++i) { | 105 for (int i = 0; i < tab_count - 1; ++i) { |
107 EXPECT_TRUE( | 106 EXPECT_TRUE( |
108 tab_strip_model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE)); | 107 tab_strip_model->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE)); |
109 RecordPortCount(); | 108 RecordPortCount(); |
110 } | 109 } |
111 } | 110 } |
112 | 111 |
113 } // namespace | 112 } // namespace |
OLD | NEW |