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