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

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

Issue 268763006: Disable firewall check. It takes signifficant time, need to be on FILE thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fri 05/02/2014 16:39:31.63 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/browser/local_discovery/service_discovery_client_utility.h" 14 #include "chrome/browser/local_discovery/service_discovery_client_utility.h"
15 #include "chrome/installer/util/browser_distribution.h" 15 #include "chrome/installer/util/browser_distribution.h"
16 #include "chrome/installer/util/firewall_manager_win.h" 16 #include "chrome/installer/util/firewall_manager_win.h"
17 #endif // OS_WIN 17 #endif // OS_WIN
18 18
19 #if defined(OS_MACOSX) 19 #if defined(OS_MACOSX)
20 #include "chrome/browser/local_discovery/service_discovery_client_mac_factory.h" 20 #include "chrome/browser/local_discovery/service_discovery_client_mac_factory.h"
21 #endif 21 #endif
22 22
23 #if defined(ENABLE_MDNS) 23 #if defined(ENABLE_MDNS)
24 #include "chrome/browser/local_discovery/service_discovery_client_mdns.h" 24 #include "chrome/browser/local_discovery/service_discovery_client_mdns.h"
25 #endif // ENABLE_MDNS 25 #endif // ENABLE_MDNS
26 26
27 namespace { 27 namespace {
28 28
29 #if defined(OS_WIN) 29 #if defined(OS_WIN)
30 bool IsFirewallReady() { 30 void ReportFirewallStats() {
31 base::FilePath exe_path; 31 base::FilePath exe_path;
32 if (!PathService::Get(base::FILE_EXE, &exe_path)) 32 if (!PathService::Get(base::FILE_EXE, &exe_path))
33 return false; 33 return;
34 base::ElapsedTimer timer; 34 base::ElapsedTimer timer;
35 scoped_ptr<installer::FirewallManager> manager = 35 scoped_ptr<installer::FirewallManager> manager =
36 installer::FirewallManager::Create(BrowserDistribution::GetDistribution(), 36 installer::FirewallManager::Create(BrowserDistribution::GetDistribution(),
37 exe_path); 37 exe_path);
38 if (!manager) 38 if (!manager)
39 return false; 39 return;
40 bool is_ready = manager->CanUseLocalPorts(); 40 bool is_ready = manager->CanUseLocalPorts();
41 UMA_HISTOGRAM_TIMES("LocalDiscovery.FirewallAccessTime", timer.Elapsed()); 41 UMA_HISTOGRAM_TIMES("LocalDiscovery.FirewallAccessTime", timer.Elapsed());
42 UMA_HISTOGRAM_BOOLEAN("LocalDiscovery.IsFirewallReady", is_ready); 42 UMA_HISTOGRAM_BOOLEAN("LocalDiscovery.IsFirewallReady", is_ready);
43 return is_ready;
44 } 43 }
45 #endif // OS_WIN 44 #endif // OS_WIN
46 45
47 } // namespace 46 } // namespace
48 47
49 48
50 namespace local_discovery { 49 namespace local_discovery {
51 50
52 using content::BrowserThread; 51 using content::BrowserThread;
53 52
(...skipping 18 matching lines...) Expand all
72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
73 72
74 if (g_service_discovery_client) 73 if (g_service_discovery_client)
75 return g_service_discovery_client; 74 return g_service_discovery_client;
76 75
77 #if defined(OS_MACOSX) 76 #if defined(OS_MACOSX)
78 return ServiceDiscoveryClientMacFactory::CreateInstance(); 77 return ServiceDiscoveryClientMacFactory::CreateInstance();
79 #else 78 #else
80 79
81 #if defined(OS_WIN) 80 #if defined(OS_WIN)
82 static bool is_firewall_ready = IsFirewallReady(); 81 static bool reported =
83 if (!is_firewall_ready) { 82 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
84 // TODO(vitalybuka): Remove after we find what to do with firewall for 83 base::Bind(&ReportFirewallStats));
85 // user-level installs. crbug.com/366408 84 // TODO(vitalybuka): Switch to |ServiceDiscoveryClientMdns| after we find what
86 return new ServiceDiscoveryClientUtility(); 85 // to do with firewall for user-level installs. crbug.com/366408
87 } 86 return new ServiceDiscoveryClientUtility();
88 #endif // OS_WIN 87 #endif // OS_WIN
89 return new ServiceDiscoveryClientMdns(); 88 return new ServiceDiscoveryClientMdns();
90 #endif 89 #endif
91 } 90 }
92 91
93 #else 92 #else
94 93
95 scoped_refptr<ServiceDiscoverySharedClient> 94 scoped_refptr<ServiceDiscoverySharedClient>
96 ServiceDiscoverySharedClient::GetInstance() { 95 ServiceDiscoverySharedClient::GetInstance() {
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
98 NOTIMPLEMENTED(); 97 NOTIMPLEMENTED();
99 return NULL; 98 return NULL;
100 } 99 }
101 100
102 #endif // ENABLE_MDNS 101 #endif // ENABLE_MDNS
103 102
104 } // namespace local_discovery 103 } // 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