Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef BASE_LOCATION_H_ | 5 #ifndef BASE_LOCATION_H_ |
| 6 #define BASE_LOCATION_H_ | 6 #define BASE_LOCATION_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| 11 #include "base/values.h" | |
| 11 | 12 |
| 12 #ifndef NDEBUG | 13 #ifndef NDEBUG |
| 13 #ifndef TRACK_ALL_TASK_OBJECTS | 14 #ifndef TRACK_ALL_TASK_OBJECTS |
| 14 #define TRACK_ALL_TASK_OBJECTS | 15 #define TRACK_ALL_TASK_OBJECTS |
| 15 #endif // TRACK_ALL_TASK_OBJECTS | 16 #endif // TRACK_ALL_TASK_OBJECTS |
| 16 #endif // NDEBUG | 17 #endif // NDEBUG |
| 17 | 18 |
| 18 namespace tracked_objects { | 19 namespace tracked_objects { |
| 19 | 20 |
| 20 // Location provides basic info where of an object was constructed, or was | 21 // Location provides basic info where of an object was constructed, or was |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 46 return function_name_ < other.function_name_; | 47 return function_name_ < other.function_name_; |
| 47 } | 48 } |
| 48 | 49 |
| 49 const char* function_name() const { return function_name_; } | 50 const char* function_name() const { return function_name_; } |
| 50 const char* file_name() const { return file_name_; } | 51 const char* file_name() const { return file_name_; } |
| 51 int line_number() const { return line_number_; } | 52 int line_number() const { return line_number_; } |
| 52 const void* program_counter() const { return program_counter_; } | 53 const void* program_counter() const { return program_counter_; } |
| 53 | 54 |
| 54 std::string ToString() const; | 55 std::string ToString() const; |
| 55 | 56 |
| 57 // Translate the some of the state in this instance into a human readable | |
| 58 // string with HTML characters in the function names exscaped, and append | |
|
ramant (doing other things)
2011/10/24 18:03:49
nit: exscaped -> escaped
jar (doing other things)
2011/10/24 18:43:27
Done.
| |
| 59 // that string to |output|. Inclusion of the file_name_ and function_name_ | |
| 60 // are optional, and controlled by the boolean arguments. | |
| 56 void Write(bool display_filename, bool display_function_name, | 61 void Write(bool display_filename, bool display_function_name, |
| 57 std::string* output) const; | 62 std::string* output) const; |
| 58 | 63 |
| 59 // Write function_name_ in HTML with '<' and '>' properly encoded. | 64 // Write function_name_ in HTML with '<' and '>' properly encoded. |
| 60 void WriteFunctionName(std::string* output) const; | 65 void WriteFunctionName(std::string* output) const; |
| 61 | 66 |
| 67 // Construct a Value* representation. The caller ownns assumes ownership | |
|
ramant (doing other things)
2011/10/24 18:03:49
nit: ownns -> owns. Should we say owns and assumes
jar (doing other things)
2011/10/24 18:43:27
Done.
| |
| 68 // of the memory in the returned instance. | |
| 69 base::DictionaryValue* ToValue() const; | |
| 70 | |
| 62 private: | 71 private: |
| 63 const char* function_name_; | 72 const char* function_name_; |
| 64 const char* file_name_; | 73 const char* file_name_; |
| 65 int line_number_; | 74 int line_number_; |
| 66 const void* program_counter_; | 75 const void* program_counter_; |
| 67 }; | 76 }; |
| 68 | 77 |
| 69 BASE_EXPORT const void* GetProgramCounter(); | 78 BASE_EXPORT const void* GetProgramCounter(); |
| 70 | 79 |
| 71 // Define a macro to record the current source location. | 80 // Define a macro to record the current source location. |
| 72 #define FROM_HERE tracked_objects::Location( \ | 81 #define FROM_HERE tracked_objects::Location( \ |
| 73 __FUNCTION__, \ | 82 __FUNCTION__, \ |
| 74 __FILE__, \ | 83 __FILE__, \ |
| 75 __LINE__, \ | 84 __LINE__, \ |
| 76 tracked_objects::GetProgramCounter()) \ | 85 tracked_objects::GetProgramCounter()) \ |
| 77 | 86 |
| 78 } // namespace tracked_objects | 87 } // namespace tracked_objects |
| 79 | 88 |
| 80 #endif // BASE_LOCATION_H_ | 89 #endif // BASE_LOCATION_H_ |
| OLD | NEW |