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

Unified Diff: chrome/browser/local_discovery/privet_notifications.cc

Issue 23863004: Delay delay launch of local discovery notification service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/local_discovery/privet_notifications.cc
diff --git a/chrome/browser/local_discovery/privet_notifications.cc b/chrome/browser/local_discovery/privet_notifications.cc
index 3faceaff25b9582c6aa6a29c21a5c17728a59473..b378a64097150e0c253268c11f8694430af14bc0 100644
--- a/chrome/browser/local_discovery/privet_notifications.cc
+++ b/chrome/browser/local_discovery/privet_notifications.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
+#include "base/rand_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/local_discovery/privet_device_lister_impl.h"
#include "chrome/browser/notifications/notification.h"
@@ -32,6 +33,7 @@ const int kTenMinutesInSeconds = 600;
const char kPrivetInfoKeyUptime[] = "uptime";
const char kPrivetNotificationIDPrefix[] = "privet_notification:";
const char kPrivetNotificationOriginUrl[] = "chrome://devices";
+const int kStartDelaySeconds = 30;
}
PrivetNotificationsListener::PrivetNotificationsListener(
@@ -150,9 +152,11 @@ PrivetNotificationService::PrivetNotificationService(
NotificationUIManager* notification_manager)
: profile_(profile),
notification_manager_(notification_manager) {
- base::MessageLoop::current()->PostTask(
+ base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
- base::Bind(&PrivetNotificationService::Start, AsWeakPtr()));
+ base::Bind(&PrivetNotificationService::Start, AsWeakPtr()),
+ base::TimeDelta::FromSeconds(kStartDelaySeconds +
+ base::RandInt(0, kStartDelaySeconds/4)));
}
PrivetNotificationService::~PrivetNotificationService() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698