summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/dns_global.h
blob: 3b76f4543e115a02179297fd3c74cc8c7f0d3a20 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2006-2008 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.

// This is the global interface for the dns prefetch services.  It centralizes
// initialization, along with all the callbacks etc. to connect to the browser
// process.  This allows the more standard DNS prefetching services, such as
// provided by DnsMaster to be left as more generally usable code, and possibly
// be shared across multiple client projects.

#ifndef CHROME_BROWSER_NET_DNS_GLOBAL_H_
#define CHROME_BROWSER_NET_DNS_GLOBAL_H_

#include "chrome/browser/net/dns_master.h"

#include <string>

class PrefService;

namespace chrome_browser_net {

// Functions to initialize our global state so that PrefetchDns() can be called.
void InitDnsPrefetch(PrefService* user_prefs);
void ShutdownDnsPrefetch();

//------------------------------------------------------------------------------
// Global APIs relating to Prefetching in browser
void EnableDnsPrefetch(bool enable);
void RegisterPrefs(PrefService* local_state);
void RegisterUserPrefs(PrefService* user_prefs);
// Renderer bundles up list and sends to this browser API via IPC.
void DnsPrefetchList(const NameList& hostnames);
// This API is used by the autocomplete popup box (as user types).
void DnsPrefetchUrlString(const url_canon::UTF16String& url_string);
void DnsPrefetchGetHtmlInfo(std::string* output);

//------------------------------------------------------------------------------
// Save the hostnames actually used at the start of this session to prefetch
// during the next startup.
void SaveHostNamesForNextStartup(PrefService* local_state);
void DnsPrefetchHostNamesAtStartup(PrefService* user_prefs,
                                   PrefService* local_state);

//------------------------------------------------------------------------------
// Helper class to handle global init and shutdown.
class DnsPrefetcherInit {
 public:
  explicit DnsPrefetcherInit(PrefService* user_prefs) {
    InitDnsPrefetch(user_prefs);
  }
  ~DnsPrefetcherInit() {ShutdownDnsPrefetch();}

 private:
  DISALLOW_COPY_AND_ASSIGN(DnsPrefetcherInit);
};

}  // namespace chrome_browser_net

#endif  // CHROME_BROWSER_NET_DNS_GLOBAL_H_