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

Unified Diff: chrome/browser/extensions/api/mdns/mdns_api.cc

Issue 1040773002: Limit number of service instances passed to onServiceList listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Service instance limit and unit test against HEAD of master Created 5 years, 9 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: chrome/browser/extensions/api/mdns/mdns_api.cc
diff --git a/chrome/browser/extensions/api/mdns/mdns_api.cc b/chrome/browser/extensions/api/mdns/mdns_api.cc
index 2a7c41d210931d1540e61b8cb89fe402a203e1e8..b69899823eac3f243511c25e24b4b5fb756eacbc 100644
--- a/chrome/browser/extensions/api/mdns/mdns_api.cc
+++ b/chrome/browser/extensions/api/mdns/mdns_api.cc
@@ -22,6 +22,10 @@ const char kCastServiceType[] = "_googlecast._tcp.local";
const char kPrivetServiceType[] = "_privet._tcp.local";
const char kTestServiceType[] = "_testing._tcp.local";
+// Maximum number of services that may be included in an onServiceList event
+// as arguments.
+const uint8 kMaxServicesPerOnServiceListEvent = 64;
not at google - send to devlin 2015/03/30 17:08:50 You can, and should, declare this constant in the
Red Daly 2015/03/31 19:23:50 I didn't find great support for constants in the I
+
bool IsServiceTypeWhitelisted(const std::string& service_type) {
return service_type == kCastServiceType ||
service_type == kPrivetServiceType ||
@@ -139,7 +143,8 @@ void MDnsAPI::OnDnsSdEvent(const std::string& service_type,
std::vector<linked_ptr<mdns::MDnsService> > args;
for (DnsSdRegistry::DnsSdServiceList::const_iterator it = services.begin();
- it != services.end(); ++it) {
+ it != services.end() && args.size() < kMaxServicesPerOnServiceListEvent;
not at google - send to devlin 2015/03/30 17:08:50 It would be nice to warn the developer somehow if
mark a. foltz 2015/03/30 17:57:22 That would depend on the number of devices adverti
Red Daly 2015/03/31 19:23:50 I added a VLOG(1) message, which will help a devel
not at google - send to devlin 2015/04/01 20:25:58 JS console output is worth doing insofar as VLOG o
Red Daly 2015/04/02 22:25:21 I modified this to do JS console output but didn't
+ ++it) {
linked_ptr<mdns::MDnsService> mdns_service =
make_linked_ptr(new mdns::MDnsService);
mdns_service->service_name = (*it).service_name;

Powered by Google App Engine
This is Rietveld 408576698