tile_config.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // Copyright 2020 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_QUERY_TILES_INTERNAL_TILE_CONFIG_H_
  5. #define COMPONENTS_QUERY_TILES_INTERNAL_TILE_CONFIG_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/time/time.h"
  9. #include "components/query_tiles/internal/tile_types.h"
  10. #include "url/gurl.h"
  11. namespace query_tiles {
  12. // Default URL string for GetQueryTiles RPC.
  13. extern const char kDefaultGetQueryTilePath[];
  14. // Finch parameter key for experiment tag to be passed to the server.
  15. extern const char kExperimentTagKey[];
  16. // Finch parameter key for base server URL to retrieve the tiles.
  17. extern const char kBaseURLKey[];
  18. // Finch parameter key for expire duration in seconds.
  19. extern const char kExpireDurationKey[];
  20. // Finch parameter key for expire duration in seconds.
  21. extern const char kIsUnmeteredNetworkRequiredKey[];
  22. // Finch parameter key for image prefetch mode.
  23. extern const char kImagePrefetchModeKey[];
  24. // Finch parameter key for the minimum interval to next schedule.
  25. extern const char kScheduleIntervalKey[];
  26. // Finch parameter key for random window.
  27. extern const char kMaxRandomWindowKey[];
  28. // Finch parameter key for one off task window.
  29. extern const char kOneoffTaskWindowKey[];
  30. // Finch parameter key for Backoff policy initial delay in ms.
  31. extern const char kBackoffInitDelayInMsKey[];
  32. // Finch parameter key for Backoff policy maximum delay in ms.
  33. extern const char kBackoffMaxDelayInMsKey[];
  34. // Finch parameter key for lambda in tile score decay calculation.
  35. extern const char kTileScoreDecayLambdaKey[];
  36. // Finch parameter key representing the minimum scores for new tiles that are in
  37. // front of others.
  38. extern const char kMinimumScoreForNewFrontTilesKey[];
  39. // Finch parameter key for number of trending tiles to display.
  40. extern const char kNumTrendingTilesKey[];
  41. // Finch parameter key for max number of trending tile impressions.
  42. extern const char kMaxTrendingTileImpressionsKey[];
  43. // Finch parameter key for the starting position to shuffle unclicked tiles.
  44. extern const char kTileShufflePositionKey[];
  45. // Finch parameter key for number of non-interacted days to reset tile score.
  46. extern const char kNumDaysToResetTileScore[];
  47. class TileConfig {
  48. public:
  49. // Gets the URL for the Query Tiles service. If
  50. // |override_field_trial_param_value_if_empty| is false, server URL provided
  51. // by field trial param is preferred over |base_url|. Otherwise, |base_url| is
  52. // used. This method could return an empty URL if no valid URL is provided
  53. // though |base_url| or field trial param.
  54. static GURL GetQueryTilesServerUrl(
  55. const std::string& base_url,
  56. bool override_field_trial_param_value_if_empty);
  57. // Gets whether running the background task requires unmeter network
  58. // condition.
  59. static bool GetIsUnMeteredNetworkRequired();
  60. // Gets the experiment tag to be passed to server, given the country code.
  61. static std::string GetExperimentTag(const std::string& country_code);
  62. // Gets the maximum duration for holding current group's info and images.
  63. static base::TimeDelta GetExpireDuration();
  64. // Gets the image prefetch mode to determine how many images will be
  65. // prefetched in background task.
  66. static ImagePrefetchMode GetImagePrefetchMode();
  67. // Get the interval of schedule window in ms.
  68. static int GetScheduleIntervalInMs();
  69. // Get the maxmium window for randomization in ms.
  70. static int GetMaxRandomWindowInMs();
  71. // Get the schedule window duration from start to end in one-off task params
  72. // in ms.
  73. static int GetOneoffTaskWindowInMs();
  74. // Get the init delay (unit:ms) argument for backoff policy.
  75. static int GetBackoffPolicyArgsInitDelayInMs();
  76. // Get the max delay (unit:ms) argument for backoff policy.
  77. static int GetBackoffPolicyArgsMaxDelayInMs();
  78. // Get the lambda value used for calculating the tile score decay over time.
  79. static double GetTileScoreDecayLambda();
  80. // Get the minimum scrore for newly showing tiles that are in front of others.
  81. static double GetMinimumScoreForNewFrontTiles();
  82. // Get the number of trending tiles to be displayed at the same time.
  83. static int GetNumTrendingTilesToDisplay();
  84. // Get the maximum number of impressions for a trending tile to be displayed.
  85. static int GetMaxTrendingTileImpressions();
  86. // Get the starting position tp shuffle unclicked tiles. Tiles before this
  87. // position are not shuffled.
  88. static int GetTileShufflePosition();
  89. // Get the number of non-interacted days to reset tile score.
  90. static int GetNumDaysToResetTileScore();
  91. };
  92. } // namespace query_tiles
  93. #endif // COMPONENTS_QUERY_TILES_INTERNAL_TILE_CONFIG_H_