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/sequenced_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 namespace net { 20 class URLRequestContextGetter; 21 }; 22 23 namespace domain_reliability { 24 25 class DomainReliabilityMonitor; 26 27 // DomainReliabilityService is a KeyedService that manages a Monitor that lives 28 // on another thread (as provided by the URLRequestContextGetter's task runner) 29 // and proxies (selected) method calls to it. Destruction of the Monitor (on 30 // that thread) is the responsibility of the caller. 31 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityService 32 : public KeyedService { 33 public: 34 // Creates a DomainReliabilityService that will contain a Monitor with the 35 // given upload reporter string. 36 static DomainReliabilityService* Create( 37 const std::string& upload_reporter_string); 38 39 virtual ~DomainReliabilityService(); 40 41 // Initializes the Service: given the task runner on which Monitor methods 42 // should be called, creates the Monitor and returns it. Can be called at 43 // most once, and must be called before any of the below methods can be 44 // called. The caller is responsible for destroying the Monitor on the given 45 // task runner when it is no longer needed. 46 virtual scoped_ptr<DomainReliabilityMonitor> Init( 47 scoped_refptr<base::SequencedTaskRunner> network_task_runner) = 0; 48 49 // Clears browsing data on the associated Monitor. |Init()| must have been 50 // called first. 51 virtual void ClearBrowsingData(DomainReliabilityClearMode clear_mode, 52 const base::Closure& callback) = 0; 53 54 // KeyedService implementation: 55 virtual void Shutdown() OVERRIDE = 0; 56 57 protected: 58 DomainReliabilityService(); 59 60 private: 61 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityService); 62 }; 63 64 } // namespace domain_reliability 65 66 #endif // COMPONENTS_DOMAIN_RELIABILITY_SERVICE_H_ 67