/core/externals/update-engine/Core/KSFrameworkStats.h

http://macfuse.googlecode.com/ · C Header · 85 lines · 27 code · 17 blank · 41 comment · 1 complexity · 709ee8327268cc5992be6becedee2d3e MD5 · raw file

  1. // Copyright 2008 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. #import "KSStatsCollection.h"
  16. //
  17. // UpdateEngine Framework Stats keys
  18. //
  19. // These keys are for stats recorded by the UpdateEngine framework only. Any
  20. // stats specific to the agent, daemon, etc. are not listed here.
  21. //
  22. #define kStatTickets @"tickets"
  23. #define kStatValidTickets @"validtickets"
  24. #define kStatChecks @"checks"
  25. #define kStatFailedChecks @"failedchecks"
  26. #define kStatPrompts @"prompts"
  27. #define kStatPromptApps @"promptapps"
  28. #define kStatPromptUpdates @"promptupdates"
  29. #define kStatDownloads @"downloads"
  30. #define kStatDownloadCacheHits @"downloadcachehits"
  31. #define kStatFailedDownloads @"faileddownloads"
  32. //
  33. // Per-product Stats
  34. //
  35. // See "KSMakeProductStatKey()" below for an explanation of using these keys
  36. //
  37. #define kStatInstallRC @"installrc"
  38. #define kStatActiveProduct @"active"
  39. // This Macro produces an NSString that is formated with a product ID and the
  40. // given stat name. For example, calling
  41. //
  42. // KSMakeProductStatKey(@"foo", kStatInstallRC)
  43. //
  44. // would produce the per-product stat key of @"InstallRC/foo"
  45. //
  46. #define kProductStatDelimiter @"///" // Something fairly unique
  47. #define KSMakeProductStatKey(p, s) \
  48. [NSString stringWithFormat:@"%@%@%@", s, kProductStatDelimiter, p]
  49. // Returns YES if the given string represents a per-product stat, NO otherwise
  50. #define KSIsProductStatKey(key) \
  51. ([[key componentsSeparatedByString:kProductStatDelimiter] count] == 2)
  52. // Given a stat key that was created with KSMakeProductStatKey(), return the
  53. // product portion of the stat key.
  54. #define KSProductFromStatKey(key) \
  55. [[key componentsSeparatedByString:kProductStatDelimiter] objectAtIndex:1]
  56. // Given a stat key that was created with KSMakeProductStatKey(), return the
  57. // "stat" portion of the stat key.
  58. #define KSStatFromStatKey(key) \
  59. [[key componentsSeparatedByString:kProductStatDelimiter] objectAtIndex:0]
  60. // Provides a global access point to a shared KSStatsCollection object to be
  61. // used by the UpdateEngine framework for collecting stats.
  62. @interface KSFrameworkStats : NSObject
  63. // Returns the shared KSStatsCollection instance. May return nil if
  64. // setSharedStats: was never called.
  65. + (KSStatsCollection *)sharedStats;
  66. // Sets the shared KSStatsCollection instance. May set to nil.
  67. + (void)setSharedStats:(KSStatsCollection *)stats;
  68. @end