| 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 <stddef.h> | 8 #include <stddef.h> | 
| 9 | 9 | 
| 10 #include <cassert> | 10 #include <cassert> | 
| 11 #include <string> | 11 #include <string> | 
| 12 | 12 | 
| 13 #include "base/base_export.h" | 13 #include "base/base_export.h" | 
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/hash.h" | 
| 15 | 15 | 
| 16 namespace tracked_objects { | 16 namespace tracked_objects { | 
| 17 | 17 | 
| 18 // Location provides basic info where of an object was constructed, or was | 18 // Location provides basic info where of an object was constructed, or was | 
| 19 // significantly brought to life. | 19 // significantly brought to life. | 
| 20 class BASE_EXPORT Location { | 20 class BASE_EXPORT Location { | 
| 21  public: | 21  public: | 
| 22   // Constructor should be called with a long-lived char*, such as __FILE__. | 22   // Constructor should be called with a long-lived char*, such as __FILE__. | 
| 23   // It assumes the provided value will persist as a global constant, and it | 23   // It assumes the provided value will persist as a global constant, and it | 
| 24   // will not make a copy of it. | 24   // will not make a copy of it. | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 52   struct Hash { | 52   struct Hash { | 
| 53     size_t operator()(const Location& location) const { | 53     size_t operator()(const Location& location) const { | 
| 54       // Compute the hash value using file name pointer and line number. | 54       // Compute the hash value using file name pointer and line number. | 
| 55       // No need to use |function_name_| since the other two fields uniquely | 55       // No need to use |function_name_| since the other two fields uniquely | 
| 56       // identify this location. | 56       // identify this location. | 
| 57 | 57 | 
| 58       // The file name will always be uniquely identified by its pointer since | 58       // The file name will always be uniquely identified by its pointer since | 
| 59       // it comes from __FILE__, so no need to check the contents of the string. | 59       // it comes from __FILE__, so no need to check the contents of the string. | 
| 60       // See the definition of FROM_HERE in location.h, and how it is used | 60       // See the definition of FROM_HERE in location.h, and how it is used | 
| 61       // elsewhere. | 61       // elsewhere. | 
| 62       return base::HashPair(reinterpret_cast<uintptr_t>(location.file_name()), | 62       return base::HashInts(reinterpret_cast<uintptr_t>(location.file_name()), | 
| 63                             location.line_number()); | 63                             location.line_number()); | 
| 64     } | 64     } | 
| 65   }; | 65   }; | 
| 66 | 66 | 
| 67   // Translate the some of the state in this instance into a human readable | 67   // Translate the some of the state in this instance into a human readable | 
| 68   // string with HTML characters in the function names escaped, and append that | 68   // string with HTML characters in the function names escaped, and append that | 
| 69   // string to |output|.  Inclusion of the file_name_ and function_name_ are | 69   // string to |output|.  Inclusion of the file_name_ and function_name_ are | 
| 70   // optional, and controlled by the boolean arguments. | 70   // optional, and controlled by the boolean arguments. | 
| 71   void Write(bool display_filename, bool display_function_name, | 71   void Write(bool display_filename, bool display_function_name, | 
| 72              std::string* output) const; | 72              std::string* output) const; | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 101 | 101 | 
| 102 #define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name)                        \ | 102 #define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name)                        \ | 
| 103     ::tracked_objects::Location(function_name,                                 \ | 103     ::tracked_objects::Location(function_name,                                 \ | 
| 104                                 __FILE__,                                      \ | 104                                 __FILE__,                                      \ | 
| 105                                 __LINE__,                                      \ | 105                                 __LINE__,                                      \ | 
| 106                                 ::tracked_objects::GetProgramCounter()) | 106                                 ::tracked_objects::GetProgramCounter()) | 
| 107 | 107 | 
| 108 }  // namespace tracked_objects | 108 }  // namespace tracked_objects | 
| 109 | 109 | 
| 110 #endif  // BASE_LOCATION_H_ | 110 #endif  // BASE_LOCATION_H_ | 
| OLD | NEW | 
|---|