Clean dead code w.r.t already-deleted multi-threat-block interstitial.
[chromium-blink-merge.git] / components / domain_reliability / service.cc
blob3ce1cb1c147f28a65bc4e435ecb0caab8371a64c
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 #include "components/domain_reliability/service.h"
7 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/task_runner_util.h"
12 #include "components/domain_reliability/monitor.h"
13 #include "net/url_request/url_request_context_getter.h"
15 namespace domain_reliability {
17 namespace {
19 scoped_ptr<base::Value> GetWebUIDataOnNetworkTaskRunner(
20 base::WeakPtr<DomainReliabilityMonitor> monitor) {
21 if (!monitor) {
22 base::DictionaryValue* dict = new base::DictionaryValue();
23 dict->SetString("error", "no_monitor");
24 return scoped_ptr<base::Value>(dict);
27 return monitor->GetWebUIData();
30 } // namespace
32 class DomainReliabilityServiceImpl : public DomainReliabilityService {
33 public:
34 explicit DomainReliabilityServiceImpl(
35 const std::string& upload_reporter_string)
36 : upload_reporter_string_(upload_reporter_string) {}
38 ~DomainReliabilityServiceImpl() override {}
40 // DomainReliabilityService implementation:
42 scoped_ptr<DomainReliabilityMonitor> CreateMonitor(
43 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
44 override {
45 DCHECK(!network_task_runner_.get());
47 scoped_ptr<DomainReliabilityMonitor> monitor(
48 new DomainReliabilityMonitor(upload_reporter_string_,
49 base::MessageLoopProxy::current(),
50 network_task_runner));
52 monitor_ = monitor->MakeWeakPtr();
53 network_task_runner_ = network_task_runner;
55 return monitor.Pass();
58 void ClearBrowsingData(DomainReliabilityClearMode clear_mode,
59 const base::Closure& callback) override {
60 DCHECK(network_task_runner_.get());
62 network_task_runner_->PostTaskAndReply(
63 FROM_HERE,
64 base::Bind(&DomainReliabilityMonitor::ClearBrowsingData,
65 monitor_,
66 clear_mode),
67 callback);
70 void GetWebUIData(const base::Callback<void(scoped_ptr<base::Value>)>&
71 callback) const override {
72 DCHECK(network_task_runner_.get());
74 PostTaskAndReplyWithResult(
75 network_task_runner_.get(),
76 FROM_HERE,
77 base::Bind(&GetWebUIDataOnNetworkTaskRunner, monitor_),
78 callback);
81 private:
82 std::string upload_reporter_string_;
83 base::WeakPtr<DomainReliabilityMonitor> monitor_;
84 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
87 // static
88 DomainReliabilityService* DomainReliabilityService::Create(
89 const std::string& upload_reporter_string) {
90 return new DomainReliabilityServiceImpl(upload_reporter_string);
93 DomainReliabilityService::~DomainReliabilityService() {}
95 DomainReliabilityService::DomainReliabilityService() {}
97 } // namespace domain_reliability