Commit 093318e5 authored by horo@chromium.org's avatar horo@chromium.org

Revert 282098 "Add function queryForNewLocalDevices to send quer..."

> Add function queryForNewLocalDevices to send query for new local devices,
> implement it for mDNS (WiFi devices forthcoming)
> 
> BUG=383167
> 
> Review URL: https://codereview.chromium.org/356613002

TBR=noamsml@chromium.org

Review URL: https://codereview.chromium.org/377383008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282217 0039d316-1c4b-4281-b951-d872f2087c98
parent ae2ce569
......@@ -154,15 +154,6 @@ void GcdPrivateAPI::DeviceCacheFlushed() {
known_devices_.clear();
}
bool GcdPrivateAPI::QueryForDevices() {
if (!privet_device_lister_)
return false;
privet_device_lister_->DiscoverNewDevices(true);
return true;
}
// static
void GcdPrivateAPI::SetGCDApiFlowFactoryForTests(
GCDApiFlowFactoryForTests* factory) {
......@@ -244,29 +235,6 @@ void GcdPrivateGetCloudDeviceListFunction::CheckListingDone() {
Release();
}
GcdPrivateQueryForNewLocalDevicesFunction::
GcdPrivateQueryForNewLocalDevicesFunction() {
}
GcdPrivateQueryForNewLocalDevicesFunction::
~GcdPrivateQueryForNewLocalDevicesFunction() {
}
bool GcdPrivateQueryForNewLocalDevicesFunction::RunSync() {
GcdPrivateAPI* gcd_api =
BrowserContextKeyedAPIFactory<GcdPrivateAPI>::Get(GetProfile());
if (!gcd_api)
return false;
if (!gcd_api->QueryForDevices()) {
error_ = "You must first subscribe to onDeviceStateChanged notifications";
return false;
}
return true;
}
GcdPrivateStartSetupFunction::GcdPrivateStartSetupFunction() {
}
......
......@@ -37,8 +37,6 @@ class GcdPrivateAPI : public BrowserContextKeyedAPI,
// BrowserContextKeyedAPI implementation.
static BrowserContextKeyedAPIFactory<GcdPrivateAPI>* GetFactoryInstance();
bool QueryForDevices();
private:
friend class BrowserContextKeyedAPIFactory<GcdPrivateAPI>;
......@@ -100,7 +98,7 @@ class GcdPrivateGetCloudDeviceListFunction
};
class GcdPrivateQueryForNewLocalDevicesFunction
: public ChromeSyncExtensionFunction {
: public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.queryForNewLocalDevices",
GCDPRIVATE_QUERYFORNEWLOCALDEVICES)
......@@ -110,8 +108,8 @@ class GcdPrivateQueryForNewLocalDevicesFunction
protected:
virtual ~GcdPrivateQueryForNewLocalDevicesFunction();
// SyncExtensionFunction overrides.
virtual bool RunSync() OVERRIDE;
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
};
class GcdPrivateStartSetupFunction : public ChromeAsyncExtensionFunction {
......
......@@ -130,22 +130,6 @@ const uint8 kGoodbyePacket[] = {
'o', 'c', 'a', 'l', 0x00,
};
const uint8 kQueryPacket[] = {
// Header
0x00, 0x00, // ID is zeroed out
0x00, 0x00, // No flags.
0x00, 0x01, // One question.
0x00, 0x00, // 0 RRs (answers)
0x00, 0x00, // 0 authority RRs
0x00, 0x00, // 0 additional RRs
// Question
// This part is echoed back from the respective query.
0x07, '_', 'p', 'r', 'i', 'v', 'e', 't', 0x04, '_', 't', 'c',
'p', 0x05, 'l', 'o', 'c', 'a', 'l', 0x00, 0x00, 0x0c, // TYPE is PTR.
0x00, 0x01, // CLASS is IN.
};
#endif // ENABLE_MDNS
// Sentinel value to signify the request should fail.
......@@ -270,14 +254,6 @@ IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddRemove) {
EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "remove_device.html"));
}
IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, SendQuery) {
EXPECT_CALL(*test_service_discovery_client_,
OnSendTo(std::string(reinterpret_cast<const char*>(kQueryPacket),
sizeof(kQueryPacket)))).Times(2);
EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "send_query.html"));
}
#endif // ENABLE_MDNS
} // namespace
......@@ -40,11 +40,6 @@ namespace gcdPrivate {
interface Functions {
static void getCloudDeviceList(CloudDeviceListCallback callback);
// Call this function *only* after registering for onDeviceStateChanged
// events, or it will do nothing. This will trigger an
// onLocalDeviceStateChanged event per device.
static void queryForNewLocalDevices();
// Starts device setup process. Returns id of setup process. Id should be
// used as |setupId| in all subsequent setup related calls, and for
// filtering setup events.
......
// 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.
onload = function() {
chrome.test.runTests([
function receiveNewDevice() {
chrome.gcdPrivate.onCloudDeviceStateChanged.addListener(
function(available, device) {});
chrome.gcdPrivate.queryForNewLocalDevices();
chrome.test.notifyPass();
}]);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment