diff options
author | gavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-13 20:45:21 +0000 |
---|---|---|
committer | gavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-13 20:45:21 +0000 |
commit | 9d337bc7383bef4366f949b08867ba4fa9b874a9 (patch) | |
tree | 86e5c8130aa9d9b7c71138f4ce3d39f18d0a5076 /net | |
parent | 1477ef4c522c910b5f1933f6ebf095e8d9f4d8d7 (diff) | |
download | chromium_src-9d337bc7383bef4366f949b08867ba4fa9b874a9.zip chromium_src-9d337bc7383bef4366f949b08867ba4fa9b874a9.tar.gz chromium_src-9d337bc7383bef4366f949b08867ba4fa9b874a9.tar.bz2 |
Clean up dependencies for disk_cache histogram_macros.h.
The current mechanism by which these convenience macros find their
backend is confusing, at best; the macro has the form of our include
guard macros, but describes a CC file. Embedded within the
histogram_macros.h then is an abstraction violation: it just knows
which object has backend information depending on which file it was
included from.
Some downstream reviews have made this even more confusing; rather
than continue this, let's parameterize the backend object to the
convenience macros, so each translation unit is responsible for
knowing its own context.
R=mmenke@chromium.org, rvargas@chromium.org
TBR=mmenke@chromium.org
BUG=None
Review URL: https://codereview.chromium.org/140893013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251116 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/disk_cache/backend_impl.cc | 6 | ||||
-rw-r--r-- | net/disk_cache/backend_unittest.cc | 3 | ||||
-rw-r--r-- | net/disk_cache/entry_impl.cc | 3 | ||||
-rw-r--r-- | net/disk_cache/eviction.cc | 3 | ||||
-rw-r--r-- | net/disk_cache/histogram_macros.h | 11 | ||||
-rw-r--r-- | net/disk_cache/in_flight_backend_io.cc | 3 | ||||
-rw-r--r-- | net/disk_cache/rankings.cc | 3 | ||||
-rw-r--r-- | net/disk_cache/v3/backend_impl_v3.cc | 6 | ||||
-rw-r--r-- | net/disk_cache/v3/backend_worker.cc | 6 | ||||
-rw-r--r-- | net/disk_cache/v3/entry_impl_v3.cc | 3 | ||||
-rw-r--r-- | net/disk_cache/v3/eviction_v3.cc | 3 | ||||
-rw-r--r-- | net/disk_cache/v3/histogram_macros.h | 11 | ||||
-rw-r--r-- | net/net.gyp | 1 |
13 files changed, 37 insertions, 25 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index d10a19d..c934b87 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -27,11 +27,11 @@ #include "net/disk_cache/errors.h" #include "net/disk_cache/experiments.h" #include "net/disk_cache/file.h" - -// This has to be defined before including histogram_macros.h from this file. -#define NET_DISK_CACHE_BACKEND_IMPL_CC_ #include "net/disk_cache/histogram_macros.h" +// Provide a BackendImpl object to macros from histogram_macros.h. +#define CACHE_UMA_BACKEND_IMPL_OBJ this + using base::Time; using base::TimeDelta; using base::TimeTicks; diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc index 14ffbf0..8119f85 100644 --- a/net/disk_cache/backend_unittest.cc +++ b/net/disk_cache/backend_unittest.cc @@ -35,6 +35,9 @@ #include "base/win/scoped_handle.h" #endif +// Provide a BackendImpl object to macros from histogram_macros.h. +#define CACHE_UMA_BACKEND_IMPL_OBJ backend_ + using base::Time; namespace { diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc index 4b6e4cf..d6796d7 100644 --- a/net/disk_cache/entry_impl.cc +++ b/net/disk_cache/entry_impl.cc @@ -18,6 +18,9 @@ #include "net/disk_cache/net_log_parameters.h" #include "net/disk_cache/sparse_control.h" +// Provide a BackendImpl object to macros from histogram_macros.h. +#define CACHE_UMA_BACKEND_IMPL_OBJ backend_ + using base::Time; using base::TimeDelta; using base::TimeTicks; diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc index 47b5255..3e2c779 100644 --- a/net/disk_cache/eviction.cc +++ b/net/disk_cache/eviction.cc @@ -41,6 +41,9 @@ #include "net/disk_cache/histogram_macros.h" #include "net/disk_cache/trace.h" +// Provide a BackendImpl object to macros from histogram_macros.h. +#define CACHE_UMA_BACKEND_IMPL_OBJ backend_ + using base::Time; using base::TimeTicks; diff --git a/net/disk_cache/histogram_macros.h b/net/disk_cache/histogram_macros.h index 651bce9..6af9ca1 100644 --- a/net/disk_cache/histogram_macros.h +++ b/net/disk_cache/histogram_macros.h @@ -84,12 +84,6 @@ #define CACHE_HISTOGRAM_CACHE_ERROR(name, sample) \ CACHE_HISTOGRAM_ENUMERATION(name, sample, 50) -#ifdef NET_DISK_CACHE_BACKEND_IMPL_CC_ -#define BACKEND_OBJ this -#else -#define BACKEND_OBJ backend_ -#endif - // Generates a UMA histogram of the given type, generating the proper name for // it (asking backend_->HistogramName), and adding the provided sample. // For example, to generate a regualar UMA_HISTOGRAM_COUNTS, this macro would @@ -101,8 +95,9 @@ // UMA_HISTOGRAM_COUNTS("DiskCache.2.MyExperiment_530", 55); // #define CACHE_UMA(type, name, experiment, sample) {\ - const std::string my_name = BACKEND_OBJ->HistogramName(name, experiment);\ - switch (BACKEND_OBJ->cache_type()) {\ + const std::string my_name =\ + CACHE_UMA_BACKEND_IMPL_OBJ->HistogramName(name, experiment);\ + switch (CACHE_UMA_BACKEND_IMPL_OBJ->cache_type()) {\ case net::DISK_CACHE:\ CACHE_HISTOGRAM_##type(my_name.data(), sample);\ break;\ diff --git a/net/disk_cache/in_flight_backend_io.cc b/net/disk_cache/in_flight_backend_io.cc index 3ed9e4d..394cc85 100644 --- a/net/disk_cache/in_flight_backend_io.cc +++ b/net/disk_cache/in_flight_backend_io.cc @@ -13,6 +13,9 @@ #include "net/disk_cache/entry_impl.h" #include "net/disk_cache/histogram_macros.h" +// Provide a BackendImpl object to macros from histogram_macros.h. +#define CACHE_UMA_BACKEND_IMPL_OBJ backend_ + namespace disk_cache { BackendIO::BackendIO(InFlightIO* controller, BackendImpl* backend, diff --git a/net/disk_cache/rankings.cc b/net/disk_cache/rankings.cc index ff9913e..3ddbcf8 100644 --- a/net/disk_cache/rankings.cc +++ b/net/disk_cache/rankings.cc @@ -12,6 +12,9 @@ #include "net/disk_cache/histogram_macros.h" #include "net/disk_cache/stress_support.h" +// Provide a BackendImpl object to macros from histogram_macros.h. +#define CACHE_UMA_BACKEND_IMPL_OBJ backend_ + using base::Time; using base::TimeTicks; diff --git a/net/disk_cache/v3/backend_impl_v3.cc b/net/disk_cache/v3/backend_impl_v3.cc index 7c85584..67dc861 100644 --- a/net/disk_cache/v3/backend_impl_v3.cc +++ b/net/disk_cache/v3/backend_impl_v3.cc @@ -28,11 +28,11 @@ #include "net/disk_cache/storage_block-inl.h" #include "net/disk_cache/v3/disk_format_v3.h" #include "net/disk_cache/v3/entry_impl_v3.h" +#include "net/disk_cache/v3/histogram_macros.h" #include "net/disk_cache/v3/index_table.h" -// This has to be defined before including histogram_macros.h from this file. -#define NET_DISK_CACHE_BACKEND_IMPL_CC_ -#include "net/disk_cache/v3/histogram_macros.h" +// Provide a BackendImpl object to macros from histogram_macros.h. +#define CACHE_UMA_BACKEND_IMPL_OBJ this using base::Time; using base::TimeDelta; diff --git a/net/disk_cache/v3/backend_worker.cc b/net/disk_cache/v3/backend_worker.cc index be12a96..a4acefb 100644 --- a/net/disk_cache/v3/backend_worker.cc +++ b/net/disk_cache/v3/backend_worker.cc @@ -26,11 +26,11 @@ #include "net/disk_cache/errors.h" #include "net/disk_cache/experiments.h" #include "net/disk_cache/file.h" - -// This has to be defined before including histogram_macros.h from this file. -#define NET_DISK_CACHE_BACKEND_IMPL_CC_ #include "net/disk_cache/histogram_macros.h" +// Provide a BackendImpl object to macros from histogram_macros.h. +#define CACHE_UMA_BACKEND_IMPL_OBJ this + using base::Time; using base::TimeDelta; using base::TimeTicks; diff --git a/net/disk_cache/v3/entry_impl_v3.cc b/net/disk_cache/v3/entry_impl_v3.cc index d748ed2..432a6a7 100644 --- a/net/disk_cache/v3/entry_impl_v3.cc +++ b/net/disk_cache/v3/entry_impl_v3.cc @@ -18,6 +18,9 @@ #include "net/disk_cache/v3/histogram_macros.h" // #include "net/disk_cache/v3/sparse_control_v3.h" +// Provide a BackendImpl object to macros from histogram_macros.h. +#define CACHE_UMA_BACKEND_IMPL_OBJ backend_ + using base::Time; using base::TimeDelta; using base::TimeTicks; diff --git a/net/disk_cache/v3/eviction_v3.cc b/net/disk_cache/v3/eviction_v3.cc index 64b4c29..fc0d37a 100644 --- a/net/disk_cache/v3/eviction_v3.cc +++ b/net/disk_cache/v3/eviction_v3.cc @@ -40,6 +40,9 @@ #include "net/disk_cache/v3/entry_impl_v3.h" #include "net/disk_cache/v3/histogram_macros.h" +// Define CACHE_UMA_BACKEND_IMPL_OBJ to be a disk_cache::BackendImpl* in order +// to use the CACHE_UMA histogram macro. +#define CACHE_UMA_BACKEND_IMPL_OBJ backend_ using base::Time; using base::TimeTicks; diff --git a/net/disk_cache/v3/histogram_macros.h b/net/disk_cache/v3/histogram_macros.h index 4f37970..50d4d75 100644 --- a/net/disk_cache/v3/histogram_macros.h +++ b/net/disk_cache/v3/histogram_macros.h @@ -84,12 +84,6 @@ #define CACHE_HISTOGRAM_CACHE_ERROR(name, sample) \ CACHE_HISTOGRAM_ENUMERATION(name, sample, 50) -#ifdef NET_DISK_CACHE_BACKEND_IMPL_CC_ -#define BACKEND_OBJ this -#else -#define BACKEND_OBJ backend_ -#endif - // Generates a UMA histogram of the given type, generating the proper name for // it (asking backend_->HistogramName), and adding the provided sample. // For example, to generate a regualar UMA_HISTOGRAM_COUNTS, this macro would @@ -99,8 +93,9 @@ // UMA_HISTOGRAM_COUNTS("DiskCache3.MyName_AppCache", 20); // #define CACHE_UMA(type, name, sample) {\ - const std::string my_name = BACKEND_OBJ->HistogramName(name);\ - switch (BACKEND_OBJ->cache_type()) {\ + const std::string my_name =\ + CACHE_UMA_BACKEND_IMPL_OBJ->HistogramName(name);\ + switch (CACHE_UMA_BACKEND_IMPL_OBJ->cache_type()) {\ case net::DISK_CACHE:\ CACHE_HISTOGRAM_##type(my_name.data(), sample);\ break;\ diff --git a/net/net.gyp b/net/net.gyp index 308c98d..348c134 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -457,6 +457,7 @@ 'disk_cache/v3/entry_impl_v3.h', 'disk_cache/v3/eviction_v3.cc', 'disk_cache/v3/eviction_v3.h', + 'disk_cache/v3/histogram_macros.h', 'disk_cache/v3/index_table.cc', 'disk_cache/v3/index_table.h', 'dns/address_sorter.h', |