OLD | NEW |
---|---|
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 #ifndef BASE_LOCATION_H_ | 5 #ifndef BASE_LOCATION_H_ |
6 #define BASE_LOCATION_H_ | 6 #define BASE_LOCATION_H_ |
7 | 7 |
8 #include <cassert> | 8 #include <cassert> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 struct Hash { | 51 struct Hash { |
52 size_t operator()(const Location& location) const { | 52 size_t operator()(const Location& location) const { |
53 // Compute the hash value using file name pointer and line number. | 53 // Compute the hash value using file name pointer and line number. |
54 // No need to use |function_name_| since the other two fields uniquely | 54 // No need to use |function_name_| since the other two fields uniquely |
55 // identify this location. | 55 // identify this location. |
56 | 56 |
57 // The file name will always be uniquely identified by its pointer since | 57 // The file name will always be uniquely identified by its pointer since |
58 // it comes from __FILE__, so no need to check the contents of the string. | 58 // it comes from __FILE__, so no need to check the contents of the string. |
59 // See the definition of FROM_HERE in location.h, and how it is used | 59 // See the definition of FROM_HERE in location.h, and how it is used |
60 // elsewhere. | 60 // elsewhere. |
61 | 61 return base::HashPair(reinterpret_cast<uintptr_t>(location.file_name()), |
62 // Due to inconsistent definitions of uint64_t and uintptr_t, casting the | |
63 // file name pointer to a uintptr_t causes a compiler error for some | |
danakj
2015/12/02 20:49:41
No more compiler errors? Cool. LGTM
| |
64 // platforms. The solution is to explicitly cast it to a uint64_t. | |
65 return base::HashPair(reinterpret_cast<uint64_t>(location.file_name()), | |
66 location.line_number()); | 62 location.line_number()); |
67 } | 63 } |
68 }; | 64 }; |
69 | 65 |
70 // Translate the some of the state in this instance into a human readable | 66 // Translate the some of the state in this instance into a human readable |
71 // string with HTML characters in the function names escaped, and append that | 67 // string with HTML characters in the function names escaped, and append that |
72 // string to |output|. Inclusion of the file_name_ and function_name_ are | 68 // string to |output|. Inclusion of the file_name_ and function_name_ are |
73 // optional, and controlled by the boolean arguments. | 69 // optional, and controlled by the boolean arguments. |
74 void Write(bool display_filename, bool display_function_name, | 70 void Write(bool display_filename, bool display_function_name, |
75 std::string* output) const; | 71 std::string* output) const; |
(...skipping 28 matching lines...) Expand all Loading... | |
104 | 100 |
105 #define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name) \ | 101 #define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name) \ |
106 ::tracked_objects::Location(function_name, \ | 102 ::tracked_objects::Location(function_name, \ |
107 __FILE__, \ | 103 __FILE__, \ |
108 __LINE__, \ | 104 __LINE__, \ |
109 ::tracked_objects::GetProgramCounter()) | 105 ::tracked_objects::GetProgramCounter()) |
110 | 106 |
111 } // namespace tracked_objects | 107 } // namespace tracked_objects |
112 | 108 |
113 #endif // BASE_LOCATION_H_ | 109 #endif // BASE_LOCATION_H_ |
OLD | NEW |