OLD | NEW |
---|---|
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/tracked.h" | 5 #include "base/tracked.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/stringprintf.h" |
8 #include "base/tracked_objects.h" | 8 #include "base/tracked_objects.h" |
9 | 9 |
10 using base::TimeTicks; | 10 using base::TimeTicks; |
11 | 11 |
12 namespace tracked_objects { | 12 namespace tracked_objects { |
13 | 13 |
14 //------------------------------------------------------------------------------ | 14 //------------------------------------------------------------------------------ |
15 | 15 |
16 Location::Location(const char* function_name, const char* file_name, | 16 Location::Location(const char* function_name, const char* file_name, |
17 int line_number) | 17 int line_number) |
18 : function_name_(function_name), | 18 : function_name_(function_name), |
19 file_name_(file_name), | 19 file_name_(file_name), |
20 line_number_(line_number) { | 20 line_number_(line_number) { |
21 } | 21 } |
22 | 22 |
23 Location::Location() | 23 Location::Location() |
24 : function_name_("Unknown"), | 24 : function_name_("Unknown"), |
25 file_name_("Unknown"), | 25 file_name_("Unknown"), |
26 line_number_(-1) { | 26 line_number_(-1) { |
27 } | 27 } |
28 | 28 |
29 void Location::Write(bool display_filename, bool display_function_name, | 29 void Location::Write(bool display_filename, bool display_function_name, |
30 std::string* output) const { | 30 std::string* output) const { |
31 StringAppendF(output, "%s[%d] ", | 31 StringAppendF(output, "%s[%d] ", |
viettrungluu
2010/08/17 05:09:15
base::?
| |
32 display_filename ? file_name_ : "line", | 32 display_filename ? file_name_ : "line", |
33 line_number_); | 33 line_number_); |
34 | 34 |
35 if (display_function_name) { | 35 if (display_function_name) { |
36 WriteFunctionName(output); | 36 WriteFunctionName(output); |
37 output->push_back(' '); | 37 output->push_back(' '); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 void Location::WriteFunctionName(std::string* output) const { | 41 void Location::WriteFunctionName(std::string* output) const { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 tracked_birth_time_ = TimeTicks::Now(); | 100 tracked_birth_time_ = TimeTicks::Now(); |
101 } | 101 } |
102 | 102 |
103 bool Tracked::MissingBirthplace() const { | 103 bool Tracked::MissingBirthplace() const { |
104 return -1 == tracked_births_->location().line_number(); | 104 return -1 == tracked_births_->location().line_number(); |
105 } | 105 } |
106 | 106 |
107 #endif // NDEBUG | 107 #endif // NDEBUG |
108 | 108 |
109 } // namespace tracked_objects | 109 } // namespace tracked_objects |
OLD | NEW |