This source file includes following definitions.
- GetInstance
- GetInstance
#include "chrome/browser/local_discovery/service_discovery_shared_client.h"
#include "content/public/browser/browser_thread.h"
#if defined(OS_MACOSX)
#include "chrome/browser/local_discovery/service_discovery_client_mac_factory.h"
#endif
#if defined(ENABLE_MDNS)
#include "chrome/browser/local_discovery/service_discovery_client_mdns.h"
#endif
namespace local_discovery {
using content::BrowserThread;
namespace {
ServiceDiscoverySharedClient* g_service_discovery_client = NULL;
}
ServiceDiscoverySharedClient::ServiceDiscoverySharedClient() {
DCHECK(!g_service_discovery_client);
g_service_discovery_client = this;
}
ServiceDiscoverySharedClient::~ServiceDiscoverySharedClient() {
DCHECK_EQ(g_service_discovery_client, this);
g_service_discovery_client = NULL;
}
#if defined(ENABLE_MDNS) || defined(OS_MACOSX)
scoped_refptr<ServiceDiscoverySharedClient>
ServiceDiscoverySharedClient::GetInstance() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (g_service_discovery_client)
return g_service_discovery_client;
#if defined(OS_MACOSX)
return ServiceDiscoveryClientMacFactory::CreateInstance();
#else
return new ServiceDiscoveryClientMdns();
#endif
}
#else
scoped_refptr<ServiceDiscoverySharedClient>
ServiceDiscoverySharedClient::GetInstance() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
NOTIMPLEMENTED();
return NULL;
}
#endif
}