Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / local_discovery / service_discovery_shared_client.cc
blobd5fc9e0a33d6fa2a91d2f9bea440a2c02f01ec90
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
3 // found in the LICENSE file.
5 #include "chrome/browser/local_discovery/service_discovery_shared_client.h"
7 #include "content/public/browser/browser_thread.h"
9 #if defined(OS_MACOSX)
10 #include "chrome/browser/local_discovery/service_discovery_client_mac_factory.h"
11 #endif
13 #if defined(ENABLE_MDNS)
14 #include "chrome/browser/local_discovery/service_discovery_client_mdns.h"
15 #endif // ENABLE_MDNS
17 namespace local_discovery {
19 using content::BrowserThread;
21 namespace {
22 ServiceDiscoverySharedClient* g_service_discovery_client = NULL;
23 } // namespace
25 ServiceDiscoverySharedClient::ServiceDiscoverySharedClient() {
26 DCHECK(!g_service_discovery_client);
27 g_service_discovery_client = this;
30 ServiceDiscoverySharedClient::~ServiceDiscoverySharedClient() {
31 DCHECK_EQ(g_service_discovery_client, this);
32 g_service_discovery_client = NULL;
35 #if defined(ENABLE_MDNS) || defined(OS_MACOSX)
37 scoped_refptr<ServiceDiscoverySharedClient>
38 ServiceDiscoverySharedClient::GetInstance() {
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
41 if (g_service_discovery_client)
42 return g_service_discovery_client;
44 #if defined(OS_MACOSX)
45 return ServiceDiscoveryClientMacFactory::CreateInstance();
46 #else
47 return new ServiceDiscoveryClientMdns();
48 #endif
51 #else
53 scoped_refptr<ServiceDiscoverySharedClient>
54 ServiceDiscoverySharedClient::GetInstance() {
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
56 NOTIMPLEMENTED();
57 return NULL;
60 #endif // ENABLE_MDNS
62 } // namespace local_discovery