config.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2014 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 COMPONENTS_DOMAIN_RELIABILITY_CONFIG_H_
  5. #define COMPONENTS_DOMAIN_RELIABILITY_CONFIG_H_
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "base/json/json_value_converter.h"
  10. #include "base/strings/string_piece.h"
  11. #include "components/domain_reliability/domain_reliability_export.h"
  12. #include "url/gurl.h"
  13. #include "url/origin.h"
  14. namespace domain_reliability {
  15. // The per-origin configuration that controls which requests are measured and
  16. // reported, with what frequency, and where the beacons are uploaded.
  17. struct DOMAIN_RELIABILITY_EXPORT DomainReliabilityConfig {
  18. public:
  19. DomainReliabilityConfig();
  20. DomainReliabilityConfig(const DomainReliabilityConfig&) = delete;
  21. DomainReliabilityConfig& operator=(const DomainReliabilityConfig&) = delete;
  22. ~DomainReliabilityConfig();
  23. // Uses the JSONValueConverter to parse the JSON for a config into a struct.
  24. static std::unique_ptr<const DomainReliabilityConfig> FromJSON(
  25. const base::StringPiece& json);
  26. bool IsValid() const;
  27. double GetSampleRate(bool request_successful) const;
  28. // Registers with the JSONValueConverter so it will know how to convert the
  29. // JSON for a config into the struct.
  30. static void RegisterJSONConverter(
  31. base::JSONValueConverter<DomainReliabilityConfig>* converter);
  32. url::Origin origin;
  33. bool include_subdomains;
  34. // Each entry in |collectors| must have scheme https.
  35. std::vector<std::unique_ptr<GURL>> collectors;
  36. double success_sample_rate;
  37. double failure_sample_rate;
  38. std::vector<std::unique_ptr<std::string>> path_prefixes;
  39. };
  40. } // namespace domain_reliability
  41. #endif // COMPONENTS_DOMAIN_RELIABILITY_CONFIG_H_