1 // Copyright 2019 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 
5 #ifndef SERVICES_NETWORK_PUBLIC_CPP_LOAD_INFO_UTIL_H_
6 #define SERVICES_NETWORK_PUBLIC_CPP_LOAD_INFO_UTIL_H_
7 
8 #include "base/component_export.h"
9 
10 namespace network {
11 
12 namespace mojom {
13 class LoadInfo;
14 }
15 
16 // This function returns true if the LoadInfo of |a| is "more interesting"
17 // than the LoadInfo of |b|.  The load that is currently sending the larger
18 // request body is considered more interesting.  If neither request is
19 // sending a body (Neither request has a body, or any request that has a body
20 // is not currently sending the body), the request that is further along is
21 // considered more interesting.
22 //
23 // This takes advantage of the fact that the load states are an enumeration
24 // listed in the order in which they usually occur during the lifetime of a
25 // request, so states with larger numeric values are generally further along
26 // toward completion.
27 //
28 // For example, by this measure "tranferring data" is a more interesting state
29 // than "resolving host" because when transferring data something is being
30 // done that corresponds to changes that the user might observe, whereas
31 // waiting for a host name to resolve implies being stuck.
32 COMPONENT_EXPORT(NETWORK_CPP)
33 bool LoadInfoIsMoreInteresting(const mojom::LoadInfo& a,
34                                const mojom::LoadInfo& b);
35 
36 }  // namespace network
37 
38 #endif  // SERVICES_NETWORK_PUBLIC_CPP_LOAD_INFO_UTIL_H_