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() { ...@@ -154,15 +154,6 @@ void GcdPrivateAPI::DeviceCacheFlushed() {
known_devices_.clear(); known_devices_.clear();
} }
bool GcdPrivateAPI::QueryForDevices() {
if (!privet_device_lister_)
return false;
privet_device_lister_->DiscoverNewDevices(true);
return true;
}
// static // static
void GcdPrivateAPI::SetGCDApiFlowFactoryForTests( void GcdPrivateAPI::SetGCDApiFlowFactoryForTests(
GCDApiFlowFactoryForTests* factory) { GCDApiFlowFactoryForTests* factory) {
...@@ -244,29 +235,6 @@ void GcdPrivateGetCloudDeviceListFunction::CheckListingDone() { ...@@ -244,29 +235,6 @@ void GcdPrivateGetCloudDeviceListFunction::CheckListingDone() {
Release(); 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() { GcdPrivateStartSetupFunction::GcdPrivateStartSetupFunction() {
} }
......
...@@ -37,8 +37,6 @@ class GcdPrivateAPI : public BrowserContextKeyedAPI, ...@@ -37,8 +37,6 @@ class GcdPrivateAPI : public BrowserContextKeyedAPI,
// BrowserContextKeyedAPI implementation. // BrowserContextKeyedAPI implementation.
static BrowserContextKeyedAPIFactory<GcdPrivateAPI>* GetFactoryInstance(); static BrowserContextKeyedAPIFactory<GcdPrivateAPI>* GetFactoryInstance();
bool QueryForDevices();
private: private:
friend class BrowserContextKeyedAPIFactory<GcdPrivateAPI>; friend class BrowserContextKeyedAPIFactory<GcdPrivateAPI>;
...@@ -100,7 +98,7 @@ class GcdPrivateGetCloudDeviceListFunction ...@@ -100,7 +98,7 @@ class GcdPrivateGetCloudDeviceListFunction
}; };
class GcdPrivateQueryForNewLocalDevicesFunction class GcdPrivateQueryForNewLocalDevicesFunction
: public ChromeSyncExtensionFunction { : public ChromeAsyncExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.queryForNewLocalDevices", DECLARE_EXTENSION_FUNCTION("gcdPrivate.queryForNewLocalDevices",
GCDPRIVATE_QUERYFORNEWLOCALDEVICES) GCDPRIVATE_QUERYFORNEWLOCALDEVICES)
...@@ -110,8 +108,8 @@ class GcdPrivateQueryForNewLocalDevicesFunction ...@@ -110,8 +108,8 @@ class GcdPrivateQueryForNewLocalDevicesFunction
protected: protected:
virtual ~GcdPrivateQueryForNewLocalDevicesFunction(); virtual ~GcdPrivateQueryForNewLocalDevicesFunction();
// SyncExtensionFunction overrides. // AsyncExtensionFunction overrides.
virtual bool RunSync() OVERRIDE; virtual bool RunAsync() OVERRIDE;
}; };
class GcdPrivateStartSetupFunction : public ChromeAsyncExtensionFunction { class GcdPrivateStartSetupFunction : public ChromeAsyncExtensionFunction {
......
...@@ -130,22 +130,6 @@ const uint8 kGoodbyePacket[] = { ...@@ -130,22 +130,6 @@ const uint8 kGoodbyePacket[] = {
'o', 'c', 'a', 'l', 0x00, '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 #endif // ENABLE_MDNS
// Sentinel value to signify the request should fail. // Sentinel value to signify the request should fail.
...@@ -270,14 +254,6 @@ IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddRemove) { ...@@ -270,14 +254,6 @@ IN_PROC_BROWSER_TEST_F(GcdPrivateAPITest, AddRemove) {
EXPECT_TRUE(RunExtensionSubtest("gcd_private/api", "remove_device.html")); 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 #endif // ENABLE_MDNS
} // namespace } // namespace
...@@ -40,11 +40,6 @@ namespace gcdPrivate { ...@@ -40,11 +40,6 @@ namespace gcdPrivate {
interface Functions { interface Functions {
static void getCloudDeviceList(CloudDeviceListCallback callback); 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 // Starts device setup process. Returns id of setup process. Id should be
// used as |setupId| in all subsequent setup related calls, and for // used as |setupId| in all subsequent setup related calls, and for
// filtering setup events. // 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