Index: chrome/browser/local_discovery/service_discovery_shared_client.cc |
diff --git a/chrome/browser/local_discovery/service_discovery_shared_client.cc b/chrome/browser/local_discovery/service_discovery_shared_client.cc |
index e7f851e50c0b38f229991c7904e752b64c3a9e1d..7193b33b4d6937b2eaa26fea4785c7ee68337bac 100644 |
--- a/chrome/browser/local_discovery/service_discovery_shared_client.cc |
+++ b/chrome/browser/local_discovery/service_discovery_shared_client.cc |
@@ -29,8 +29,12 @@ namespace { |
#if defined(OS_WIN) |
bool g_is_firewall_ready = false; |
+bool g_is_firewall_state_reported = false; |
void ReportFirewallStats() { |
+ if (g_is_firewall_state_reported) |
+ return; |
+ g_is_firewall_state_reported = true; |
base::FilePath exe_path; |
if (!PathService::Get(base::FILE_EXE, &exe_path)) |
return; |
@@ -80,18 +84,41 @@ scoped_refptr<ServiceDiscoverySharedClient> |
return ServiceDiscoveryClientMacFactory::CreateInstance(); |
#else // OS_MACOSX |
-#if defined(OS_WIN) |
- static bool reported = |
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
- base::Bind(&ReportFirewallStats)); |
+ return new ServiceDiscoveryClientMdns(); |
Noam Samuel
2014/08/27 17:58:56
Maybe do
if (g_is_firewall_state_reported) {
ret
Vitaly Buka (NO REVIEWS)
2014/08/27 18:08:27
Goal is always use ServiceDiscoveryClientMdns. Onl
|
+#endif // OS_MACOSX |
+} |
+ |
+// static |
+void ServiceDiscoverySharedClient::GetInstanceWithoutAlert( |
+ const GetInstanceCallback& callback) { |
+#if !defined(OS_WIN) |
+ |
+ scoped_refptr<ServiceDiscoverySharedClient> result = GetInstance(); |
+ return callback.Run(result); |
+ |
+#else // OS_WIN |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
// TODO(vitalybuka): Switch to |ServiceDiscoveryClientMdns| after we find what |
// to do with firewall for user-level installs. crbug.com/366408 |
- if (!g_is_firewall_ready) |
- return new ServiceDiscoveryClientUtility(); |
-#endif // OS_WIN |
+ scoped_refptr<ServiceDiscoverySharedClient> result = |
+ g_service_discovery_client; |
+ if (result) |
+ return callback.Run(result); |
+ |
+ if (!g_is_firewall_state_reported) { |
+ BrowserThread::PostTaskAndReply( |
+ BrowserThread::FILE, |
+ FROM_HERE, |
+ base::Bind(&ReportFirewallStats), |
+ base::Bind(&ServiceDiscoverySharedClient::GetInstanceWithoutAlert, |
+ callback)); |
+ return; |
+ } |
- return new ServiceDiscoveryClientMdns(); |
-#endif // OS_MACOSX |
+ result = |
+ g_is_firewall_ready ? GetInstance() : new ServiceDiscoveryClientUtility(); |
+ callback.Run(result); |
+#endif // OS_WIN |
} |
#else |