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

Side by Side Diff: base/location.h

Issue 8313013: Support JSON encoding of data for about:tracking information (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/location.cc » ('j') | base/tracked_objects.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 8 #include <string>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
11 #include "base/values.h"
11 12
12 #ifndef NDEBUG 13 #ifndef NDEBUG
13 #ifndef TRACK_ALL_TASK_OBJECTS 14 #ifndef TRACK_ALL_TASK_OBJECTS
14 #define TRACK_ALL_TASK_OBJECTS 15 #define TRACK_ALL_TASK_OBJECTS
15 #endif // TRACK_ALL_TASK_OBJECTS 16 #endif // TRACK_ALL_TASK_OBJECTS
16 #endif // NDEBUG 17 #endif // NDEBUG
17 18
18 namespace tracked_objects { 19 namespace tracked_objects {
19 20
20 // Location provides basic info where of an object was constructed, or was 21 // Location provides basic info where of an object was constructed, or was
(...skipping 25 matching lines...) Expand all
46 return function_name_ < other.function_name_; 47 return function_name_ < other.function_name_;
47 } 48 }
48 49
49 const char* function_name() const { return function_name_; } 50 const char* function_name() const { return function_name_; }
50 const char* file_name() const { return file_name_; } 51 const char* file_name() const { return file_name_; }
51 int line_number() const { return line_number_; } 52 int line_number() const { return line_number_; }
52 const void* program_counter() const { return program_counter_; } 53 const void* program_counter() const { return program_counter_; }
53 54
54 std::string ToString() const; 55 std::string ToString() const;
55 56
57 // Translate the some of the state in this instance into a human readable
58 // string with HTML characters in the function names escaped, and append that
59 // string to |output|. Inclusion of the file_name_ and function_name_ are
60 // optional, and controlled by the boolean arguments.
56 void Write(bool display_filename, bool display_function_name, 61 void Write(bool display_filename, bool display_function_name,
57 std::string* output) const; 62 std::string* output) const;
58 63
59 // Write function_name_ in HTML with '<' and '>' properly encoded. 64 // Write function_name_ in HTML with '<' and '>' properly encoded.
60 void WriteFunctionName(std::string* output) const; 65 void WriteFunctionName(std::string* output) const;
61 66
67 // Construct a Value* representation. The caller assumes ownership of the
68 // memory in the returned instance.
69 base::DictionaryValue* ToValue() const;
70
62 private: 71 private:
63 const char* function_name_; 72 const char* function_name_;
64 const char* file_name_; 73 const char* file_name_;
65 int line_number_; 74 int line_number_;
66 const void* program_counter_; 75 const void* program_counter_;
67 }; 76 };
68 77
69 BASE_EXPORT const void* GetProgramCounter(); 78 BASE_EXPORT const void* GetProgramCounter();
70 79
71 // Define a macro to record the current source location. 80 // Define a macro to record the current source location.
72 #define FROM_HERE tracked_objects::Location( \ 81 #define FROM_HERE tracked_objects::Location( \
73 __FUNCTION__, \ 82 __FUNCTION__, \
74 __FILE__, \ 83 __FILE__, \
75 __LINE__, \ 84 __LINE__, \
76 tracked_objects::GetProgramCounter()) \ 85 tracked_objects::GetProgramCounter()) \
77 86
78 } // namespace tracked_objects 87 } // namespace tracked_objects
79 88
80 #endif // BASE_LOCATION_H_ 89 #endif // BASE_LOCATION_H_
OLDNEW
« no previous file with comments | « no previous file | base/location.cc » ('j') | base/tracked_objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698