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

Unified Diff: chrome/browser/local_discovery/privet_device_resolver.cc

Issue 131503013: Added PrivetDeviceResolver to resolve a device and parse it as a privet device (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
« no previous file with comments | « chrome/browser/local_discovery/privet_device_resolver.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/local_discovery/privet_device_resolver.cc
diff --git a/chrome/browser/local_discovery/privet_device_resolver.cc b/chrome/browser/local_discovery/privet_device_resolver.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6bbb13b6bf5b31dd93b44b509103c84f862eed0d
--- /dev/null
+++ b/chrome/browser/local_discovery/privet_device_resolver.cc
@@ -0,0 +1,42 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "chrome/browser/local_discovery/privet_device_resolver.h"
+
+namespace local_discovery {
+
+PrivetDeviceResolver::PrivetDeviceResolver(
+ ServiceDiscoveryClient* service_discovery_client,
+ const std::string& service_name,
+ const ResultCallback& callback)
+ : service_discovery_client_(service_discovery_client),
+ service_name_(service_name), callback_(callback) {
+}
+
+PrivetDeviceResolver::~PrivetDeviceResolver() {
+}
+
+void PrivetDeviceResolver::Start() {
+ service_resolver_ = service_discovery_client_->CreateServiceResolver(
+ service_name_,
+ base::Bind(&PrivetDeviceResolver::OnServiceResolved,
+ base::Unretained(this)));
+ service_resolver_->StartResolving();
+}
+
+void PrivetDeviceResolver::OnServiceResolved(
+ ServiceResolver::RequestStatus request_status,
+ const ServiceDescription& service_description) {
+ DeviceDescription device_description;
+ if (request_status != ServiceResolver::STATUS_SUCCESS) {
+ callback_.Run(false, device_description);
+ return;
+ }
+
+ device_description.FillFromServiceDescription(service_description);
+ callback_.Run(true, device_description);
+}
+
+} // namespace local_discovery
« no previous file with comments | « chrome/browser/local_discovery/privet_device_resolver.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698