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

Side by Side Diff: base/trace_event/trace_event_memory_unittest.cc

Issue 1113953002: Revert of base: Remove use of MessageLoopProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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 "base/trace_event/trace_event_memory.h" 5 #include "base/trace_event/trace_event_memory.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/message_loop/message_loop.h"
10 #include "base/trace_event/trace_event_impl.h" 11 #include "base/trace_event/trace_event_impl.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) 14 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED)
14 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" 15 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
15 #endif 16 #endif
16 17
17 namespace base { 18 namespace base {
18 namespace trace_event { 19 namespace trace_event {
19 20
(...skipping 12 matching lines...) Expand all
32 33
33 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) 34 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED)
34 35
35 TEST_F(TraceMemoryTest, TraceMemoryController) { 36 TEST_F(TraceMemoryTest, TraceMemoryController) {
36 MessageLoop message_loop; 37 MessageLoop message_loop;
37 38
38 // Start with no observers of the TraceLog. 39 // Start with no observers of the TraceLog.
39 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest()); 40 EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest());
40 41
41 // Creating a controller adds it to the TraceLog observer list. 42 // Creating a controller adds it to the TraceLog observer list.
42 scoped_ptr<TraceMemoryController> controller(new TraceMemoryController( 43 scoped_ptr<TraceMemoryController> controller(
43 message_loop.task_runner(), ::HeapProfilerWithPseudoStackStart, 44 new TraceMemoryController(
44 ::HeapProfilerStop, ::GetHeapProfile)); 45 message_loop.message_loop_proxy(),
46 ::HeapProfilerWithPseudoStackStart,
47 ::HeapProfilerStop,
48 ::GetHeapProfile));
45 EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest()); 49 EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest());
46 EXPECT_TRUE( 50 EXPECT_TRUE(
47 TraceLog::GetInstance()->HasEnabledStateObserver(controller.get())); 51 TraceLog::GetInstance()->HasEnabledStateObserver(controller.get()));
48 52
49 // By default the observer isn't dumping memory profiles. 53 // By default the observer isn't dumping memory profiles.
50 EXPECT_FALSE(controller->IsTimerRunningForTest()); 54 EXPECT_FALSE(controller->IsTimerRunningForTest());
51 55
52 // Simulate enabling tracing. 56 // Simulate enabling tracing.
53 controller->StartProfiling(); 57 controller->StartProfiling();
54 message_loop.RunUntilIdle(); 58 message_loop.RunUntilIdle();
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 EXPECT_STREQ("null", StringFromHexAddress("0x0")); 231 EXPECT_STREQ("null", StringFromHexAddress("0x0"));
228 EXPECT_STREQ("error", StringFromHexAddress("not an address")); 232 EXPECT_STREQ("error", StringFromHexAddress("not an address"));
229 const char kHello[] = "hello"; 233 const char kHello[] = "hello";
230 std::ostringstream hex_address; 234 std::ostringstream hex_address;
231 hex_address << &kHello; 235 hex_address << &kHello;
232 EXPECT_STREQ(kHello, StringFromHexAddress(hex_address.str())); 236 EXPECT_STREQ(kHello, StringFromHexAddress(hex_address.str()));
233 } 237 }
234 238
235 } // namespace trace_event 239 } // namespace trace_event
236 } // namespace base 240 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_memory.cc ('k') | base/trace_event/trace_event_system_stats_monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698