Commit fede7212 authored by dgrogan@chromium.org's avatar dgrogan@chromium.org

Probably broke Win7 Tests (dbg)(6)....

Probably broke Win7 Tests (dbg)(6). http://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%286%29/builds/27654/steps/browser_tests/logs/SendQuery

[ RUN      ] GcdPrivateAPITest.SendQuery
[4036:2900:0709/150928:ERROR:singleton_hwnd.cc(43)] Cannot create windows on non-UI thread!
[956:2412:0709/150928:WARNING:extension_apitest.cc(282)] Workaround for 177163, prematurely returning
c:\b\build\slave\win_builder__dbg_\build\src\chrome\browser\extensions\api\gcd_private\gcd_private_apitest.cc(276): error: Actual function call count doesn't match EXPECT_CALL(*test_service_discovery_client_, OnSendTo(std::string(reinterpret_cast\u003Cconst char*>(kQueryPacket), sizeof(kQueryPacket))))...
         Expected: to be called twice
           Actual: never called - unsatisfied and active
[  FAILED  ] GcdPrivateAPITest.SendQuery, where TypeParam =  and GetParam() =  (5746 ms)


Revert 282099 "Add API stubs for GCD device commands."

> Add API stubs for GCD device commands.
> Changed registration API to work for one network at once.
> Fixed comments.
> Replaced argument GCDDevice with just string id.
> 
> BUG=383167
> R=alexsemenov@chromium.org, asargent@chromium.org, asvitkine@chromium.org, noamsml@chromium.org
> 
> Review URL: https://codereview.chromium.org/363883002

TBR=vitalybuka@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282175 0039d316-1c4b-4281-b951-d872f2087c98
parent a402eb74
...@@ -23,28 +23,21 @@ namespace gcd_private = api::gcd_private; ...@@ -23,28 +23,21 @@ namespace gcd_private = api::gcd_private;
namespace { namespace {
const int kNumRequestsNeeded = 2; scoped_ptr<Event> MakeCloudDeviceStateChangedEvent(
bool available,
const char kIDPrefixCloudPrinter[] = "cloudprint:";
const char kIDPrefixGcd[] = "gcd:";
const char kIDPrefixMdns[] = "mdns:";
scoped_ptr<Event> MakeDeviceStateChangedEvent(
const gcd_private::GCDDevice& device) { const gcd_private::GCDDevice& device) {
scoped_ptr<base::ListValue> params = scoped_ptr<base::ListValue> params =
gcd_private::OnDeviceStateChanged::Create(device); gcd_private::OnCloudDeviceStateChanged::Create(available, device);
scoped_ptr<Event> event( scoped_ptr<Event> event(new Event(
new Event(gcd_private::OnDeviceStateChanged::kEventName, params.Pass())); gcd_private::OnCloudDeviceStateChanged::kEventName, params.Pass()));
return event.Pass(); return event.Pass();
} }
scoped_ptr<Event> MakeDeviceRemovedEvent(const std::string& device) { const int kNumRequestsNeeded = 2;
scoped_ptr<base::ListValue> params =
gcd_private::OnDeviceRemoved::Create(device); const char kIDPrefixCloudPrinter[] = "cloudprint:";
scoped_ptr<Event> event( const char kIDPrefixGcd[] = "gcd:";
new Event(gcd_private::OnDeviceRemoved::kEventName, params.Pass())); const char kIDPrefixMdns[] = "mdns:";
return event.Pass();
}
GcdPrivateAPI::GCDApiFlowFactoryForTests* g_gcd_api_flow_factory = NULL; GcdPrivateAPI::GCDApiFlowFactoryForTests* g_gcd_api_flow_factory = NULL;
...@@ -76,10 +69,8 @@ GcdPrivateAPI::GcdPrivateAPI(content::BrowserContext* context) ...@@ -76,10 +69,8 @@ GcdPrivateAPI::GcdPrivateAPI(content::BrowserContext* context)
: num_device_listeners_(0), browser_context_(context) { : num_device_listeners_(0), browser_context_(context) {
DCHECK(browser_context_); DCHECK(browser_context_);
if (EventRouter::Get(context)) { if (EventRouter::Get(context)) {
EventRouter::Get(context) EventRouter::Get(context)->RegisterObserver(
->RegisterObserver(this, gcd_private::OnDeviceStateChanged::kEventName); this, gcd_private::OnCloudDeviceStateChanged::kEventName);
EventRouter::Get(context)
->RegisterObserver(this, gcd_private::OnDeviceRemoved::kEventName);
} }
} }
...@@ -96,36 +87,31 @@ GcdPrivateAPI::GetFactoryInstance() { ...@@ -96,36 +87,31 @@ GcdPrivateAPI::GetFactoryInstance() {
} }
void GcdPrivateAPI::OnListenerAdded(const EventListenerInfo& details) { void GcdPrivateAPI::OnListenerAdded(const EventListenerInfo& details) {
if (details.event_name == gcd_private::OnDeviceStateChanged::kEventName || num_device_listeners_++;
details.event_name == gcd_private::OnDeviceRemoved::kEventName) {
num_device_listeners_++; if (num_device_listeners_ == 1) {
service_discovery_client_ =
if (num_device_listeners_ == 1) { local_discovery::ServiceDiscoverySharedClient::GetInstance();
service_discovery_client_ = privet_device_lister_.reset(new local_discovery::PrivetDeviceListerImpl(
local_discovery::ServiceDiscoverySharedClient::GetInstance(); service_discovery_client_.get(), this));
privet_device_lister_.reset(new local_discovery::PrivetDeviceListerImpl( privet_device_lister_->Start();
service_discovery_client_.get(), this)); }
privet_device_lister_->Start();
}
for (GCDDeviceMap::iterator i = known_devices_.begin(); for (GCDDeviceMap::iterator i = known_devices_.begin();
i != known_devices_.end(); i != known_devices_.end();
i++) { i++) {
EventRouter::Get(browser_context_)->DispatchEventToExtension( EventRouter::Get(browser_context_)->DispatchEventToExtension(
details.extension_id, MakeDeviceStateChangedEvent(*i->second)); details.extension_id,
} MakeCloudDeviceStateChangedEvent(true, *i->second));
} }
} }
void GcdPrivateAPI::OnListenerRemoved(const EventListenerInfo& details) { void GcdPrivateAPI::OnListenerRemoved(const EventListenerInfo& details) {
if (details.event_name == gcd_private::OnDeviceStateChanged::kEventName || num_device_listeners_--;
details.event_name == gcd_private::OnDeviceRemoved::kEventName) {
num_device_listeners_--;
if (num_device_listeners_ == 0) { if (num_device_listeners_ == 0) {
privet_device_lister_.reset(); privet_device_lister_.reset();
service_discovery_client_ = NULL; service_discovery_client_ = NULL;
}
} }
} }
...@@ -135,17 +121,17 @@ void GcdPrivateAPI::DeviceChanged( ...@@ -135,17 +121,17 @@ void GcdPrivateAPI::DeviceChanged(
const local_discovery::DeviceDescription& description) { const local_discovery::DeviceDescription& description) {
linked_ptr<gcd_private::GCDDevice> device(new gcd_private::GCDDevice); linked_ptr<gcd_private::GCDDevice> device(new gcd_private::GCDDevice);
device->setup_type = gcd_private::SETUP_TYPE_MDNS; device->setup_type = gcd_private::SETUP_TYPE_MDNS;
device->device_id = kIDPrefixMdns + name; device->id_string = kIDPrefixMdns + name;
device->device_type = description.type; device->device_type = description.type;
device->device_name = description.name; device->device_name = description.name;
device->device_description = description.description; device->device_description = description.description;
if (!description.id.empty()) if (!description.id.empty())
device->cloud_id.reset(new std::string(description.id)); device->cloud_id.reset(new std::string(description.id));
known_devices_[device->device_id] = device; known_devices_[device->id_string] = device;
EventRouter::Get(browser_context_) EventRouter::Get(browser_context_)
->BroadcastEvent(MakeDeviceStateChangedEvent(*device)); ->BroadcastEvent(MakeCloudDeviceStateChangedEvent(true, *device));
} }
void GcdPrivateAPI::DeviceRemoved(const std::string& name) { void GcdPrivateAPI::DeviceRemoved(const std::string& name) {
...@@ -154,7 +140,7 @@ void GcdPrivateAPI::DeviceRemoved(const std::string& name) { ...@@ -154,7 +140,7 @@ void GcdPrivateAPI::DeviceRemoved(const std::string& name) {
known_devices_.erase(found); known_devices_.erase(found);
EventRouter::Get(browser_context_) EventRouter::Get(browser_context_)
->BroadcastEvent(MakeDeviceRemovedEvent(device->device_id)); ->BroadcastEvent(MakeCloudDeviceStateChangedEvent(false, *device));
} }
void GcdPrivateAPI::DeviceCacheFlushed() { void GcdPrivateAPI::DeviceCacheFlushed() {
...@@ -162,7 +148,7 @@ void GcdPrivateAPI::DeviceCacheFlushed() { ...@@ -162,7 +148,7 @@ void GcdPrivateAPI::DeviceCacheFlushed() {
i != known_devices_.end(); i != known_devices_.end();
i++) { i++) {
EventRouter::Get(browser_context_) EventRouter::Get(browser_context_)
->BroadcastEvent(MakeDeviceRemovedEvent(i->second->device_id)); ->BroadcastEvent(MakeCloudDeviceStateChangedEvent(false, *i->second));
} }
known_devices_.clear(); known_devices_.clear();
...@@ -239,9 +225,9 @@ void GcdPrivateGetCloudDeviceListFunction::CheckListingDone() { ...@@ -239,9 +225,9 @@ void GcdPrivateGetCloudDeviceListFunction::CheckListingDone() {
linked_ptr<gcd_private::GCDDevice> device(new gcd_private::GCDDevice); linked_ptr<gcd_private::GCDDevice> device(new gcd_private::GCDDevice);
device->setup_type = gcd_private::SETUP_TYPE_CLOUD; device->setup_type = gcd_private::SETUP_TYPE_CLOUD;
if (i->type == local_discovery::kGCDTypePrinter) { if (i->type == local_discovery::kGCDTypePrinter) {
device->device_id = kIDPrefixCloudPrinter + i->id; device->id_string = kIDPrefixCloudPrinter + i->id;
} else { } else {
device->device_id = kIDPrefixGcd + i->id; device->id_string = kIDPrefixGcd + i->id;
} }
device->cloud_id.reset(new std::string(i->id)); device->cloud_id.reset(new std::string(i->id));
...@@ -291,23 +277,23 @@ bool GcdPrivateStartSetupFunction::RunAsync() { ...@@ -291,23 +277,23 @@ bool GcdPrivateStartSetupFunction::RunAsync() {
return false; return false;
} }
GcdPrivateSetWiFiNetworkFunction::GcdPrivateSetWiFiNetworkFunction() { GcdPrivateSetWiFiNetworksFunction::GcdPrivateSetWiFiNetworksFunction() {
} }
GcdPrivateSetWiFiNetworkFunction::~GcdPrivateSetWiFiNetworkFunction() { GcdPrivateSetWiFiNetworksFunction::~GcdPrivateSetWiFiNetworksFunction() {
} }
bool GcdPrivateSetWiFiNetworkFunction::RunAsync() { bool GcdPrivateSetWiFiNetworksFunction::RunAsync() {
return false; return false;
} }
GcdPrivateSetWiFiPasswordFunction::GcdPrivateSetWiFiPasswordFunction() { GcdPrivateSetWiFiCredentialsFunction::GcdPrivateSetWiFiCredentialsFunction() {
} }
GcdPrivateSetWiFiPasswordFunction::~GcdPrivateSetWiFiPasswordFunction() { GcdPrivateSetWiFiCredentialsFunction::~GcdPrivateSetWiFiCredentialsFunction() {
} }
bool GcdPrivateSetWiFiPasswordFunction::RunAsync() { bool GcdPrivateSetWiFiCredentialsFunction::RunAsync() {
return false; return false;
} }
...@@ -331,56 +317,4 @@ bool GcdPrivateStopSetupFunction::RunAsync() { ...@@ -331,56 +317,4 @@ bool GcdPrivateStopSetupFunction::RunAsync() {
return false; return false;
} }
GcdPrivateGetCommandDefinitionsFunction::
GcdPrivateGetCommandDefinitionsFunction() {
}
GcdPrivateGetCommandDefinitionsFunction::
~GcdPrivateGetCommandDefinitionsFunction() {
}
bool GcdPrivateGetCommandDefinitionsFunction::RunAsync() {
return false;
}
GcdPrivateInsertCommandFunction::GcdPrivateInsertCommandFunction() {
}
GcdPrivateInsertCommandFunction::~GcdPrivateInsertCommandFunction() {
}
bool GcdPrivateInsertCommandFunction::RunAsync() {
return false;
}
GcdPrivateGetCommandFunction::GcdPrivateGetCommandFunction() {
}
GcdPrivateGetCommandFunction::~GcdPrivateGetCommandFunction() {
}
bool GcdPrivateGetCommandFunction::RunAsync() {
return false;
}
GcdPrivateCancelCommandFunction::GcdPrivateCancelCommandFunction() {
}
GcdPrivateCancelCommandFunction::~GcdPrivateCancelCommandFunction() {
}
bool GcdPrivateCancelCommandFunction::RunAsync() {
return false;
}
GcdPrivateGetCommandsListFunction::GcdPrivateGetCommandsListFunction() {
}
GcdPrivateGetCommandsListFunction::~GcdPrivateGetCommandsListFunction() {
}
bool GcdPrivateGetCommandsListFunction::RunAsync() {
return false;
}
} // namespace extensions } // namespace extensions
...@@ -130,15 +130,15 @@ class GcdPrivateStartSetupFunction : public ChromeAsyncExtensionFunction { ...@@ -130,15 +130,15 @@ class GcdPrivateStartSetupFunction : public ChromeAsyncExtensionFunction {
private: private:
}; };
class GcdPrivateSetWiFiNetworkFunction : public ChromeAsyncExtensionFunction { class GcdPrivateSetWiFiNetworksFunction : public ChromeAsyncExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.setWiFiNetwork", DECLARE_EXTENSION_FUNCTION("gcdPrivate.setWiFiNetworks",
GCDPRIVATE_SETWIFINETWORK) GCDPRIVATE_SETWIFINETWORKS)
GcdPrivateSetWiFiNetworkFunction(); GcdPrivateSetWiFiNetworksFunction();
protected: protected:
virtual ~GcdPrivateSetWiFiNetworkFunction(); virtual ~GcdPrivateSetWiFiNetworksFunction();
// AsyncExtensionFunction overrides. // AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE; virtual bool RunAsync() OVERRIDE;
...@@ -146,15 +146,16 @@ class GcdPrivateSetWiFiNetworkFunction : public ChromeAsyncExtensionFunction { ...@@ -146,15 +146,16 @@ class GcdPrivateSetWiFiNetworkFunction : public ChromeAsyncExtensionFunction {
private: private:
}; };
class GcdPrivateSetWiFiPasswordFunction : public ChromeAsyncExtensionFunction { class GcdPrivateSetWiFiCredentialsFunction
: public ChromeAsyncExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.setWiFiPassword", DECLARE_EXTENSION_FUNCTION("gcdPrivate.setWiFiCredentials",
GCDPRIVATE_SETWIFIPASSWORD) GCDPRIVATE_SETWIFICREDENTIALS)
GcdPrivateSetWiFiPasswordFunction(); GcdPrivateSetWiFiCredentialsFunction();
protected: protected:
virtual ~GcdPrivateSetWiFiPasswordFunction(); virtual ~GcdPrivateSetWiFiCredentialsFunction();
// AsyncExtensionFunction overrides. // AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE; virtual bool RunAsync() OVERRIDE;
...@@ -192,86 +193,6 @@ class GcdPrivateStopSetupFunction : public ChromeAsyncExtensionFunction { ...@@ -192,86 +193,6 @@ class GcdPrivateStopSetupFunction : public ChromeAsyncExtensionFunction {
private: private:
}; };
class GcdPrivateGetCommandDefinitionsFunction
: public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.getCommandDefinitions",
GCDPRIVATE_GETCOMMANDDEFINITIONS)
GcdPrivateGetCommandDefinitionsFunction();
protected:
virtual ~GcdPrivateGetCommandDefinitionsFunction();
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
private:
};
class GcdPrivateInsertCommandFunction : public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.insertCommand",
GCDPRIVATE_INSERTCOMMAND)
GcdPrivateInsertCommandFunction();
protected:
virtual ~GcdPrivateInsertCommandFunction();
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
private:
};
class GcdPrivateGetCommandFunction : public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.getCommand", GCDPRIVATE_GETCOMMAND)
GcdPrivateGetCommandFunction();
protected:
virtual ~GcdPrivateGetCommandFunction();
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
private:
};
class GcdPrivateCancelCommandFunction : public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.cancelCommand",
GCDPRIVATE_CANCELCOMMAND)
GcdPrivateCancelCommandFunction();
protected:
virtual ~GcdPrivateCancelCommandFunction();
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
private:
};
class GcdPrivateGetCommandsListFunction : public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("gcdPrivate.getCommandsList",
GCDPRIVATE_GETCOMMANDSLIST)
GcdPrivateGetCommandsListFunction();
protected:
virtual ~GcdPrivateGetCommandsListFunction();
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
private:
};
} // namespace extensions } // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_GCD_PRIVATE_GCD_PRIVATE_API_H_ #endif // CHROME_BROWSER_EXTENSIONS_API_GCD_PRIVATE_GCD_PRIVATE_API_H_
...@@ -10,12 +10,12 @@ namespace gcdPrivate { ...@@ -10,12 +10,12 @@ namespace gcdPrivate {
// Represents a GCD device discovered locally or registered to a given user. // Represents a GCD device discovered locally or registered to a given user.
dictionary GCDDevice { dictionary GCDDevice {
// Opaque device identifier to be passed to API.
DOMString deviceId;
// How this device was discovered. // How this device was discovered.
SetupType setupType; SetupType setupType;
// Opaque device identifier to be passed to API.
DOMString idString;
// Cloud identifier string. // Cloud identifier string.
DOMString? cloudId; DOMString? cloudId;
...@@ -29,47 +29,39 @@ namespace gcdPrivate { ...@@ -29,47 +29,39 @@ namespace gcdPrivate {
DOMString deviceDescription; DOMString deviceDescription;
}; };
callback CloudDeviceListCallback = void(GCDDevice[] devices); // Represents wifi network credentials.
dictionary WiFiCredentials {
// |commandDefinitions| : Is "commandDefs" value of device described at DOMString ssid;
// https://developers.google.com/cloud-devices/v1/reference/devices DOMString password;
// TODO(vitalybuka): consider to describe object in IDL. };
callback CommandDefinitionsCallback = void(object commandDefinitions);
// |command| : Described at
// https://developers.google.com/cloud-devices/v1/reference/commands
// TODO(vitalybuka): consider to describe object in IDL.
callback CommandCallback = void(object command);
// |commands| : Array of commands described at callback CloudDeviceListCallback = void(GCDDevice[] devices);
// https://developers.google.com/cloud-devices/v1/reference/commands
// TODO(vitalybuka): consider to describe object in IDL.
callback CommandListCallback = void(object[] commands);
interface Functions { interface Functions {
// Returns the list of cloud devices visible locally or available in the
// cloud for user account.
static void getCloudDeviceList(CloudDeviceListCallback callback); static void getCloudDeviceList(CloudDeviceListCallback callback);
// Queries network for local devices. Triggers an onDeviceStateChanged and // Call this function *only* after registering for onDeviceStateChanged
// onDeviceRemoved events. Call this function *only* after registering for // events, or it will do nothing. This will trigger an
// onDeviceStateChanged and onDeviceRemoved events, or it will do nothing. // onLocalDeviceStateChanged event per device.
static void queryForNewLocalDevices(); 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.
static long startSetup(DOMString deviceId); static long startSetup(GCDDevice device);
// Sets WiFi network as reply to |onGetWifiNetworks| event. // Sets WiFi network list as reply to |onGetWifiNetworks| event.
// |setupId| : The value returned by |startSetup|. // |setupId| : The value returned by |startSetup|.
// |network| : The wifi network for device setup. // |networks| : The list of network device should be registered on.
static void setWiFiNetwork(long setupId, DOMString network); static void setWiFiNetworks(long setupId, DOMString[] networks);
// Sets WiFi network password as reply to |onGetWifiPassword| event. // Sets WiFi network credentials as reply to |onGetWifiCredentials|
// event.
// |setupId| : The value returned by |startSetup|. // |setupId| : The value returned by |startSetup|.
// |password| : The password for network selected with |setWiFiNetwork|. // |credentials| : The list of ssid with passwoors. The list is not required
static void setWiFiPassword(long setupId, DOMString password); // to match |networks| provided with |setWiFiNetworks| or
// |onGetWifiCredentials|.
static void setWiFiCredentials(long setupId, WiFiCredentials[] credentials);
// Confirms that security code known to application match to the code known // Confirms that security code known to application match to the code known
// to device. // to device.
...@@ -81,70 +73,24 @@ namespace gcdPrivate { ...@@ -81,70 +73,24 @@ namespace gcdPrivate {
// starting new registration. // starting new registration.
// |setupId| : The value returned by |startSetup|. // |setupId| : The value returned by |startSetup|.
static void stopSetup(long setupId); static void stopSetup(long setupId);
// Returns command definitions.
// |deviceId| : The device to get command definitions for.
// |callback| : The result callback.
static void getCommandDefinitions(DOMString deviceId,
CommandDefinitionsCallback callback);
// Creates and sends a new command.
// |deviceId| : The device to send the command to.
// |expireInMs| : The number of milliseconds since now before the command
// expires. Expired command should not be executed by device. Acceptable
// values are 10000 to 2592000000, inclusive. All values outside that range
// will be replaced by 2592000000.
// |command| : Described at
// https://developers.google.com/cloud-devices/v1/reference/commands
// |callback| : The result callback.
static void insertCommand(DOMString deviceId,
long expireInMs,
object command,
CommandCallback callback);
// Returns a particular command.
// |commandId| : Unique command ID.
// |callback| : The result callback.
static void getCommand(DOMString commandId, CommandCallback callback);
// Cancels a command.
// |commandId| : Unique command ID.
// |callback| : The result callback.
static void cancelCommand(DOMString commandId, CommandCallback callback);
// Lists all commands in order of creation.
// |deviceId| : The device to get the commands for.
// |byUser| : List all the commands issued by the user. Special value 'me'
// can be used to list by the current user.
// |state| : Command state.
// |callback| : The result callback.
static void getCommandsList(DOMString deviceId,
DOMString byUser,
DOMString state,
CommandListCallback callback);
}; };
interface Events { interface Events {
// Subscribe to this event to start listening new or updated devices. New // Subscribe to this event to start listening to cloud devices. New
// listeners will get called with all known devices on the network, and // listeners will get called with all known devices on the network.
// status updates for devices available through the cloud. static void onCloudDeviceStateChanged(boolean available, GCDDevice device);
static void onDeviceStateChanged(GCDDevice device);
// Notifies that device has disappeared.
// |deviceId| : The device has disappeared.
static void onDeviceRemoved(DOMString deviceId);
// Notifies app that setup is waiting for a wifi network. App should reply // Notifies app that setup is waiting for network list. App should reply
// with |setWiFiNetwork|. // with |setWiFiNetworks|.
// |setupId| : The value returned by |startSetup|. // |setupId| : The value returned by |startSetup|.
static void onGetWifiNetwork(long setupId); static void onGetWifiNetworks(long setupId);
// Notifies app that setup is waiting for password for the network provided // Notifies app that setup is waiting for credentions for |networks| list.
// with |setWiFiNetwork|. Even will be called if setup flow would unable to // App should reply with |setWiFiCredentials|.
// get password from the system.
// App should reply with |setWiFiPassword|.
// |setupId| : The value returned by |startSetup|. // |setupId| : The value returned by |startSetup|.
static void onGetWifiPassword(long setupId); // |networks| : A subset of the list provided in |setWiFiNetworks| for which
// setup flow is unable to find credentials
static void onGetWifiCredentials(long setupId, DOMString[] networks);
// Notifies app that setup is waiting for confirmation that code is the same // Notifies app that setup is waiting for confirmation that code is the same
// as code known to device. App should reply with |confirmCode|, or // as code known to device. App should reply with |confirmCode|, or
...@@ -157,7 +103,7 @@ namespace gcdPrivate { ...@@ -157,7 +103,7 @@ namespace gcdPrivate {
// |setupId| : The value returned by |startSetup|. // |setupId| : The value returned by |startSetup|.
static void onSetupSuccess(long setupId); static void onSetupSuccess(long setupId);
// Notifies app that setup is failed or stopped. // Notifies app that setup is failed or stoped.
// |setupId| : The value returned by |startSetup|. // |setupId| : The value returned by |startSetup|.
static void onSetupError(long setupId); static void onSetupError(long setupId);
}; };
......
...@@ -8,13 +8,13 @@ onload = function() { ...@@ -8,13 +8,13 @@ onload = function() {
chrome.gcdPrivate.getCloudDeviceList(function(services) { chrome.gcdPrivate.getCloudDeviceList(function(services) {
// Sort to avoid order dependence // Sort to avoid order dependence
services.sort(function(a,b) { services.sort(function(a,b) {
return a.deviceId.localeCompare(b.deviceId); return a.idString.localeCompare(b.idString);
}); });
chrome.test.assertEq(2, services.length); chrome.test.assertEq(2, services.length);
chrome.test.assertEq(services[0].setupType, "cloud"); chrome.test.assertEq(services[0].setupType, "cloud");
chrome.test.assertEq(services[0].deviceId, chrome.test.assertEq(services[0].idString,
"cloudprint:someCloudPrintID"); "cloudprint:someCloudPrintID");
chrome.test.assertEq(services[0].cloudId, "someCloudPrintID"); chrome.test.assertEq(services[0].cloudId, "someCloudPrintID");
chrome.test.assertEq(services[0].deviceType, "printer"); chrome.test.assertEq(services[0].deviceType, "printer");
...@@ -24,7 +24,7 @@ onload = function() { ...@@ -24,7 +24,7 @@ onload = function() {
"someCloudPrintDescription"); "someCloudPrintDescription");
chrome.test.assertEq(services[1].setupType, "cloud"); chrome.test.assertEq(services[1].setupType, "cloud");
chrome.test.assertEq(services[1].deviceId, "gcd:someGCDID"); chrome.test.assertEq(services[1].idString, "gcd:someGCDID");
chrome.test.assertEq(services[1].cloudId, "someGCDID"); chrome.test.assertEq(services[1].cloudId, "someGCDID");
chrome.test.assertEq(services[1].deviceType, "someType"); chrome.test.assertEq(services[1].deviceType, "someType");
chrome.test.assertEq(services[1].deviceName, "someGCDDisplayName"); chrome.test.assertEq(services[1].deviceName, "someGCDDisplayName");
......
...@@ -4,19 +4,21 @@ ...@@ -4,19 +4,21 @@
onload = function() { onload = function() {
chrome.test.runTests([ chrome.test.runTests([
function receiveNewDevice() { function receiveNewDevice() {
chrome.gcdPrivate.onDeviceStateChanged.addListener( chrome.gcdPrivate.onCloudDeviceStateChanged.addListener(
function(device) { function(available, device) {
chrome.test.assertEq(device.setupType, "mdns"); chrome.test.assertTrue(available);
chrome.test.assertEq(device.deviceId,
"mdns:myService._privet._tcp.local");
chrome.test.assertEq(device.deviceType, "printer");
chrome.test.assertEq(device.deviceName,
"Sample device");
chrome.test.assertEq(device.deviceDescription,
"Sample device description");
chrome.test.notifyPass(); chrome.test.assertEq(device.setupType, "mdns");
}) chrome.test.assertEq(device.idString,
"mdns:myService._privet._tcp.local");
chrome.test.assertEq(device.deviceType, "printer");
chrome.test.assertEq(device.deviceName,
"Sample device");
chrome.test.assertEq(device.deviceDescription,
"Sample device description");
chrome.test.notifyPass();
})
}]); }]);
}; };
...@@ -4,12 +4,26 @@ ...@@ -4,12 +4,26 @@
onload = function() { onload = function() {
chrome.test.runTests([ chrome.test.runTests([
function addRemoveDevice() { function addRemoveDevice() {
chrome.gcdPrivate.onDeviceRemoved.addListener( var should_be_available = true;
function(deviceId) { chrome.gcdPrivate.onCloudDeviceStateChanged.addListener(
chrome.test.assertEq(deviceId, function(available, device) {
"mdns:myService._privet._tcp.local"); chrome.test.assertEq(available, should_be_available);
chrome.test.notifyPass(); should_be_available = false;
})
chrome.test.assertEq(device.setupType, "mdns");
chrome.test.assertEq(device.idString,
"mdns:myService._privet._tcp.local");
chrome.test.assertEq(device.deviceType, "printer");
chrome.test.assertEq(device.deviceName,
"Sample device");
chrome.test.assertEq(device.deviceDescription,
"Sample device description");
if (!available) {
// Only pass after device is removed
chrome.test.notifyPass();
}
})
}]); }]);
}; };
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
onload = function() { onload = function() {
chrome.test.runTests([ chrome.test.runTests([
function receiveNewDevice() { function receiveNewDevice() {
chrome.gcdPrivate.onDeviceStateChanged.addListener(function(device) {}); chrome.gcdPrivate.onCloudDeviceStateChanged.addListener(
chrome.gcdPrivate.queryForNewLocalDevices(); function(available, device) {});
chrome.test.notifyPass();
} chrome.gcdPrivate.queryForNewLocalDevices();
]); chrome.test.notifyPass();
}]);
}; };
...@@ -884,19 +884,14 @@ enum HistogramValue { ...@@ -884,19 +884,14 @@ enum HistogramValue {
GCDPRIVATE_GETCLOUDDEVICELIST, GCDPRIVATE_GETCLOUDDEVICELIST,
GCDPRIVATE_QUERYFORNEWLOCALDEVICES, GCDPRIVATE_QUERYFORNEWLOCALDEVICES,
GCDPRIVATE_STARTSETUP, GCDPRIVATE_STARTSETUP,
GCDPRIVATE_SETWIFINETWORK, GCDPRIVATE_SETWIFINETWORKS,
GCDPRIVATE_SETWIFIPASSWORD, GCDPRIVATE_SETWIFICREDENTIALS,
GCDPRIVATE_CONFIRMCODE, GCDPRIVATE_CONFIRMCODE,
GCDPRIVATE_STOPSETUP, GCDPRIVATE_STOPSETUP,
TABS_SETZOOM, TABS_SETZOOM,
TABS_GETZOOM, TABS_GETZOOM,
TABS_SETZOOMSETTINGS, TABS_SETZOOMSETTINGS,
TABS_GETZOOMSETTINGS, TABS_GETZOOMSETTINGS,
GCDPRIVATE_GETCOMMANDDEFINITIONS,
GCDPRIVATE_INSERTCOMMAND,
GCDPRIVATE_GETCOMMAND,
GCDPRIVATE_CANCELCOMMAND,
GCDPRIVATE_GETCOMMANDSLIST,
// Last entry: Add new entries above and ensure to update // Last entry: Add new entries above and ensure to update
// tools/metrics/histograms/histograms/histograms.xml. // tools/metrics/histograms/histograms/histograms.xml.
ENUM_BOUNDARY ENUM_BOUNDARY
......
...@@ -38425,11 +38425,6 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -38425,11 +38425,6 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="831" label="TABS_GETZOOM"/> <int value="831" label="TABS_GETZOOM"/>
<int value="832" label="TABS_SETZOOMSETTINGS"/> <int value="832" label="TABS_SETZOOMSETTINGS"/>
<int value="833" label="TABS_GETZOOMSETTINGS"/> <int value="833" label="TABS_GETZOOMSETTINGS"/>
<int value="834" label="GCDPRIVATE_GETCOMMANDDEFS"/>
<int value="835" label="GCDPRIVATE_INSERTCOMMAND"/>
<int value="836" label="GCDPRIVATE_GETCOMMAND"/>
<int value="837" label="GCDPRIVATE_CANCELCOMMAND"/>
<int value="838" label="GCDPRIVATE_GETCOMMANDSLIST"/>
</enum> </enum>
<enum name="ExtensionInstallCause" type="int"> <enum name="ExtensionInstallCause" type="int">
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