simple_histogram_macros.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_HISTOGRAM_MACROS_H_
  5. #define NET_DISK_CACHE_SIMPLE_SIMPLE_HISTOGRAM_MACROS_H_
  6. #include "base/metrics/histogram_macros.h"
  7. #include "net/base/cache_type.h"
  8. // This file contains macros used to report histograms. The main issue is that
  9. // we want to have separate histograms for each type of cache (app, http, and
  10. // media), while making it easy to report histograms and have all names
  11. // precomputed.
  12. #define SIMPLE_CACHE_THUNK(uma_prefix, uma_type, args) \
  13. uma_prefix##_HISTOGRAM_##uma_type args
  14. // TODO(pasko): add histograms for shader cache as soon as it becomes possible
  15. // for a user to get shader cache with the |SimpleBackendImpl| without altering
  16. // any flags.
  17. #define SIMPLE_CACHE_HISTO(uma_prefix, uma_type, uma_name, cache_type, ...) \
  18. do { \
  19. switch (cache_type) { \
  20. case net::DISK_CACHE: \
  21. SIMPLE_CACHE_THUNK(uma_prefix, uma_type, \
  22. ("SimpleCache.Http." uma_name, ##__VA_ARGS__)); \
  23. break; \
  24. case net::APP_CACHE: \
  25. SIMPLE_CACHE_THUNK(uma_prefix, uma_type, \
  26. ("SimpleCache.App." uma_name, ##__VA_ARGS__)); \
  27. break; \
  28. case net::GENERATED_BYTE_CODE_CACHE: \
  29. SIMPLE_CACHE_THUNK(uma_prefix, uma_type, \
  30. ("SimpleCache.Code." uma_name, ##__VA_ARGS__)); \
  31. break; \
  32. case net::GENERATED_NATIVE_CODE_CACHE: \
  33. case net::GENERATED_WEBUI_BYTE_CODE_CACHE: \
  34. case net::SHADER_CACHE: \
  35. break; \
  36. default: \
  37. NOTREACHED(); \
  38. break; \
  39. } \
  40. } while (0)
  41. #define SIMPLE_CACHE_UMA(uma_type, uma_name, cache_type, ...) \
  42. SIMPLE_CACHE_HISTO(UMA, uma_type, uma_name, cache_type, ##__VA_ARGS__)
  43. #define SIMPLE_CACHE_LOCAL(uma_type, uma_name, cache_type, ...) \
  44. SIMPLE_CACHE_HISTO(LOCAL, uma_type, uma_name, cache_type, ##__VA_ARGS__)
  45. #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_HISTOGRAM_MACROS_H_