OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/domain_reliability/service.h" | 5 #include "components/domain_reliability/service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 const std::string& upload_reporter_string) | 35 const std::string& upload_reporter_string) |
36 : upload_reporter_string_(upload_reporter_string) {} | 36 : upload_reporter_string_(upload_reporter_string) {} |
37 | 37 |
38 virtual ~DomainReliabilityServiceImpl() {} | 38 virtual ~DomainReliabilityServiceImpl() {} |
39 | 39 |
40 // DomainReliabilityService implementation: | 40 // DomainReliabilityService implementation: |
41 | 41 |
42 virtual scoped_ptr<DomainReliabilityMonitor> CreateMonitor( | 42 virtual scoped_ptr<DomainReliabilityMonitor> CreateMonitor( |
43 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 43 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
44 PrefService* local_state_pref_service, | 44 PrefService* local_state_pref_service, |
45 const char* reporting_pref_name) OVERRIDE { | 45 const char* reporting_pref_name) override { |
46 DCHECK(!network_task_runner_.get()); | 46 DCHECK(!network_task_runner_.get()); |
47 | 47 |
48 scoped_ptr<DomainReliabilityMonitor> monitor( | 48 scoped_ptr<DomainReliabilityMonitor> monitor( |
49 new DomainReliabilityMonitor(upload_reporter_string_, | 49 new DomainReliabilityMonitor(upload_reporter_string_, |
50 base::MessageLoopProxy::current(), | 50 base::MessageLoopProxy::current(), |
51 network_task_runner, | 51 network_task_runner, |
52 local_state_pref_service, | 52 local_state_pref_service, |
53 reporting_pref_name)); | 53 reporting_pref_name)); |
54 | 54 |
55 monitor_ = monitor->MakeWeakPtr(); | 55 monitor_ = monitor->MakeWeakPtr(); |
56 network_task_runner_ = network_task_runner; | 56 network_task_runner_ = network_task_runner; |
57 | 57 |
58 return monitor.Pass(); | 58 return monitor.Pass(); |
59 } | 59 } |
60 | 60 |
61 virtual void ClearBrowsingData(DomainReliabilityClearMode clear_mode, | 61 virtual void ClearBrowsingData(DomainReliabilityClearMode clear_mode, |
62 const base::Closure& callback) OVERRIDE { | 62 const base::Closure& callback) override { |
63 DCHECK(network_task_runner_.get()); | 63 DCHECK(network_task_runner_.get()); |
64 | 64 |
65 network_task_runner_->PostTaskAndReply( | 65 network_task_runner_->PostTaskAndReply( |
66 FROM_HERE, | 66 FROM_HERE, |
67 base::Bind(&DomainReliabilityMonitor::ClearBrowsingData, | 67 base::Bind(&DomainReliabilityMonitor::ClearBrowsingData, |
68 monitor_, | 68 monitor_, |
69 clear_mode), | 69 clear_mode), |
70 callback); | 70 callback); |
71 } | 71 } |
72 | 72 |
73 virtual void GetWebUIData( | 73 virtual void GetWebUIData( |
74 const base::Callback<void(scoped_ptr<base::Value>)>& callback) | 74 const base::Callback<void(scoped_ptr<base::Value>)>& callback) |
75 const OVERRIDE { | 75 const override { |
76 DCHECK(network_task_runner_.get()); | 76 DCHECK(network_task_runner_.get()); |
77 | 77 |
78 PostTaskAndReplyWithResult( | 78 PostTaskAndReplyWithResult( |
79 network_task_runner_.get(), | 79 network_task_runner_.get(), |
80 FROM_HERE, | 80 FROM_HERE, |
81 base::Bind(&GetWebUIDataOnNetworkTaskRunner, monitor_), | 81 base::Bind(&GetWebUIDataOnNetworkTaskRunner, monitor_), |
82 callback); | 82 callback); |
83 } | 83 } |
84 | 84 |
85 private: | 85 private: |
86 std::string upload_reporter_string_; | 86 std::string upload_reporter_string_; |
87 base::WeakPtr<DomainReliabilityMonitor> monitor_; | 87 base::WeakPtr<DomainReliabilityMonitor> monitor_; |
88 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 88 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
89 }; | 89 }; |
90 | 90 |
91 // static | 91 // static |
92 DomainReliabilityService* DomainReliabilityService::Create( | 92 DomainReliabilityService* DomainReliabilityService::Create( |
93 const std::string& upload_reporter_string) { | 93 const std::string& upload_reporter_string) { |
94 return new DomainReliabilityServiceImpl(upload_reporter_string); | 94 return new DomainReliabilityServiceImpl(upload_reporter_string); |
95 } | 95 } |
96 | 96 |
97 DomainReliabilityService::~DomainReliabilityService() {} | 97 DomainReliabilityService::~DomainReliabilityService() {} |
98 | 98 |
99 DomainReliabilityService::DomainReliabilityService() {} | 99 DomainReliabilityService::DomainReliabilityService() {} |
100 | 100 |
101 } // namespace domain_reliability | 101 } // namespace domain_reliability |
OLD | NEW |