summaryrefslogtreecommitdiff
path: root/chromium/content/public/browser/resource_hints.h
blob: fdb7778374568c282902efdc7a9b488ff09fa52f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_HINTS_H_
#define CONTENT_PUBLIC_BROWSER_RESOURCE_HINTS_H_

#include "content/common/content_export.h"
#include "net/base/completion_callback.h"
#include "net/http/http_request_info.h"
#include "url/gurl.h"

class GURL;

namespace content {
class ResourceContext;
}

namespace content {

// A Preconnect instance maintains state while a TCP/IP connection is made, and
// then released into the pool of available connections for future use.

// Tries to preconnect. |count| may be used to request more than one connection
// be established in parallel. Note that the net stack has logic so multiple
// calls to preconnect a given url within a short time frame will automatically
// coalesce. |allow_credentials| corresponds to the fetch spec.
// Note: This should only be called on the IO thread, with a valid
// URLRequestContextGetter.
CONTENT_EXPORT void PreconnectUrl(
    content::ResourceContext* resource_context,
    const GURL& url,
    const GURL& first_party_for_cookies,
    int count,
    bool allow_credentials,
    net::HttpRequestInfo::RequestMotivation motivation);

// Issues a DNS request to |url|. Note that these requests are sent to the host
// resolver with priority net::IDLE.
CONTENT_EXPORT int PreresolveUrl(content::ResourceContext* resource_context,
                                 const GURL& url,
                                 const net::CompletionCallback& callback);

}  // namespace content

#endif  // CONTENT_PUBLIC_BROWSER_RESOURCE_HINTS_H_