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

Unified Diff: trunk/src/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc

Issue 385483002: Probably broke Win7 Tests (dbg)(6). http://build.chromium.org/p/chromium.win/builders/Win7%20Tests%… (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 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: trunk/src/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc
===================================================================
--- trunk/src/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc (revision 282174)
+++ trunk/src/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc (working copy)
@@ -23,29 +23,22 @@
namespace {
-const int kNumRequestsNeeded = 2;
-
-const char kIDPrefixCloudPrinter[] = "cloudprint:";
-const char kIDPrefixGcd[] = "gcd:";
-const char kIDPrefixMdns[] = "mdns:";
-
-scoped_ptr<Event> MakeDeviceStateChangedEvent(
+scoped_ptr<Event> MakeCloudDeviceStateChangedEvent(
+ bool available,
const gcd_private::GCDDevice& device) {
scoped_ptr<base::ListValue> params =
- gcd_private::OnDeviceStateChanged::Create(device);
- scoped_ptr<Event> event(
- new Event(gcd_private::OnDeviceStateChanged::kEventName, params.Pass()));
+ gcd_private::OnCloudDeviceStateChanged::Create(available, device);
+ scoped_ptr<Event> event(new Event(
+ gcd_private::OnCloudDeviceStateChanged::kEventName, params.Pass()));
return event.Pass();
}
-scoped_ptr<Event> MakeDeviceRemovedEvent(const std::string& device) {
- scoped_ptr<base::ListValue> params =
- gcd_private::OnDeviceRemoved::Create(device);
- scoped_ptr<Event> event(
- new Event(gcd_private::OnDeviceRemoved::kEventName, params.Pass()));
- return event.Pass();
-}
+const int kNumRequestsNeeded = 2;
+const char kIDPrefixCloudPrinter[] = "cloudprint:";
+const char kIDPrefixGcd[] = "gcd:";
+const char kIDPrefixMdns[] = "mdns:";
+
GcdPrivateAPI::GCDApiFlowFactoryForTests* g_gcd_api_flow_factory = NULL;
base::LazyInstance<BrowserContextKeyedAPIFactory<GcdPrivateAPI> > g_factory =
@@ -76,10 +69,8 @@
: num_device_listeners_(0), browser_context_(context) {
DCHECK(browser_context_);
if (EventRouter::Get(context)) {
- EventRouter::Get(context)
- ->RegisterObserver(this, gcd_private::OnDeviceStateChanged::kEventName);
- EventRouter::Get(context)
- ->RegisterObserver(this, gcd_private::OnDeviceRemoved::kEventName);
+ EventRouter::Get(context)->RegisterObserver(
+ this, gcd_private::OnCloudDeviceStateChanged::kEventName);
}
}
@@ -96,36 +87,31 @@
}
void GcdPrivateAPI::OnListenerAdded(const EventListenerInfo& details) {
- if (details.event_name == gcd_private::OnDeviceStateChanged::kEventName ||
- details.event_name == gcd_private::OnDeviceRemoved::kEventName) {
- num_device_listeners_++;
+ num_device_listeners_++;
- if (num_device_listeners_ == 1) {
- service_discovery_client_ =
- local_discovery::ServiceDiscoverySharedClient::GetInstance();
- privet_device_lister_.reset(new local_discovery::PrivetDeviceListerImpl(
- service_discovery_client_.get(), this));
- privet_device_lister_->Start();
- }
+ if (num_device_listeners_ == 1) {
+ service_discovery_client_ =
+ local_discovery::ServiceDiscoverySharedClient::GetInstance();
+ privet_device_lister_.reset(new local_discovery::PrivetDeviceListerImpl(
+ service_discovery_client_.get(), this));
+ privet_device_lister_->Start();
+ }
- for (GCDDeviceMap::iterator i = known_devices_.begin();
- i != known_devices_.end();
- i++) {
- EventRouter::Get(browser_context_)->DispatchEventToExtension(
- details.extension_id, MakeDeviceStateChangedEvent(*i->second));
- }
+ for (GCDDeviceMap::iterator i = known_devices_.begin();
+ i != known_devices_.end();
+ i++) {
+ EventRouter::Get(browser_context_)->DispatchEventToExtension(
+ details.extension_id,
+ MakeCloudDeviceStateChangedEvent(true, *i->second));
}
}
void GcdPrivateAPI::OnListenerRemoved(const EventListenerInfo& details) {
- if (details.event_name == gcd_private::OnDeviceStateChanged::kEventName ||
- details.event_name == gcd_private::OnDeviceRemoved::kEventName) {
- num_device_listeners_--;
+ num_device_listeners_--;
- if (num_device_listeners_ == 0) {
- privet_device_lister_.reset();
- service_discovery_client_ = NULL;
- }
+ if (num_device_listeners_ == 0) {
+ privet_device_lister_.reset();
+ service_discovery_client_ = NULL;
}
}
@@ -135,17 +121,17 @@
const local_discovery::DeviceDescription& description) {
linked_ptr<gcd_private::GCDDevice> device(new gcd_private::GCDDevice);
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_name = description.name;
device->device_description = description.description;
if (!description.id.empty())
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_)
- ->BroadcastEvent(MakeDeviceStateChangedEvent(*device));
+ ->BroadcastEvent(MakeCloudDeviceStateChangedEvent(true, *device));
}
void GcdPrivateAPI::DeviceRemoved(const std::string& name) {
@@ -154,7 +140,7 @@
known_devices_.erase(found);
EventRouter::Get(browser_context_)
- ->BroadcastEvent(MakeDeviceRemovedEvent(device->device_id));
+ ->BroadcastEvent(MakeCloudDeviceStateChangedEvent(false, *device));
}
void GcdPrivateAPI::DeviceCacheFlushed() {
@@ -162,7 +148,7 @@
i != known_devices_.end();
i++) {
EventRouter::Get(browser_context_)
- ->BroadcastEvent(MakeDeviceRemovedEvent(i->second->device_id));
+ ->BroadcastEvent(MakeCloudDeviceStateChangedEvent(false, *i->second));
}
known_devices_.clear();
@@ -239,9 +225,9 @@
linked_ptr<gcd_private::GCDDevice> device(new gcd_private::GCDDevice);
device->setup_type = gcd_private::SETUP_TYPE_CLOUD;
if (i->type == local_discovery::kGCDTypePrinter) {
- device->device_id = kIDPrefixCloudPrinter + i->id;
+ device->id_string = kIDPrefixCloudPrinter + i->id;
} else {
- device->device_id = kIDPrefixGcd + i->id;
+ device->id_string = kIDPrefixGcd + i->id;
}
device->cloud_id.reset(new std::string(i->id));
@@ -291,23 +277,23 @@
return false;
}
-GcdPrivateSetWiFiNetworkFunction::GcdPrivateSetWiFiNetworkFunction() {
+GcdPrivateSetWiFiNetworksFunction::GcdPrivateSetWiFiNetworksFunction() {
}
-GcdPrivateSetWiFiNetworkFunction::~GcdPrivateSetWiFiNetworkFunction() {
+GcdPrivateSetWiFiNetworksFunction::~GcdPrivateSetWiFiNetworksFunction() {
}
-bool GcdPrivateSetWiFiNetworkFunction::RunAsync() {
+bool GcdPrivateSetWiFiNetworksFunction::RunAsync() {
return false;
}
-GcdPrivateSetWiFiPasswordFunction::GcdPrivateSetWiFiPasswordFunction() {
+GcdPrivateSetWiFiCredentialsFunction::GcdPrivateSetWiFiCredentialsFunction() {
}
-GcdPrivateSetWiFiPasswordFunction::~GcdPrivateSetWiFiPasswordFunction() {
+GcdPrivateSetWiFiCredentialsFunction::~GcdPrivateSetWiFiCredentialsFunction() {
}
-bool GcdPrivateSetWiFiPasswordFunction::RunAsync() {
+bool GcdPrivateSetWiFiCredentialsFunction::RunAsync() {
return false;
}
@@ -331,56 +317,4 @@
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

Powered by Google App Engine
This is Rietveld 408576698