| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * libjingle | 2  * libjingle | 
| 3  * Copyright 2012 Google Inc. | 3  * Copyright 2012 Google Inc. | 
| 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 met: | 6  * modification, are permitted provided that the following conditions are met: | 
| 7  * | 7  * | 
| 8  *  1. Redistributions of source code must retain the above copyright notice, | 8  *  1. Redistributions of source code must retain the above copyright notice, | 
| 9  *     this list of conditions and the following disclaimer. | 9  *     this list of conditions and the following disclaimer. | 
| 10  *  2. Redistributions in binary form must reproduce the above copyright notice, | 10  *  2. Redistributions in binary form must reproduce the above copyright notice, | 
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 243     IdBase(StatsType type);  // Only meant for derived classes. | 243     IdBase(StatsType type);  // Only meant for derived classes. | 
| 244     const StatsType type_; | 244     const StatsType type_; | 
| 245 | 245 | 
| 246     static const char kSeparator = '_'; | 246     static const char kSeparator = '_'; | 
| 247   }; | 247   }; | 
| 248 | 248 | 
| 249   typedef rtc::scoped_refptr<IdBase> Id; | 249   typedef rtc::scoped_refptr<IdBase> Id; | 
| 250 | 250 | 
| 251   struct Value { | 251   struct Value { | 
| 252     enum Type { | 252     enum Type { | 
| 253       kInt, // int. | 253       kInt,           // int. | 
| 254       kInt64,  // int64. | 254       kInt64,         // int64_t. | 
| 255       kFloat,  // float. | 255       kFloat,         // float. | 
| 256       kString,  // std::string | 256       kString,        // std::string | 
| 257       kStaticString,  // const char*. | 257       kStaticString,  // const char*. | 
| 258       kBool,  // bool. | 258       kBool,          // bool. | 
| 259       kId,  // Id. | 259       kId,            // Id. | 
| 260     }; | 260     }; | 
| 261 | 261 | 
| 262     Value(StatsValueName name, int64 value, Type int_type); | 262     Value(StatsValueName name, int64_t value, Type int_type); | 
| 263     Value(StatsValueName name, float f); | 263     Value(StatsValueName name, float f); | 
| 264     Value(StatsValueName name, const std::string& value); | 264     Value(StatsValueName name, const std::string& value); | 
| 265     Value(StatsValueName name, const char* value); | 265     Value(StatsValueName name, const char* value); | 
| 266     Value(StatsValueName name, bool b); | 266     Value(StatsValueName name, bool b); | 
| 267     Value(StatsValueName name, const Id& value); | 267     Value(StatsValueName name, const Id& value); | 
| 268 | 268 | 
| 269     ~Value(); | 269     ~Value(); | 
| 270 | 270 | 
| 271     // TODO(tommi): This compares name as well as value... | 271     // TODO(tommi): This compares name as well as value... | 
| 272     // I think we should only need to compare the value part and | 272     // I think we should only need to compare the value part and | 
| 273     // move the name part into a hash map. | 273     // move the name part into a hash map. | 
| 274     bool Equals(const Value& other) const; | 274     bool Equals(const Value& other) const; | 
| 275 | 275 | 
| 276     // Comparison operators. Return true iff the current instance is of the | 276     // Comparison operators. Return true iff the current instance is of the | 
| 277     // correct type and holds the same value.  No conversion is performed so | 277     // correct type and holds the same value.  No conversion is performed so | 
| 278     // a string value of "123" is not equal to an int value of 123 and an int | 278     // a string value of "123" is not equal to an int value of 123 and an int | 
| 279     // value of 123 is not equal to a float value of 123.0f. | 279     // value of 123 is not equal to a float value of 123.0f. | 
| 280     // One exception to this is that types kInt and kInt64 can be compared and | 280     // One exception to this is that types kInt and kInt64 can be compared and | 
| 281     // kString and kStaticString too. | 281     // kString and kStaticString too. | 
| 282     bool operator==(const std::string& value) const; | 282     bool operator==(const std::string& value) const; | 
| 283     bool operator==(const char* value) const; | 283     bool operator==(const char* value) const; | 
| 284     bool operator==(int64 value) const; | 284     bool operator==(int64_t value) const; | 
| 285     bool operator==(bool value) const; | 285     bool operator==(bool value) const; | 
| 286     bool operator==(float value) const; | 286     bool operator==(float value) const; | 
| 287     bool operator==(const Id& value) const; | 287     bool operator==(const Id& value) const; | 
| 288 | 288 | 
| 289     // Getters that allow getting the native value directly. | 289     // Getters that allow getting the native value directly. | 
| 290     // The caller must know the type beforehand or else hit a check. | 290     // The caller must know the type beforehand or else hit a check. | 
| 291     int int_val() const; | 291     int int_val() const; | 
| 292     int64 int64_val() const; | 292     int64_t int64_val() const; | 
| 293     float float_val() const; | 293     float float_val() const; | 
| 294     const char* static_string_val() const; | 294     const char* static_string_val() const; | 
| 295     const std::string& string_val() const; | 295     const std::string& string_val() const; | 
| 296     bool bool_val() const; | 296     bool bool_val() const; | 
| 297     const Id& id_val() const; | 297     const Id& id_val() const; | 
| 298 | 298 | 
| 299     // Returns the string representation of |name|. | 299     // Returns the string representation of |name|. | 
| 300     const char* display_name() const; | 300     const char* display_name() const; | 
| 301 | 301 | 
| 302     // Converts the native value to a string representation of the value. | 302     // Converts the native value to a string representation of the value. | 
| 303     std::string ToString() const; | 303     std::string ToString() const; | 
| 304 | 304 | 
| 305     Type type() const { return type_; } | 305     Type type() const { return type_; } | 
| 306 | 306 | 
| 307     // TODO(tommi): Move |name| and |display_name| out of the Value struct. | 307     // TODO(tommi): Move |name| and |display_name| out of the Value struct. | 
| 308     const StatsValueName name; | 308     const StatsValueName name; | 
| 309 | 309 | 
| 310    private: | 310    private: | 
| 311     const Type type_; | 311     const Type type_; | 
| 312     // TODO(tommi): Use C++ 11 union and make value_ const. | 312     // TODO(tommi): Use C++ 11 union and make value_ const. | 
| 313     union InternalType { | 313     union InternalType { | 
| 314       int int_; | 314       int int_; | 
| 315       int64 int64_; | 315       int64_t int64_; | 
| 316       float float_; | 316       float float_; | 
| 317       bool bool_; | 317       bool bool_; | 
| 318       std::string* string_; | 318       std::string* string_; | 
| 319       const char* static_string_; | 319       const char* static_string_; | 
| 320       Id* id_; | 320       Id* id_; | 
| 321     } value_; | 321     } value_; | 
| 322 | 322 | 
| 323    private: | 323    private: | 
| 324     RTC_DISALLOW_COPY_AND_ASSIGN(Value); | 324     RTC_DISALLOW_COPY_AND_ASSIGN(Value); | 
| 325   }; | 325   }; | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 348   StatsType type() const { return id_->type(); } | 348   StatsType type() const { return id_->type(); } | 
| 349   double timestamp() const { return timestamp_; } | 349   double timestamp() const { return timestamp_; } | 
| 350   void set_timestamp(double t) { timestamp_ = t; } | 350   void set_timestamp(double t) { timestamp_ = t; } | 
| 351   bool empty() const { return values_.empty(); } | 351   bool empty() const { return values_.empty(); } | 
| 352   const Values& values() const { return values_; } | 352   const Values& values() const { return values_; } | 
| 353 | 353 | 
| 354   const char* TypeToString() const; | 354   const char* TypeToString() const; | 
| 355 | 355 | 
| 356   void AddString(StatsValueName name, const std::string& value); | 356   void AddString(StatsValueName name, const std::string& value); | 
| 357   void AddString(StatsValueName name, const char* value); | 357   void AddString(StatsValueName name, const char* value); | 
| 358   void AddInt64(StatsValueName name, int64 value); | 358   void AddInt64(StatsValueName name, int64_t value); | 
| 359   void AddInt(StatsValueName name, int value); | 359   void AddInt(StatsValueName name, int value); | 
| 360   void AddFloat(StatsValueName name, float value); | 360   void AddFloat(StatsValueName name, float value); | 
| 361   void AddBoolean(StatsValueName name, bool value); | 361   void AddBoolean(StatsValueName name, bool value); | 
| 362   void AddId(StatsValueName name, const Id& value); | 362   void AddId(StatsValueName name, const Id& value); | 
| 363 | 363 | 
| 364   const Value* FindValue(StatsValueName name) const; | 364   const Value* FindValue(StatsValueName name) const; | 
| 365 | 365 | 
| 366  private: | 366  private: | 
| 367   // The unique identifier for this object. | 367   // The unique identifier for this object. | 
| 368   // This is used as a key for this report in ordered containers, | 368   // This is used as a key for this report in ordered containers, | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 408   StatsReport* Find(const StatsReport::Id& id); | 408   StatsReport* Find(const StatsReport::Id& id); | 
| 409 | 409 | 
| 410  private: | 410  private: | 
| 411   Container list_; | 411   Container list_; | 
| 412   rtc::ThreadChecker thread_checker_; | 412   rtc::ThreadChecker thread_checker_; | 
| 413 }; | 413 }; | 
| 414 | 414 | 
| 415 }  // namespace webrtc | 415 }  // namespace webrtc | 
| 416 | 416 | 
| 417 #endif  // TALK_APP_WEBRTC_STATSTYPES_H_ | 417 #endif  // TALK_APP_WEBRTC_STATSTYPES_H_ | 
| OLD | NEW | 
|---|