Chromium Code Reviews| Index: content/public/browser/push_messaging_application_id.h |
| diff --git a/content/public/browser/push_messaging_application_id.h b/content/public/browser/push_messaging_application_id.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..84134655e944aa0bba99d1236c4c11a1313d6b08 |
| --- /dev/null |
| +++ b/content/public/browser/push_messaging_application_id.h |
| @@ -0,0 +1,44 @@ |
| +// Copyright 2014 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 CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_APPLICATION_ID_H_ |
| +#define CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_APPLICATION_ID_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "content/common/content_export.h" |
| +#include "url/gurl.h" |
| + |
| +namespace content { |
| + |
| +// The prefix used for all push messaging application ids. |
| +CONTENT_EXPORT extern const char kPushMessagingApplicationIdPrefix[]; |
| + |
| +// Type used to identify an "application" from a Push API perspective. |
|
johnme
2014/07/23 12:36:57
Nit: s/an "application"/a web app/ ?
Michael van Ouwerkerk
2014/07/23 15:05:14
Done.
|
| +struct CONTENT_EXPORT PushMessagingApplicationId { |
| + public: |
| + static PushMessagingApplicationId Parse(const std::string& id); |
| + |
| + PushMessagingApplicationId() |
| + : origin(GURL::EmptyGURL()), service_worker_registration_id(-1) {} |
| + PushMessagingApplicationId(const GURL& origin, |
| + int64 service_worker_registration_id) |
| + : origin(origin), |
| + service_worker_registration_id(service_worker_registration_id) {} |
| + |
| + bool is_valid() { |
|
johnme
2014/07/23 12:36:57
Nit: this isn't a simple getter, so IIRC the defin
Michael van Ouwerkerk
2014/07/23 15:05:14
Done.
|
| + return origin.is_valid() && origin.GetOrigin() == origin && |
| + service_worker_registration_id >= 0; |
| + } |
| + |
| + std::string ToString(); |
| + |
| + GURL origin; |
|
johnme
2014/07/23 12:36:57
Perhaps these should be immutable? You might even
Michael van Ouwerkerk
2014/07/23 15:05:14
Ok they're const now.
|
| + int64 service_worker_registration_id; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_APPLICATION_ID_H_ |