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

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

Issue 452843002: Revert 270745 "Enable ServiceDiscoveryClientMdns." to fix crash. (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 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"
24 #include "chrome/browser/local_discovery/service_discovery_client_utility.h" 23 #include "chrome/browser/local_discovery/service_discovery_client_utility.h"
25 #endif // ENABLE_MDNS 24 #endif // ENABLE_MDNS
26 25
27 namespace { 26 namespace {
28 27
29 #if defined(OS_WIN) 28 #if defined(OS_WIN)
30
31 bool g_is_firewall_ready = false;
32
33 void ReportFirewallStats() { 29 void ReportFirewallStats() {
34 base::FilePath exe_path; 30 base::FilePath exe_path;
35 if (!PathService::Get(base::FILE_EXE, &exe_path)) 31 if (!PathService::Get(base::FILE_EXE, &exe_path))
36 return; 32 return;
37 base::ElapsedTimer timer; 33 base::ElapsedTimer timer;
38 scoped_ptr<installer::FirewallManager> manager = 34 scoped_ptr<installer::FirewallManager> manager =
39 installer::FirewallManager::Create(BrowserDistribution::GetDistribution(), 35 installer::FirewallManager::Create(BrowserDistribution::GetDistribution(),
40 exe_path); 36 exe_path);
41 if (!manager) 37 if (!manager)
42 return; 38 return;
43 g_is_firewall_ready = manager->CanUseLocalPorts(); 39 bool is_ready = manager->CanUseLocalPorts();
44 UMA_HISTOGRAM_TIMES("LocalDiscovery.FirewallAccessTime", timer.Elapsed()); 40 UMA_HISTOGRAM_TIMES("LocalDiscovery.FirewallAccessTime", timer.Elapsed());
45 UMA_HISTOGRAM_BOOLEAN("LocalDiscovery.IsFirewallReady", g_is_firewall_ready); 41 UMA_HISTOGRAM_BOOLEAN("LocalDiscovery.IsFirewallReady", is_ready);
46 } 42 }
47 #endif // OS_WIN 43 #endif // OS_WIN
48 44
49 } // namespace 45 } // namespace
50 46
51 47
52 namespace local_discovery { 48 namespace local_discovery {
53 49
54 using content::BrowserThread; 50 using content::BrowserThread;
55 51
(...skipping 21 matching lines...) Expand all
77 return g_service_discovery_client; 73 return g_service_discovery_client;
78 74
79 #if defined(OS_MACOSX) 75 #if defined(OS_MACOSX)
80 return ServiceDiscoveryClientMacFactory::CreateInstance(); 76 return ServiceDiscoveryClientMacFactory::CreateInstance();
81 #else // OS_MACOSX 77 #else // OS_MACOSX
82 78
83 #if defined(OS_WIN) 79 #if defined(OS_WIN)
84 static bool reported = 80 static bool reported =
85 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 81 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
86 base::Bind(&ReportFirewallStats)); 82 base::Bind(&ReportFirewallStats));
83 #endif // OS_WIN
84
87 // TODO(vitalybuka): Switch to |ServiceDiscoveryClientMdns| after we find what 85 // TODO(vitalybuka): Switch to |ServiceDiscoveryClientMdns| after we find what
88 // to do with firewall for user-level installs. crbug.com/366408 86 // to do with firewall for user-level installs. crbug.com/366408
89 if (!g_is_firewall_ready) 87 return new ServiceDiscoveryClientUtility();
90 return new ServiceDiscoveryClientUtility();
91 #endif // OS_WIN
92
93 return new ServiceDiscoveryClientMdns();
94 #endif // OS_MACOSX 88 #endif // OS_MACOSX
95 } 89 }
96 90
97 #else 91 #else
98 92
99 scoped_refptr<ServiceDiscoverySharedClient> 93 scoped_refptr<ServiceDiscoverySharedClient>
100 ServiceDiscoverySharedClient::GetInstance() { 94 ServiceDiscoverySharedClient::GetInstance() {
101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
102 NOTIMPLEMENTED(); 96 NOTIMPLEMENTED();
103 return NULL; 97 return NULL;
104 } 98 }
105 99
106 #endif // ENABLE_MDNS 100 #endif // ENABLE_MDNS
107 101
108 } // namespace local_discovery 102 } // 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