summaryrefslogtreecommitdiffstats
path: root/components/domain_reliability/service.h
blob: 9625ae633aba5efc3e79f3dfb3653b6c227fad64 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright 2014 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 COMPONENTS_DOMAIN_RELIABILITY_SERVICE_H_
#define COMPONENTS_DOMAIN_RELIABILITY_SERVICE_H_

#include <string>

#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
#include "components/domain_reliability/clear_mode.h"
#include "components/domain_reliability/domain_reliability_export.h"
#include "components/keyed_service/core/keyed_service.h"

class PrefService;

namespace base {
class Value;
}  // namespace base

namespace net {
class URLRequestContextGetter;
}  // namespace net

namespace domain_reliability {

class DomainReliabilityMonitor;

// DomainReliabilityService is a KeyedService that manages a Monitor that lives
// on another thread (as provided by the URLRequestContextGetter's task runner)
// and proxies (selected) method calls to it. Destruction of the Monitor (on
// that thread) is the responsibility of the caller.
class DOMAIN_RELIABILITY_EXPORT DomainReliabilityService
    : public KeyedService {
 public:
  // Creates a DomainReliabilityService that will contain a Monitor with the
  // given upload reporter string.
  static DomainReliabilityService* Create(
      const std::string& upload_reporter_string);

  ~DomainReliabilityService() override;

  // Initializes the Service: given the task runner on which Monitor methods
  // should be called, creates the Monitor and returns it. Can be called at
  // most once, and must be called before any of the below methods can be
  // called. The caller is responsible for destroying the Monitor on the given
  // task runner when it is no longer needed.
  virtual scoped_ptr<DomainReliabilityMonitor> CreateMonitor(
      scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) = 0;

  // Clears browsing data on the associated Monitor. |Init()| must have been
  // called first.
  virtual void ClearBrowsingData(DomainReliabilityClearMode clear_mode,
                                 const base::Closure& callback) = 0;

  virtual void GetWebUIData(
      const base::Callback<void(scoped_ptr<base::Value>)>& callback)
      const = 0;

 protected:
  DomainReliabilityService();

 private:
  DISALLOW_COPY_AND_ASSIGN(DomainReliabilityService);
};

}  // namespace domain_reliability

#endif  // COMPONENTS_DOMAIN_RELIABILITY_SERVICE_H_