Chromium Code Reviews| Index: components/domain_reliability/service.cc |
| diff --git a/components/domain_reliability/service.cc b/components/domain_reliability/service.cc |
| index eba9ddfaa81d31e7fe72c3b90c85ae6d1d873030..6e3517a489c1bcaa79563b9350ff0c6d229c729d 100644 |
| --- a/components/domain_reliability/service.cc |
| +++ b/components/domain_reliability/service.cc |
| @@ -12,6 +12,24 @@ |
| namespace domain_reliability { |
| +namespace { |
| + |
| +void GetWebUIDataOnNetworkTaskRunner( |
| + base::WeakPtr<DomainReliabilityMonitor> monitor, |
| + scoped_ptr<const base::Value>* data_out) { |
| + if (monitor) |
| + *data_out = monitor->GetWebUIData(); |
| +} |
| + |
| +void CallGetWebUIDataCallbackAndDeleteDataPointer( |
| + const base::Callback<void(scoped_ptr<const base::Value>)>& callback, |
| + scoped_ptr<const base::Value>* data_in) { |
| + callback.Run(data_in->Pass()); |
| + delete data_in; |
| +} |
| + |
| +} // namespace |
| + |
| class DomainReliabilityServiceImpl : public DomainReliabilityService { |
| public: |
| explicit DomainReliabilityServiceImpl( |
| @@ -47,6 +65,22 @@ class DomainReliabilityServiceImpl : public DomainReliabilityService { |
| callback); |
| } |
| + virtual void GetWebUIData( |
| + const base::Callback<void(scoped_ptr<const base::Value>)>& callback) |
| + const OVERRIDE { |
| + DCHECK(network_task_runner_); |
| + |
| + scoped_ptr<const base::Value>* data = |
| + new scoped_ptr<const base::Value>(new base::DictionaryValue()); |
| + network_task_runner_->PostTaskAndReply(FROM_HERE, |
|
Bernhard Bauer
2014/06/28 11:16:35
I think you can do this with base::PostTaskAndRepl
Deprecated (see juliatuttle)
2014/06/30 16:58:21
Nah, I can't; it won't let me bind a weak pointer
Bernhard Bauer
2014/06/30 17:26:54
:-( Could you write a wrapper function like this:
|
| + base::Bind(&GetWebUIDataOnNetworkTaskRunner, |
| + monitor_, |
| + data), |
| + base::Bind(&CallGetWebUIDataCallbackAndDeleteDataPointer, |
| + callback, |
| + data)); |
| + } |
| + |
| private: |
| std::string upload_reporter_string_; |
| base::WeakPtr<DomainReliabilityMonitor> monitor_; |