Delay delay launch of local discovery notification service.

Review URL: https://chromiumcodereview.appspot.com/23863004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221971 0039d316-1c4b-4281-b951-d872f2087c98
parent 14fc22fc
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/rand_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/local_discovery/privet_device_lister_impl.h" #include "chrome/browser/local_discovery/privet_device_lister_impl.h"
#include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification.h"
...@@ -32,6 +33,7 @@ const int kTenMinutesInSeconds = 600; ...@@ -32,6 +33,7 @@ const int kTenMinutesInSeconds = 600;
const char kPrivetInfoKeyUptime[] = "uptime"; const char kPrivetInfoKeyUptime[] = "uptime";
const char kPrivetNotificationIDPrefix[] = "privet_notification:"; const char kPrivetNotificationIDPrefix[] = "privet_notification:";
const char kPrivetNotificationOriginUrl[] = "chrome://devices"; const char kPrivetNotificationOriginUrl[] = "chrome://devices";
const int kStartDelaySeconds = 30;
} }
PrivetNotificationsListener::PrivetNotificationsListener( PrivetNotificationsListener::PrivetNotificationsListener(
...@@ -150,9 +152,11 @@ PrivetNotificationService::PrivetNotificationService( ...@@ -150,9 +152,11 @@ PrivetNotificationService::PrivetNotificationService(
NotificationUIManager* notification_manager) NotificationUIManager* notification_manager)
: profile_(profile), : profile_(profile),
notification_manager_(notification_manager) { notification_manager_(notification_manager) {
base::MessageLoop::current()->PostTask( base::MessageLoop::current()->PostDelayedTask(
FROM_HERE, FROM_HERE,
base::Bind(&PrivetNotificationService::Start, AsWeakPtr())); base::Bind(&PrivetNotificationService::Start, AsWeakPtr()),
base::TimeDelta::FromSeconds(kStartDelaySeconds +
base::RandInt(0, kStartDelaySeconds/4)));
} }
PrivetNotificationService::~PrivetNotificationService() { PrivetNotificationService::~PrivetNotificationService() {
......
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