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

Unified Diff: chrome/browser/extensions/api/dial/dial_api.cc

Issue 22870011: chrome.mdns API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/dial/dial_api.cc
diff --git a/chrome/browser/extensions/api/dial/dial_api.cc b/chrome/browser/extensions/api/dial/dial_api.cc
index 02f6d8222a20a0c7099c460ab4dd19bdefe2074e..9ba56141821ae6137ccb45172ab08cab780eacd9 100644
--- a/chrome/browser/extensions/api/dial/dial_api.cc
+++ b/chrome/browser/extensions/api/dial/dial_api.cc
@@ -31,6 +31,9 @@ const int kDialExpirationSecs = 240;
// The maximum number of devices retained at once in the registry.
const size_t kDialMaxDevices = 256;
+//
+const char kCastDefaultDeviceType[] = "_privet._tcp.local";
mark a. foltz 2013/08/19 18:25:26 _googlecast._tcp
+
} // namespace
namespace extensions {
@@ -55,6 +58,15 @@ DialRegistry* DialAPI::dial_registry() {
return dial_registry_.get();
}
+MDNSService* DialAPI::mdns_service() {
+ // TODO(justinlin): Any creation/access thread constraints?
mark a. foltz 2013/08/19 18:25:26 I think this should be fine, the host side of the
+ // DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (!mdns_service_.get()) {
+ mdns_service_.reset(new MDNSService(kCastDefaultDeviceType));
+ }
+ return mdns_service_.get();
+}
+
void DialAPI::OnListenerAdded(const EventListenerInfo& details) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask(
@@ -171,6 +183,34 @@ bool DialDiscoverNowFunction::Respond() {
return true;
}
+
+DialGetNetworkServicesFunction::DialGetNetworkServicesFunction()
+ : dial_(NULL), result_(false) {
+}
+
+bool DialGetNetworkServicesFunction::Prepare() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(profile());
+ dial_ = DialAPIFactory::GetInstance()->GetForProfile(profile()).get();
+ return true;
+}
+
+void DialGetNetworkServicesFunction::Work() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
mark a. foltz 2013/08/19 18:25:26 I think this should be okay to be a synchronous fu
+ // TODO(justinlin): Should instead instantiate a NetworkServicesRegistry,
+ // which calls into MDNSService.
+ result_ = dial_->mdns_service()->Start();
+}
+
+bool DialGetNetworkServicesFunction::Respond() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (!result_)
+ error_ = kDialServiceError;
+
+ SetResult(new base::FundamentalValue(result_));
+ return true;
+}
+
} // namespace api
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698