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

Side by Side Diff: base/location.h

Issue 2415673005: Revert of Move GetProgramCounter in FROM_HERE to a common function (Closed)
Patch Set: 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
41 // Comparator for hash map insertion. 36 // Comparator for hash map insertion.
42 // No need to use |function_name_| since the other two fields uniquely 37 // No need to use |function_name_| since the other two fields uniquely
43 // identify this location. 38 // identify this location.
44 bool operator==(const Location& other) const { 39 bool operator==(const Location& other) const {
45 return line_number_ == other.line_number_ && 40 return line_number_ == other.line_number_ &&
46 file_name_ == other.file_name_; 41 file_name_ == other.file_name_;
47 } 42 }
48 43
49 const char* function_name() const { return function_name_; } 44 const char* function_name() const { return function_name_; }
50 const char* file_name() const { return file_name_; } 45 const char* file_name() const { return file_name_; }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 std::string file_name; 92 std::string file_name;
98 std::string function_name; 93 std::string function_name;
99 int line_number; 94 int line_number;
100 }; 95 };
101 96
102 BASE_EXPORT const void* GetProgramCounter(); 97 BASE_EXPORT const void* GetProgramCounter();
103 98
104 // Define a macro to record the current source location. 99 // Define a macro to record the current source location.
105 #define FROM_HERE FROM_HERE_WITH_EXPLICIT_FUNCTION(__func__) 100 #define FROM_HERE FROM_HERE_WITH_EXPLICIT_FUNCTION(__func__)
106 101
107 #define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name) \ 102 #define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name) \
108 ::tracked_objects::Location::CreateForCurrentProgramCounter( \ 103 ::tracked_objects::Location(function_name, \
109 function_name, __FILE__, __LINE__) \ 104 __FILE__, \
105 __LINE__, \
106 ::tracked_objects::GetProgramCounter())
110 107
111 } // namespace tracked_objects 108 } // namespace tracked_objects
112 109
113 #endif // BASE_LOCATION_H_ 110 #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