p2p: Make HTTP downloads fail fast if using p2p to download

Failing fast when downloading via p2p is desirable because if we're
disconnected from the peer we're downloading from, chances are good
that it's not coming back. For example the peer could have gone to
sleep (user shutting the lid) or gone out of range. This is unlike the
non-p2p path where we can assume much better connectivity.

Also introduce new constants instead of hard-coded numbers and move
some existing constants to constants.h.

BUG=chromium:260426
TEST=Unit tests pass
Change-Id: Id2f1d0c60907caec06c4bdff3c70871d9f3eb20d
Reviewed-on: https://chromium-review.googlesource.com/64830
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
8 files changed
tree: 975ec5c50d89864610736b0393dc648831fe5dd1
  1. .gitignore
  2. 99-gpio-dutflag.rules
  3. action.h
  4. action_mock.h
  5. action_pipe.h
  6. action_pipe_unittest.cc
  7. action_processor.cc
  8. action_processor.h
  9. action_processor_mock.h
  10. action_processor_unittest.cc
  11. action_unittest.cc
  12. build
  13. bzip.cc
  14. bzip.h
  15. bzip_extent_writer.cc
  16. bzip_extent_writer.h
  17. bzip_extent_writer_unittest.cc
  18. certificate_checker.cc
  19. certificate_checker.h
  20. certificate_checker_mock.h
  21. certificate_checker_unittest.cc
  22. chrome_browser_proxy_resolver.cc
  23. chrome_browser_proxy_resolver.h
  24. chrome_browser_proxy_resolver_unittest.cc
  25. clock.cc
  26. clock.h
  27. clock_interface.h
  28. connection_manager.cc
  29. connection_manager.h
  30. connection_manager_unittest.cc
  31. constants.cc
  32. constants.h
  33. cycle_breaker.cc
  34. cycle_breaker.h
  35. cycle_breaker_unittest.cc
  36. dbus_constants.h
  37. dbus_interface.h
  38. dbus_service.cc
  39. dbus_service.h
  40. delta_diff_generator.cc
  41. delta_diff_generator.h
  42. delta_diff_generator_unittest.cc
  43. delta_performer.cc
  44. delta_performer.h
  45. delta_performer_unittest.cc
  46. download_action.cc
  47. download_action.h
  48. download_action_unittest.cc
  49. error_code.h
  50. extent_mapper.cc
  51. extent_mapper.h
  52. extent_mapper_unittest.cc
  53. extent_ranges.cc
  54. extent_ranges.h
  55. extent_ranges_unittest.cc
  56. extent_writer.cc
  57. extent_writer.h
  58. extent_writer_unittest.cc
  59. fake_clock.h
  60. fake_hardware.cc
  61. fake_hardware.h
  62. fake_p2p_manager.h
  63. fake_p2p_manager_configuration.h
  64. file_descriptor.cc
  65. file_descriptor.h
  66. file_writer.cc
  67. file_writer.h
  68. file_writer_mock.h
  69. file_writer_unittest.cc
  70. filesystem_copier_action.cc
  71. filesystem_copier_action.h
  72. filesystem_copier_action_unittest.cc
  73. filesystem_iterator.cc
  74. filesystem_iterator.h
  75. filesystem_iterator_unittest.cc
  76. full_update_generator.cc
  77. full_update_generator.h
  78. full_update_generator_unittest.cc
  79. gen_coverage_html
  80. generate_delta_main.cc
  81. gpio_handler.cc
  82. gpio_handler.h
  83. gpio_handler_unittest.cc
  84. gpio_handler_unittest.h
  85. gpio_mock_file_descriptor.cc
  86. gpio_mock_file_descriptor.h
  87. gpio_mock_udev_interface.cc
  88. gpio_mock_udev_interface.h
  89. graph_types.h
  90. graph_utils.cc
  91. graph_utils.h
  92. graph_utils_unittest.cc
  93. hardware.cc
  94. hardware.h
  95. hardware_interface.h
  96. hardware_unittest.cc
  97. http_common.cc
  98. http_common.h
  99. http_fetcher.cc
  100. http_fetcher.h
  101. http_fetcher_unittest.cc
  102. inherit-review-settings-ok
  103. install_plan.cc
  104. install_plan.h
  105. libcurl_http_fetcher.cc
  106. libcurl_http_fetcher.h
  107. LICENSE
  108. local_coverage_rate
  109. main.cc
  110. marshal.list
  111. metadata.cc
  112. metadata.h
  113. metadata_unittest.cc
  114. mock_connection_manager.h
  115. mock_dbus_interface.h
  116. mock_file_writer.h
  117. mock_gpio_handler.h
  118. mock_http_fetcher.cc
  119. mock_http_fetcher.h
  120. mock_p2p_manager.h
  121. mock_payload_state.h
  122. mock_system_state.cc
  123. mock_system_state.h
  124. multi_range_http_fetcher.cc
  125. multi_range_http_fetcher.h
  126. omaha_hash_calculator.cc
  127. omaha_hash_calculator.h
  128. omaha_hash_calculator_unittest.cc
  129. omaha_request_action.cc
  130. omaha_request_action.h
  131. omaha_request_action_unittest.cc
  132. omaha_request_params.cc
  133. omaha_request_params.h
  134. omaha_request_params_unittest.cc
  135. omaha_response.h
  136. omaha_response_handler_action.cc
  137. omaha_response_handler_action.h
  138. omaha_response_handler_action_unittest.cc
  139. org.chromium.UpdateEngine.service
  140. p2p_manager.cc
  141. p2p_manager.h
  142. p2p_manager_unittest.cc
  143. payload_signer.cc
  144. payload_signer.h
  145. payload_signer_unittest.cc
  146. payload_state.cc
  147. payload_state.h
  148. payload_state_interface.h
  149. payload_state_unittest.cc
  150. postinstall_runner_action.cc
  151. postinstall_runner_action.h
  152. postinstall_runner_action_unittest.cc
  153. prefs.cc
  154. prefs.h
  155. prefs_interface.h
  156. prefs_mock.h
  157. prefs_unittest.cc
  158. proxy_resolver.cc
  159. proxy_resolver.h
  160. real_system_state.h
  161. run_unittests
  162. sample_omaha_v3_response.xml
  163. SConstruct
  164. setup_dev_packages
  165. simple_key_value_store.cc
  166. simple_key_value_store.h
  167. simple_key_value_store_unittest.cc
  168. subprocess.cc
  169. subprocess.h
  170. subprocess_unittest.cc
  171. system_state.cc
  172. system_state.h
  173. tarjan.cc
  174. tarjan.h
  175. tarjan_unittest.cc
  176. terminator.cc
  177. terminator.h
  178. terminator_unittest.cc
  179. test_http_server.cc
  180. test_utils.cc
  181. test_utils.h
  182. testrunner.cc
  183. topological_sort.cc
  184. topological_sort.h
  185. topological_sort_unittest.cc
  186. udev_interface.h
  187. unittest_key.pem
  188. unittest_key2.pem
  189. update_attempter.cc
  190. update_attempter.h
  191. update_attempter_mock.h
  192. update_attempter_unittest.cc
  193. update_check_scheduler.cc
  194. update_check_scheduler.h
  195. update_check_scheduler_unittest.cc
  196. update_engine.xml
  197. update_engine_client.cc
  198. update_metadata.proto
  199. UpdateEngine.conf
  200. utils.cc
  201. utils.h
  202. utils_unittest.cc
  203. WATCHLISTS
  204. zip_unittest.cc