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

Unified Diff: base/tracked.h

Issue 7778033: Add trace code to track all posted tasks in message_loop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: base/tracked.h
diff --git a/base/tracked.h b/base/tracked.h
index 3c73519c6c650d051423918a59892763bcdf7fba..6745f51cc989326f0b18263e60e2b6485d98c75d 100644
--- a/base/tracked.h
+++ b/base/tracked.h
@@ -22,6 +22,8 @@
#include <string>
#include "base/base_export.h"
+#include "base/string_piece.h"
+#include "base/stringize_macros.h"
#include "base/time.h"
#ifndef NDEBUG
@@ -38,15 +40,15 @@ namespace tracked_objects {
class BASE_EXPORT Location {
public:
- // Constructor should be called with a long-lived char*, such as __FILE__.
- // It assumes the provided value will persist as a global constant, and it
- // will not make a copy of it.
- Location(const char* function_name,
- const char* file_name,
- int line_number,
+ // Constructor should be called with a long-lived char*. It assumes the
+ // provided value will persist as a global constant, and it will not make a
+ // copy of it.
+ // |file_line| is formatted as "FILE:LINE".
+ Location(const char* file_line,
+ const char* function_name,
jbates 2011/08/31 00:40:48 I really wanted this to be "FILE:LINE:FUNCTION" to
jar (doing other things) 2011/09/01 18:17:51 There is a memory cost of having FILE:LINE, as it
jbates 2011/09/01 23:01:52 The only purpose I had in mind of merging these is
const void* program_counter);
- // Provide a default constructor for easy of debugging.
+ // Default constructor initializes to "Unknown:-1", "Unknown", NULL.
Location();
// Comparison operator for insertion into a std::map<> hash tables.
@@ -56,16 +58,14 @@ class BASE_EXPORT Location {
// a difference), and then pointers as secondary keys (just to get some
// distinctions).
bool operator < (const Location& other) const {
- if (line_number_ != other.line_number_)
- return line_number_ < other.line_number_;
- if (file_name_ != other.file_name_)
- return file_name_ < other.file_name_;
- return function_name_ < other.function_name_;
+ return file_line_ < other.file_line_;
jbates 2011/08/31 00:40:48 If file_line is the same, function is the same, so
jar (doing other things) 2011/09/01 18:17:51 I think this is not true when templates are invole
jbates 2011/09/01 23:01:52 OK, I'll add it back in. In linux/gcc, what I see
}
- const char* function_name() const { return function_name_; }
- const char* file_name() const { return file_name_; }
- int line_number() const { return line_number_; }
+ // Get long-lived file_line string "FILE:LINE".
+ const char* file_line() const { return file_line_; }
+ const base::StringPiece file_name() const;
+ int line_number() const;
+ const base::StringPiece function_name() const;
const void* program_counter() const { return program_counter_; }
void Write(bool display_filename, bool display_function_name,
@@ -75,10 +75,9 @@ class BASE_EXPORT Location {
void WriteFunctionName(std::string* output) const;
private:
- const char* const function_name_;
- const char* const file_name_;
- const int line_number_;
- const void* const program_counter_;
+ const char* file_line_;
+ const char* function_name_;
+ const void* program_counter_;
jar (doing other things) 2011/09/01 18:17:51 Why did you decide these didn't need to be constan
jbates 2011/09/01 23:01:52 operator= doesn't work if these pointers can't be
jar (doing other things) 2011/09/03 00:26:33 I think it made it clear that the object was not g
jbates 2011/09/03 01:11:41 I see. I find it useful to be able to copy Locatio
};
BASE_EXPORT const void* GetProgramCounter();
@@ -86,11 +85,9 @@ BASE_EXPORT const void* GetProgramCounter();
//------------------------------------------------------------------------------
// Define a macro to record the current source location.
-#define FROM_HERE tracked_objects::Location( \
- __FUNCTION__, \
- __FILE__, \
- __LINE__, \
- tracked_objects::GetProgramCounter()) \
+#define FROM_HERE tracked_objects::Location( \
jar (doing other things) 2011/09/03 00:26:33 I'm not sure how this happened... but the goal is
jbates 2011/09/03 01:11:41 I don't know the history of this code. The use cas
jar (doing other things) 2011/09/15 16:26:39 Can you clarify how this is used? Is it sent up as
jbates 2011/09/15 16:48:33 Now that we have about:tracing in the official bui
+ __FILE__ ":" STRINGIZE(__LINE__), __FUNCTION__, \
jar (doing other things) 2011/09/01 18:17:51 As mentioned, this will notably increase memory ut
jbates 2011/09/01 23:01:52 I compared release builds with and without this CL
jar (doing other things) 2011/09/03 00:26:33 hmmm... the "cost" will appear in each file where
jbates 2011/09/03 01:11:41 code/text size is separate, and it does go up by 8
+ tracked_objects::GetProgramCounter())
//------------------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698