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

Side by Side Diff: statsreport/formatter.h

Issue 159168: This fixes a number of things that are warnings in the Mac compiler.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 17 matching lines...) Expand all
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 32
33 // Utility class to format metrics to a string suitable for posting to 33 // Utility class to format metrics to a string suitable for posting to
34 // TB stats server. 34 // TB stats server.
35 #ifndef O3D_STATSREPORT_FORMATTER_H__ 35 #ifndef O3D_STATSREPORT_FORMATTER_H__
36 #define O3D_STATSREPORT_FORMATTER_H__ 36 #define O3D_STATSREPORT_FORMATTER_H__
37 37
38 #include <strstream> 38 #include <sstream>
39 #include "base/basictypes.h" 39 #include "base/basictypes.h"
40 #include "metrics.h" 40 #include "metrics.h"
41 41
42 namespace stats_report { 42 namespace stats_report {
43 43
44 // A utility class that knows how to turn metrics into a string for 44 // A utility class that knows how to turn metrics into a string for
45 // reporting to the Toolbar stats server. 45 // reporting to the Toolbar stats server.
46 class Formatter { 46 class Formatter {
47 public: 47 public:
48 // @param name the name of the application to report stats against 48 // @param name the name of the application to report stats against
49 Formatter(const char *name, uint32 measurement_secs); 49 Formatter(const char *name, uint32 measurement_secs);
50 ~Formatter(); 50 ~Formatter();
51 51
52 // Add metric to the output string 52 // Add metric to the output string
53 void AddMetric(MetricBase *metric); 53 void AddMetric(MetricBase *metric);
54 54
55 // Add typed metrics to the output string 55 // Add typed metrics to the output string
56 // @{ 56 // @{
57 void AddCount(const char *name, uint64 value); 57 void AddCount(const char *name, uint64 value);
58 void AddTiming(const char *name, uint64 num, uint64 avg, uint64 min, 58 void AddTiming(const char *name, uint64 num, uint64 avg, uint64 min,
59 uint64 max); 59 uint64 max);
60 void AddInteger(const char *name, uint64 value); 60 void AddInteger(const char *name, uint64 value);
61 void AddBoolean(const char *name, bool value); 61 void AddBoolean(const char *name, bool value);
62 // @} 62 // @}
63 63
64 // Terminates the output string and returns it. 64 // Terminates the output string and returns it.
65 // It is an error to add metrics after output() is called. 65 // It is an error to add metrics after output() is called.
66 const char *output() { 66 const std::string output() {
67 output_ << std::ends; 67 output_ << std::ends;
68 return output_.str(); 68 return output_.str();
69 } 69 }
70 70
71 private: 71 private:
72 mutable std::strstream output_; 72 mutable std::ostringstream output_;
73 73
74 DISALLOW_COPY_AND_ASSIGN(Formatter); 74 DISALLOW_COPY_AND_ASSIGN(Formatter);
75 }; 75 };
76 76
77 } // namespace stats_report 77 } // namespace stats_report
78 78
79 #endif // O3D_STATSREPORT_FORMATTER_H__ 79 #endif // O3D_STATSREPORT_FORMATTER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698