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.
5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_SERVICE_H_
6 #define COMPONENTS_DOMAIN_RELIABILITY_SERVICE_H_
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"
26 class URLRequestContextGetter
;
29 namespace domain_reliability
{
31 class DomainReliabilityMonitor
;
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
{
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
);
45 virtual ~DomainReliabilityService();
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;
57 // Clears browsing data on the associated Monitor. |Init()| must have been
59 virtual void ClearBrowsingData(DomainReliabilityClearMode clear_mode
,
60 const base::Closure
& callback
) = 0;
62 virtual void GetWebUIData(
63 const base::Callback
<void(scoped_ptr
<base::Value
>)>& callback
)
67 DomainReliabilityService();
70 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityService
);
73 } // namespace domain_reliability
75 #endif // COMPONENTS_DOMAIN_RELIABILITY_SERVICE_H_