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

Side by Side Diff: base/debug/trace_event_unittest.cc

Issue 11438022: Add ability to retrieve a thread_name given a thread_id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use an interned name instead of name version. Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
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/debug/trace_event_unittest.h" 5 #include "base/debug/trace_event_unittest.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/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 void EndTraceAndFlush() { 73 void EndTraceAndFlush() {
74 TraceLog::GetInstance()->SetDisabled(); 74 TraceLog::GetInstance()->SetDisabled();
75 TraceLog::GetInstance()->Flush( 75 TraceLog::GetInstance()->Flush(
76 base::Bind(&TraceEventTestFixture::OnTraceDataCollected, 76 base::Bind(&TraceEventTestFixture::OnTraceDataCollected,
77 base::Unretained(this))); 77 base::Unretained(this)));
78 } 78 }
79 79
80 virtual void SetUp() OVERRIDE { 80 virtual void SetUp() OVERRIDE {
81 old_thread_name_ = PlatformThread::GetName(); 81 const char* name = PlatformThread::GetName();
82 old_thread_name_ = name ? strdup(name) : NULL;
82 } 83 }
83 virtual void TearDown() OVERRIDE { 84 virtual void TearDown() OVERRIDE {
84 if (TraceLog::GetInstance()) 85 if (TraceLog::GetInstance())
85 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled()); 86 EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled());
86 PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : ""); 87 PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : "");
88 free(old_thread_name_);
89 old_thread_name_ = NULL;
87 } 90 }
88 91
89 const char* old_thread_name_; 92 char* old_thread_name_;
90 ListValue trace_parsed_; 93 ListValue trace_parsed_;
91 base::debug::TraceResultBuffer trace_buffer_; 94 base::debug::TraceResultBuffer trace_buffer_;
92 base::debug::TraceResultBuffer::SimpleOutput json_output_; 95 base::debug::TraceResultBuffer::SimpleOutput json_output_;
93 int event_watch_notification_; 96 int event_watch_notification_;
94 97
95 private: 98 private:
96 // We want our singleton torn down after each test. 99 // We want our singleton torn down after each test.
97 ShadowingAtExitManager at_exit_manager_; 100 ShadowingAtExitManager at_exit_manager_;
98 Lock lock_; 101 Lock lock_;
99 }; 102 };
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 Clear(); 1335 Clear();
1333 1336
1334 trace_buffer_.Start(); 1337 trace_buffer_.Start();
1335 trace_buffer_.AddFragment("bla1,bla2,bla3,bla4"); 1338 trace_buffer_.AddFragment("bla1,bla2,bla3,bla4");
1336 trace_buffer_.Finish(); 1339 trace_buffer_.Finish();
1337 EXPECT_STREQ(json_output_.json_output.c_str(), "[bla1,bla2,bla3,bla4]"); 1340 EXPECT_STREQ(json_output_.json_output.c_str(), "[bla1,bla2,bla3,bla4]");
1338 } 1341 }
1339 1342
1340 } // namespace debug 1343 } // namespace debug
1341 } // namespace base 1344 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698