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

Unified Diff: base/debug/trace_event_unittest.cc

Issue 632103004: Cleanup: Better constify some strings in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bad refactoring Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/debug/trace_event_impl_constants.cc ('k') | base/environment_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event_unittest.cc
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index 90be070ba0b855cc708d5f6eab5465df69058ea9..836a0bb6796772a0e1cce56a1efd5402c7fc1745 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -252,7 +252,6 @@ DictionaryValue* TraceEventTestFixture::FindMatchingTraceEntry(
}
void TraceEventTestFixture::DropTracedMetadataRecords() {
-
scoped_ptr<ListValue> old_trace_parsed(trace_parsed_.DeepCopy());
size_t old_trace_parsed_size = old_trace_parsed->GetSize();
trace_parsed_.Clear();
@@ -266,7 +265,7 @@ void TraceEventTestFixture::DropTracedMetadataRecords() {
}
DictionaryValue* dict = static_cast<DictionaryValue*>(value);
std::string tmp;
- if(dict->GetString("ph", &tmp) && tmp == "M")
+ if (dict->GetString("ph", &tmp) && tmp == "M")
continue;
trace_parsed_.Append(value->DeepCopy());
@@ -377,7 +376,7 @@ std::vector<const DictionaryValue*> FindTraceEntries(
return hits;
}
-const char* kControlCharacters = "\001\002\003\n\r";
+const char kControlCharacters[] = "\001\002\003\n\r";
void TraceWithAllMacroVariants(WaitableEvent* task_complete_event) {
{
@@ -478,7 +477,7 @@ void TraceWithAllMacroVariants(WaitableEvent* task_complete_event) {
TRACE_EVENT1(kControlCharacters, kControlCharacters,
kControlCharacters, kControlCharacters);
- } // Scope close causes TRACE_EVENT0 etc to send their END events.
+ } // Scope close causes TRACE_EVENT0 etc to send their END events.
if (task_complete_event)
task_complete_event->Signal();
@@ -1300,12 +1299,12 @@ TEST_F(TraceEventTestFixture, AsyncBeginEndEvents) {
BeginTrace();
unsigned long long id = 0xfeedbeeffeedbeefull;
- TRACE_EVENT_ASYNC_BEGIN0( "cat", "name1", id);
- TRACE_EVENT_ASYNC_STEP_INTO0( "cat", "name1", id, "step1");
+ TRACE_EVENT_ASYNC_BEGIN0("cat", "name1", id);
+ TRACE_EVENT_ASYNC_STEP_INTO0("cat", "name1", id, "step1");
TRACE_EVENT_ASYNC_END0("cat", "name1", id);
- TRACE_EVENT_BEGIN0( "cat", "name2");
- TRACE_EVENT_ASYNC_BEGIN0( "cat", "name3", 0);
- TRACE_EVENT_ASYNC_STEP_PAST0( "cat", "name3", 0, "step2");
+ TRACE_EVENT_BEGIN0("cat", "name2");
+ TRACE_EVENT_ASYNC_BEGIN0("cat", "name3", 0);
+ TRACE_EVENT_ASYNC_STEP_PAST0("cat", "name3", 0, "step2");
EndTraceAndFlush();
@@ -1332,13 +1331,13 @@ TEST_F(TraceEventTestFixture, AsyncBeginEndPointerMangling) {
TraceLog::GetInstance()->SetProcessID(100);
BeginTrace();
- TRACE_EVENT_ASYNC_BEGIN0( "cat", "name1", ptr);
- TRACE_EVENT_ASYNC_BEGIN0( "cat", "name2", ptr);
+ TRACE_EVENT_ASYNC_BEGIN0("cat", "name1", ptr);
+ TRACE_EVENT_ASYNC_BEGIN0("cat", "name2", ptr);
EndTraceAndFlush();
TraceLog::GetInstance()->SetProcessID(200);
BeginTrace();
- TRACE_EVENT_ASYNC_END0( "cat", "name1", ptr);
+ TRACE_EVENT_ASYNC_END0("cat", "name1", ptr);
EndTraceAndFlush();
DictionaryValue* async_begin = FindNamePhase("name1", "S");
@@ -1490,32 +1489,32 @@ TEST_F(TraceEventTestFixture, DataCapturedManyThreads) {
TEST_F(TraceEventTestFixture, ThreadNames) {
// Create threads before we enable tracing to make sure
// that tracelog still captures them.
- const int num_threads = 4;
- const int num_events = 10;
- Thread* threads[num_threads];
- PlatformThreadId thread_ids[num_threads];
- for (int i = 0; i < num_threads; i++)
+ const int kNumThreads = 4;
+ const int kNumEvents = 10;
+ Thread* threads[kNumThreads];
+ PlatformThreadId thread_ids[kNumThreads];
+ for (int i = 0; i < kNumThreads; i++)
threads[i] = new Thread(StringPrintf("Thread %d", i));
// Enable tracing.
BeginTrace();
// Now run some trace code on these threads.
- WaitableEvent* task_complete_events[num_threads];
- for (int i = 0; i < num_threads; i++) {
+ WaitableEvent* task_complete_events[kNumThreads];
+ for (int i = 0; i < kNumThreads; i++) {
task_complete_events[i] = new WaitableEvent(false, false);
threads[i]->Start();
thread_ids[i] = threads[i]->thread_id();
threads[i]->message_loop()->PostTask(
FROM_HERE, base::Bind(&TraceManyInstantEvents,
- i, num_events, task_complete_events[i]));
+ i, kNumEvents, task_complete_events[i]));
}
- for (int i = 0; i < num_threads; i++) {
+ for (int i = 0; i < kNumThreads; i++) {
task_complete_events[i]->Wait();
}
// Shut things down.
- for (int i = 0; i < num_threads; i++) {
+ for (int i = 0; i < kNumThreads; i++) {
threads[i]->Stop();
delete threads[i];
delete task_complete_events[i];
@@ -1538,7 +1537,7 @@ TEST_F(TraceEventTestFixture, ThreadNames) {
EXPECT_TRUE(item->GetInteger("tid", &tmp_int));
// See if this thread name is one of the threads we just created
- for (int j = 0; j < num_threads; j++) {
+ for (int j = 0; j < kNumThreads; j++) {
if(static_cast<int>(thread_ids[j]) != tmp_int)
continue;
@@ -2969,7 +2968,7 @@ TEST_F(TraceEventTestFixture, ConfigureSyntheticDelays) {
}
TEST_F(TraceEventTestFixture, BadSyntheticDelayConfigurations) {
- const char* configs[] = {
+ const char* const configs[] = {
"",
"DELAY(",
"DELAY(;",
« no previous file with comments | « base/debug/trace_event_impl_constants.cc ('k') | base/environment_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698