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

Side by Side Diff: base/location.h

Issue 2399053004: Move GetProgramCounter in FROM_HERE to a common function (Closed)
Patch Set: -BASE_EXPORT Created 4 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 unified diff | Download patch
« no previous file with comments | « base/BUILD.gn ('k') | base/location.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef BASE_LOCATION_H_ 5 #ifndef BASE_LOCATION_H_
6 #define BASE_LOCATION_H_ 6 #define BASE_LOCATION_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cassert> 10 #include <cassert>
(...skipping 15 matching lines...) Expand all
26 const char* file_name, 26 const char* file_name,
27 int line_number, 27 int line_number,
28 const void* program_counter); 28 const void* program_counter);
29 29
30 // Provide a default constructor for easy of debugging. 30 // Provide a default constructor for easy of debugging.
31 Location(); 31 Location();
32 32
33 // Copy constructor. 33 // Copy constructor.
34 Location(const Location& other); 34 Location(const Location& other);
35 35
36 static Location CreateForCurrentProgramCounter(
37 const char* function_name,
38 const char* file_name,
39 int line_number);
40
36 // Comparator for hash map insertion. 41 // Comparator for hash map insertion.
37 // No need to use |function_name_| since the other two fields uniquely 42 // No need to use |function_name_| since the other two fields uniquely
38 // identify this location. 43 // identify this location.
39 bool operator==(const Location& other) const { 44 bool operator==(const Location& other) const {
40 return line_number_ == other.line_number_ && 45 return line_number_ == other.line_number_ &&
41 file_name_ == other.file_name_; 46 file_name_ == other.file_name_;
42 } 47 }
43 48
44 const char* function_name() const { return function_name_; } 49 const char* function_name() const { return function_name_; }
45 const char* file_name() const { return file_name_; } 50 const char* file_name() const { return file_name_; }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 std::string file_name; 97 std::string file_name;
93 std::string function_name; 98 std::string function_name;
94 int line_number; 99 int line_number;
95 }; 100 };
96 101
97 BASE_EXPORT const void* GetProgramCounter(); 102 BASE_EXPORT const void* GetProgramCounter();
98 103
99 // Define a macro to record the current source location. 104 // Define a macro to record the current source location.
100 #define FROM_HERE FROM_HERE_WITH_EXPLICIT_FUNCTION(__func__) 105 #define FROM_HERE FROM_HERE_WITH_EXPLICIT_FUNCTION(__func__)
101 106
102 #define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name) \ 107 #define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name) \
103 ::tracked_objects::Location(function_name, \ 108 ::tracked_objects::Location::CreateForCurrentProgramCounter( \
104 __FILE__, \ 109 function_name, __FILE__, __LINE__) \
105 __LINE__, \
106 ::tracked_objects::GetProgramCounter())
107 110
108 } // namespace tracked_objects 111 } // namespace tracked_objects
109 112
110 #endif // BASE_LOCATION_H_ 113 #endif // BASE_LOCATION_H_
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | base/location.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698