Index: chrome/browser/io_thread.cc |
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc |
index e6b3fabe94102f052a32ca49c6b2b8264804d969..e434dc76883f03a7e9e32654832350171f93d2cd 100644 |
--- a/chrome/browser/io_thread.cc |
+++ b/chrome/browser/io_thread.cc |
@@ -47,6 +47,7 @@ |
#include "components/data_usage/core/data_use_aggregator.h" |
#include "components/data_usage/core/data_use_amortizer.h" |
#include "components/data_usage/core/data_use_annotator.h" |
+#include "components/metrics/metrics_service.h" |
#include "components/net_log/chrome_net_log.h" |
#include "components/policy/core/common/policy_service.h" |
#include "components/prefs/pref_registry_simple.h" |
@@ -508,6 +509,16 @@ IOThread::IOThread( |
if (value) |
value->GetAsBoolean(&is_quic_allowed_by_policy_); |
+ // Some unit tests use IOThread but do not initialize MetricsService. In that |
+ // case it is fine not to have |metrics_data_use_forwarder_|. |
+ if (g_browser_process->metrics_service()) { |
+ // Callback for updating data use prefs should be obtained on UI thread. |
+ metrics_data_use_forwarder_ = |
+ metrics::DataUseTracker::GetForwardingCallback( |
+ g_browser_process->metrics_service()->GetDataUseTracker(), |
Alexei Svitkine (slow)
2016/03/31 04:32:25
Instead of having a static GetForwardingCallback()
gayane -on leave until 09-2017
2016/03/31 17:54:57
Done.
|
+ base::ThreadTaskRunnerHandle::Get()); |
+ } |
+ |
BrowserThread::SetDelegate(BrowserThread::IO, this); |
} |
@@ -614,7 +625,8 @@ void IOThread::Init() { |
"466432 IOThread::InitAsync::ChromeNetworkDelegate")); |
scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate( |
new ChromeNetworkDelegate(extension_event_router_forwarder(), |
- &system_enable_referrers_)); |
+ &system_enable_referrers_, |
+ metrics_data_use_forwarder_)); |
// By default, data usage is considered off the record. |
chrome_network_delegate->set_data_use_aggregator( |
globals_->data_use_aggregator.get(), |