bluetooth: android: Initial Low Energy Discovery Sessions.
[chromium-blink-merge.git] / net / proxy / polling_proxy_config_service.h
blobc8230561f7fa3b032f694b9ced5dfe081ac5ccd0
1 // Copyright (c) 2011 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.
5 #ifndef NET_PROXY_POLLING_PROXY_CONFIG_SERVICE_H_
6 #define NET_PROXY_POLLING_PROXY_CONFIG_SERVICE_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/time/time.h"
11 #include "net/proxy/proxy_config_service.h"
13 namespace net {
15 // PollingProxyConfigService is a base class for creating ProxyConfigService
16 // implementations that use polling to notice when settings have change.
18 // It runs code to get the current proxy settings on a background worker
19 // thread, and notifies registered observers when the value changes.
20 class NET_EXPORT_PRIVATE PollingProxyConfigService : public ProxyConfigService {
21 public:
22 // ProxyConfigService implementation:
23 void AddObserver(Observer* observer) override;
24 void RemoveObserver(Observer* observer) override;
25 ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) override;
26 void OnLazyPoll() override;
28 protected:
29 // Function for retrieving the current proxy configuration.
30 // Implementors must be threadsafe as the function will be invoked from
31 // worker threads.
32 typedef void (*GetConfigFunction)(ProxyConfig*);
34 // Creates a polling-based ProxyConfigService which will test for new
35 // settings at most every |poll_interval| time by calling |get_config_func|
36 // on a worker thread.
37 PollingProxyConfigService(
38 base::TimeDelta poll_interval,
39 GetConfigFunction get_config_func);
41 ~PollingProxyConfigService() override;
43 // Polls for changes by posting a task to the worker pool.
44 void CheckForChangesNow();
46 private:
47 class Core;
48 scoped_refptr<Core> core_;
50 DISALLOW_COPY_AND_ASSIGN(PollingProxyConfigService);
53 } // namespace net
55 #endif // NET_PROXY_POLLING_PROXY_CONFIG_SERVICE_H_