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

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

Issue 1141613003: Push API: Include origin in generated app_ids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ident_test
Patch Set: Simplify DCHECKs Created 5 years, 7 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 | chrome/browser/push_messaging/push_messaging_app_identifier.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/push_messaging/push_messaging_app_identifier.h
diff --git a/chrome/browser/push_messaging/push_messaging_app_identifier.h b/chrome/browser/push_messaging/push_messaging_app_identifier.h
index 6d64fc2be5f4066ed6b5a1ca7b493c9dc5a564db..32bfb22b601a3f1b0466fb9a81e6b8c43911e2b2 100644
--- a/chrome/browser/push_messaging/push_messaging_app_identifier.h
+++ b/chrome/browser/push_messaging/push_messaging_app_identifier.h
@@ -10,6 +10,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/gtest_prod_util.h"
#include "base/logging.h"
#include "url/gurl.h"
@@ -24,26 +25,30 @@ extern const char kPushMessagingAppIdentifierPrefix[];
// Type used to identify a Service Worker registration from a Push API
// perspective. These can be persisted to prefs, in a 1:1 mapping between
-// app_id and pair<origin, service_worker_registration_id>.
+// app_id (which includes origin) and service_worker_registration_id.
+// Legacy mapped values saved by old versions of Chrome are also supported;
+// these don't contain the origin in the app_id, so instead they map from
+// app_id to pair<origin, service_worker_registration_id>.
class PushMessagingAppIdentifier {
public:
// Register profile-specific prefs.
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
- // Generates a new app identifier with random app_id.
+ // Generates a new app identifier, with partially random app_id.
static PushMessagingAppIdentifier Generate(
const GURL& origin,
int64_t service_worker_registration_id);
// Looks up an app identifier by app_id. If not found, is_null() will be true.
- static PushMessagingAppIdentifier Get(Profile* profile,
- const std::string& app_id);
+ static PushMessagingAppIdentifier FindByAppId(Profile* profile,
+ const std::string& app_id);
// Looks up an app identifier by origin & service worker registration id.
// If not found, is_null() will be true.
- static PushMessagingAppIdentifier Get(Profile* profile,
- const GURL& origin,
- int64_t service_worker_registration_id);
+ static PushMessagingAppIdentifier FindByServiceWorker(
+ Profile* profile,
+ const GURL& origin,
+ int64_t service_worker_registration_id);
// Returns all the PushMessagingAppIdentifiers currently registered for the
// given |profile|.
@@ -58,12 +63,13 @@ class PushMessagingAppIdentifier {
void DeleteFromPrefs(Profile* profile) const;
// Returns true if this identifier does not represent an app (i.e. this was
- // returned by a failed call to Get).
+ // returned by a failed Find call).
bool is_null() const { return service_worker_registration_id_ < 0; }
// String that should be passed to push services like GCM to identify a
// particular Service Worker (so we can route incoming messages). Example:
- // wp:9CC55CCE-B8F9-4092-A364-3B0F73A3AB5F
+ // wp:https://foo.example.com:8443/#9CC55CCE-B8F9-4092-A364-3B0F73A3AB5F
+ // Legacy app_ids have no origin, e.g. wp:9CC55CCE-B8F9-4092-A364-3B0F73A3AB5F
const std::string& app_id() const {
DCHECK(!is_null());
return app_id_;
@@ -81,6 +87,7 @@ class PushMessagingAppIdentifier {
private:
friend class PushMessagingAppIdentifierTest;
+ FRIEND_TEST_ALL_PREFIXES(PushMessagingAppIdentifierTest, FindLegacy);
// Constructs an invalid app identifier.
PushMessagingAppIdentifier();
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_app_identifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698