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

Side by Side Diff: base/location.h

Issue 9702014: [UMA] Use proper C++ objects to serialize tracked_objects across process boundaries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix base_unittests failures Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/location.cc » ('j') | content/public/common/serialized_profiler_data.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 // TODO(isherman): Remove this include, and fixup downstream files that depend
12 // on it.
11 #include "base/values.h" 13 #include "base/values.h"
12 14
15 namespace base {
16 class DictionaryValue;
17 }
18
13 namespace tracked_objects { 19 namespace tracked_objects {
14 20
15 // 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
16 // significantly brought to life. 22 // significantly brought to life.
17 class BASE_EXPORT Location { 23 class BASE_EXPORT Location {
18 public: 24 public:
19 // Constructor should be called with a long-lived char*, such as __FILE__. 25 // Constructor should be called with a long-lived char*, such as __FILE__.
20 // It assumes the provided value will persist as a global constant, and it 26 // It assumes the provided value will persist as a global constant, and it
21 // will not make a copy of it. 27 // will not make a copy of it.
22 Location(const char* function_name, 28 Location(const char* function_name,
(...skipping 28 matching lines...) Expand all
51 // Translate the some of the state in this instance into a human readable 57 // Translate the some of the state in this instance into a human readable
52 // string with HTML characters in the function names escaped, and append that 58 // string with HTML characters in the function names escaped, and append that
53 // string to |output|. Inclusion of the file_name_ and function_name_ are 59 // string to |output|. Inclusion of the file_name_ and function_name_ are
54 // optional, and controlled by the boolean arguments. 60 // optional, and controlled by the boolean arguments.
55 void Write(bool display_filename, bool display_function_name, 61 void Write(bool display_filename, bool display_function_name,
56 std::string* output) const; 62 std::string* output) const;
57 63
58 // Write function_name_ in HTML with '<' and '>' properly encoded. 64 // Write function_name_ in HTML with '<' and '>' properly encoded.
59 void WriteFunctionName(std::string* output) const; 65 void WriteFunctionName(std::string* output) const;
60 66
61 // Construct a Value* representation. The caller assumes ownership of the
62 // memory in the returned instance.
63 base::DictionaryValue* ToValue() const;
64
65 private: 67 private:
66 const char* function_name_; 68 const char* function_name_;
67 const char* file_name_; 69 const char* file_name_;
68 int line_number_; 70 int line_number_;
69 const void* program_counter_; 71 const void* program_counter_;
70 }; 72 };
71 73
74 // Serialized representation of the Location class that can safely be passed
75 // across process boundaries.
76 struct BASE_EXPORT SerializedLocation {
77 // The default constructor is exposed to support the IPC serialization macros.
78 SerializedLocation();
79 SerializedLocation(const tracked_objects::Location& location);
80 ~SerializedLocation();
81
82 // Writes the serialized data into the passed |dictionary|.
83 void ToValue(base::DictionaryValue* dictionary) const;
84
85 std::string file_name;
86 std::string function_name;
87 int line_number;
88 };
89
72 BASE_EXPORT const void* GetProgramCounter(); 90 BASE_EXPORT const void* GetProgramCounter();
73 91
74 // Define a macro to record the current source location. 92 // Define a macro to record the current source location.
75 #define FROM_HERE FROM_HERE_WITH_EXPLICIT_FUNCTION(__FUNCTION__) 93 #define FROM_HERE FROM_HERE_WITH_EXPLICIT_FUNCTION(__FUNCTION__)
76 94
77 #define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name) \ 95 #define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name) \
78 ::tracked_objects::Location(function_name, \ 96 ::tracked_objects::Location(function_name, \
79 __FILE__, \ 97 __FILE__, \
80 __LINE__, \ 98 __LINE__, \
81 ::tracked_objects::GetProgramCounter()) 99 ::tracked_objects::GetProgramCounter())
82 100
83 } // namespace tracked_objects 101 } // namespace tracked_objects
84 102
85 #endif // BASE_LOCATION_H_ 103 #endif // BASE_LOCATION_H_
OLDNEW
« no previous file with comments | « no previous file | base/location.cc » ('j') | content/public/common/serialized_profiler_data.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698