Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / components / domain_reliability / service.h
1 // Copyright 2014 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 COMPONENTS_DOMAIN_RELIABILITY_SERVICE_H_
6 #define COMPONENTS_DOMAIN_RELIABILITY_SERVICE_H_
7
8 #include <string>
9
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/single_thread_task_runner.h"
15 #include "components/domain_reliability/clear_mode.h"
16 #include "components/domain_reliability/domain_reliability_export.h"
17 #include "components/keyed_service/core/keyed_service.h"
18
19 class PrefService;
20
21 namespace base {
22 class Value;
23 }  // namespace base
24
25 namespace net {
26 class URLRequestContextGetter;
27 }  // namespace net
28
29 namespace domain_reliability {
30
31 class DomainReliabilityMonitor;
32
33 // DomainReliabilityService is a KeyedService that manages a Monitor that lives
34 // on another thread (as provided by the URLRequestContextGetter's task runner)
35 // and proxies (selected) method calls to it. Destruction of the Monitor (on
36 // that thread) is the responsibility of the caller.
37 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityService
38     : public KeyedService {
39  public:
40   // Creates a DomainReliabilityService that will contain a Monitor with the
41   // given upload reporter string.
42   static DomainReliabilityService* Create(
43       const std::string& upload_reporter_string);
44
45   virtual ~DomainReliabilityService();
46
47   // Initializes the Service: given the task runner on which Monitor methods
48   // should be called, creates the Monitor and returns it. Can be called at
49   // most once, and must be called before any of the below methods can be
50   // called. The caller is responsible for destroying the Monitor on the given
51   // task runner when it is no longer needed.
52   virtual scoped_ptr<DomainReliabilityMonitor> CreateMonitor(
53       scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
54       PrefService* pref_service,
55       const char* reporting_pref_name) = 0;
56
57   // Clears browsing data on the associated Monitor. |Init()| must have been
58   // called first.
59   virtual void ClearBrowsingData(DomainReliabilityClearMode clear_mode,
60                                  const base::Closure& callback) = 0;
61
62   virtual void GetWebUIData(
63       const base::Callback<void(scoped_ptr<base::Value>)>& callback)
64       const = 0;
65
66  protected:
67   DomainReliabilityService();
68
69  private:
70   DISALLOW_COPY_AND_ASSIGN(DomainReliabilityService);
71 };
72
73 }  // namespace domain_reliability
74
75 #endif  // COMPONENTS_DOMAIN_RELIABILITY_SERVICE_H_