Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(899)

Side by Side Diff: chrome/browser/local_discovery/service_discovery_shared_client.cc

Issue 287923002: Enable ServiceDiscoveryClientMdns. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/local_discovery/service_discovery_shared_client.h" 5 #include "chrome/browser/local_discovery/service_discovery_shared_client.h"
6 6
7 #include "content/public/browser/browser_thread.h" 7 #include "content/public/browser/browser_thread.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/timer/elapsed_timer.h" 13 #include "base/timer/elapsed_timer.h"
14 #include "chrome/installer/util/browser_distribution.h" 14 #include "chrome/installer/util/browser_distribution.h"
15 #include "chrome/installer/util/firewall_manager_win.h" 15 #include "chrome/installer/util/firewall_manager_win.h"
16 #endif // OS_WIN 16 #endif // OS_WIN
17 17
18 #if defined(OS_MACOSX) 18 #if defined(OS_MACOSX)
19 #include "chrome/browser/local_discovery/service_discovery_client_mac_factory.h" 19 #include "chrome/browser/local_discovery/service_discovery_client_mac_factory.h"
20 #endif 20 #endif
21 21
22 #if defined(ENABLE_MDNS) 22 #if defined(ENABLE_MDNS)
23 #include "chrome/browser/local_discovery/service_discovery_client_mdns.h"
23 #include "chrome/browser/local_discovery/service_discovery_client_utility.h" 24 #include "chrome/browser/local_discovery/service_discovery_client_utility.h"
24 #endif // ENABLE_MDNS 25 #endif // ENABLE_MDNS
25 26
26 namespace { 27 namespace {
27 28
28 #if defined(OS_WIN) 29 #if defined(OS_WIN)
30
31 bool g_is_firewall_ready = false;
32
29 void ReportFirewallStats() { 33 void ReportFirewallStats() {
30 base::FilePath exe_path; 34 base::FilePath exe_path;
31 if (!PathService::Get(base::FILE_EXE, &exe_path)) 35 if (!PathService::Get(base::FILE_EXE, &exe_path))
32 return; 36 return;
33 base::ElapsedTimer timer; 37 base::ElapsedTimer timer;
34 scoped_ptr<installer::FirewallManager> manager = 38 scoped_ptr<installer::FirewallManager> manager =
35 installer::FirewallManager::Create(BrowserDistribution::GetDistribution(), 39 installer::FirewallManager::Create(BrowserDistribution::GetDistribution(),
36 exe_path); 40 exe_path);
37 if (!manager) 41 if (!manager)
38 return; 42 return;
39 bool is_ready = manager->CanUseLocalPorts(); 43 g_is_firewall_ready = manager->CanUseLocalPorts();
40 UMA_HISTOGRAM_TIMES("LocalDiscovery.FirewallAccessTime", timer.Elapsed()); 44 UMA_HISTOGRAM_TIMES("LocalDiscovery.FirewallAccessTime", timer.Elapsed());
41 UMA_HISTOGRAM_BOOLEAN("LocalDiscovery.IsFirewallReady", is_ready); 45 UMA_HISTOGRAM_BOOLEAN("LocalDiscovery.IsFirewallReady", g_is_firewall_ready);
42 } 46 }
43 #endif // OS_WIN 47 #endif // OS_WIN
44 48
45 } // namespace 49 } // namespace
46 50
47 51
48 namespace local_discovery { 52 namespace local_discovery {
49 53
50 using content::BrowserThread; 54 using content::BrowserThread;
51 55
(...skipping 21 matching lines...) Expand all
73 return g_service_discovery_client; 77 return g_service_discovery_client;
74 78
75 #if defined(OS_MACOSX) 79 #if defined(OS_MACOSX)
76 return ServiceDiscoveryClientMacFactory::CreateInstance(); 80 return ServiceDiscoveryClientMacFactory::CreateInstance();
77 #else // OS_MACOSX 81 #else // OS_MACOSX
78 82
79 #if defined(OS_WIN) 83 #if defined(OS_WIN)
80 static bool reported = 84 static bool reported =
81 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 85 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
82 base::Bind(&ReportFirewallStats)); 86 base::Bind(&ReportFirewallStats));
87 // TODO(vitalybuka): Switch to |ServiceDiscoveryClientMdns| after we find what
88 // to do with firewall for user-level installs. crbug.com/366408
89 if (!g_is_firewall_ready)
90 return new ServiceDiscoveryClientUtility();
Noam Samuel 2014/05/14 18:35:09 Does this mean that ServiceDiscoveryClientUtility
Vitaly Buka (NO REVIEWS) 2014/05/14 19:11:41 No. Only one is alive in time. Check g_service_dis
Noam Samuel 2014/05/14 19:54:45 Wait, so does this mean that Chrome on Windows wil
83 #endif // OS_WIN 91 #endif // OS_WIN
84 92
85 // TODO(vitalybuka): Switch to |ServiceDiscoveryClientMdns| after we find what 93 return new ServiceDiscoveryClientMdns();
86 // to do with firewall for user-level installs. crbug.com/366408
87 return new ServiceDiscoveryClientUtility();
88 #endif // OS_MACOSX 94 #endif // OS_MACOSX
89 } 95 }
90 96
91 #else 97 #else
92 98
93 scoped_refptr<ServiceDiscoverySharedClient> 99 scoped_refptr<ServiceDiscoverySharedClient>
94 ServiceDiscoverySharedClient::GetInstance() { 100 ServiceDiscoverySharedClient::GetInstance() {
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
96 NOTIMPLEMENTED(); 102 NOTIMPLEMENTED();
97 return NULL; 103 return NULL;
98 } 104 }
99 105
100 #endif // ENABLE_MDNS 106 #endif // ENABLE_MDNS
101 107
102 } // namespace local_discovery 108 } // namespace local_discovery
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698