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

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: Switched the key to origin and added tests. 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..eb04bd088098a7c5ffca0a2838407cdc31116857
--- /dev/null
+++ b/chrome/browser/push_messaging/background_budget_service.h
@@ -0,0 +1,51 @@
+// 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 "components/keyed_service/core/keyed_service.h"
+#include "url/gurl.h"
+
+class Profile;
+
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
+namespace chrome {
+
+// 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 will be derived
+// from the Site engagement score for each domain, but in the initial
+// implementation it is just using the old grace period logic.
Peter Beverloo 2016/04/08 10:41:11 Comment nits: - s/chrome/Chrome/. - "... will
harkness 2016/04/08 14:11:43 Done.
+// TODO(harkness) do I need a CHROME_EXPORT?
Peter Beverloo 2016/04/08 10:41:11 No. The *_EXPORT macros are used when building Ch
harkness 2016/04/08 14:11:43 Acknowledged.
Peter Beverloo 2016/04/08 14:29:38 So remove the TODO? :)
+class BackgroundBudgetService : public KeyedService {
+ public:
+ BackgroundBudgetService() {}
+ ~BackgroundBudgetService() override {}
+
+ void Shutdown() override {}
+
+ using BudgetCallback = base::Callback<void(bool success)>;
Peter Beverloo 2016/04/08 10:41:11 Where would we use the success/failure callback of
harkness 2016/04/08 14:11:43 Currently, this isn't used at all. I had it in thi
+
+ using StringCallback = base::Callback<void(const std::string& data)>;
Peter Beverloo 2016/04/08 10:41:11 nit: I'd call this BudgetCallback.
harkness 2016/04/08 14:11:43 I'd actually already changed that in my next patch
+
+ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
+ static void GetBudget(Profile* profile,
Peter Beverloo 2016/04/08 10:41:11 Get/StoreBudget need to be documented. Today they
harkness 2016/04/08 14:11:43 Done.
+ const GURL& origin,
+ const StringCallback& callback);
+
+ static void StoreBudget(Profile* profile,
+ const GURL& origin,
+ const std::string& notifications_shown,
+ const BudgetCallback& callback);
+};
+
+} // namespace chrome
+
+#endif // CHROME_BROWSER_PUSH_MESSAGING_BACKGROUND_BUDGET_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698