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

Unified Diff: chrome/browser/push_messaging/background_budget_service.h

Issue 1861683002: Background service worker push message processing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Integrated code review comments Created 4 years, 8 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/push_messaging/background_budget_service.h
diff --git a/chrome/browser/push_messaging/background_budget_service.h b/chrome/browser/push_messaging/background_budget_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..5c5fbb14b54dbf7dd16a5bc1226833ca9e657cc5
--- /dev/null
+++ b/chrome/browser/push_messaging/background_budget_service.h
@@ -0,0 +1,49 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_
+#define CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_
+
+#include <string>
+
+#include "base/callback_forward.h"
+#include "url/gurl.h"
+
+class Profile;
+
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
+// A budget service to help chrome decide how much background work a service
+// worker should be able to do on behalf of the user. The budget currently
+// implements a grace period of 1 non-visual notification in 10.
+// TODO(harkness) do I need a CHROME_EXPORT?
Peter Beverloo 2016/04/08 14:29:38 Note: Personally I like using class headers as a T
harkness 2016/04/11 09:37:37 I'll consider doing that in my next patch, but it
+class BackgroundBudgetService {
+ public:
+ BackgroundBudgetService() {}
Peter Beverloo 2016/04/08 14:29:38 If you're going the all static route (we need to t
harkness 2016/04/11 09:37:37 For this patch, I'll go ahead and do that.
+ ~BackgroundBudgetService() override {}
Peter Beverloo 2016/04/08 14:29:38 Note: This (and line 28) will cause a compile fail
harkness 2016/04/11 09:37:37 Done.
+
+ void Shutdown() override {}
+
+ using BudgetCallback = base::Callback<void(const std::string& data)>;
+
+ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
+
+ // Get the budget associated with the origin. This currently tracks a string
+ // which holds 0 and 1 for the last 10 push messages and whether they
+ // triggered a visual notification.
+ static void GetBudget(Profile* profile,
+ const GURL& origin,
+ const BudgetCallback& callback);
+
+ // Store the budget associated with the origin. notifications_shown is
+ // expected to be a sting encoding whether the last 10 push messages triggered
+ // a visual notification.
+ static void StoreBudget(Profile* profile,
+ const GURL& origin,
+ const std::string& notifications_shown);
+};
+
+#endif // CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698