no_state_prefetch_utils.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2017 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_NO_STATE_PREFETCH_COMMON_NO_STATE_PREFETCH_UTILS_H_
  5. #define COMPONENTS_NO_STATE_PREFETCH_COMMON_NO_STATE_PREFETCH_UTILS_H_
  6. #include <string>
  7. class GURL;
  8. namespace prerender {
  9. extern const char kFollowOnlyWhenPrerenderShown[];
  10. // Returns true iff the scheme of the URL given is valid for prefetch.
  11. bool DoesURLHaveValidScheme(const GURL& url);
  12. // Returns true iff the scheme of the subresource URL given is valid for
  13. // prefetch.
  14. bool DoesSubresourceURLHaveValidScheme(const GURL& url);
  15. // Returns true iff the method given is valid for NoStatePrefetch.
  16. bool IsValidHttpMethod(const std::string& method);
  17. std::string ComposeHistogramName(const std::string& prefix_type,
  18. const std::string& name);
  19. // Called when a NoStatePrefetch request has received a response (including
  20. // redirects). May be called several times per resource, in case of redirects.
  21. void RecordPrefetchResponseReceived(const std::string& histogram_prefix,
  22. bool is_main_resource,
  23. bool is_redirect,
  24. bool is_no_store);
  25. // Called when a NoStatePrefetch resource has been loaded. This is called only
  26. // once per resource, when all redirects have been resolved.
  27. void RecordPrefetchRedirectCount(const std::string& histogram_prefix,
  28. bool is_main_resource,
  29. int redirect_count);
  30. } // namespace prerender
  31. #endif // COMPONENTS_NO_STATE_PREFETCH_COMMON_NO_STATE_PREFETCH_UTILS_H_