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

Side by Side Diff: content/public/browser/push_messaging_application_id.h

Issue 404353003: Define PushMessagingApplicationId and replace ad-hoc code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_APPLICATION_ID_H_
6 #define CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_APPLICATION_ID_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "content/common/content_export.h"
12 #include "url/gurl.h"
13
14 namespace content {
15
16 // The prefix used for all push messaging application ids.
17 CONTENT_EXPORT extern const char kPushMessagingApplicationIdPrefix[];
18
19 // 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.
20 struct CONTENT_EXPORT PushMessagingApplicationId {
21 public:
22 static PushMessagingApplicationId Parse(const std::string& id);
23
24 PushMessagingApplicationId()
25 : origin(GURL::EmptyGURL()), service_worker_registration_id(-1) {}
26 PushMessagingApplicationId(const GURL& origin,
27 int64 service_worker_registration_id)
28 : origin(origin),
29 service_worker_registration_id(service_worker_registration_id) {}
30
31 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.
32 return origin.is_valid() && origin.GetOrigin() == origin &&
33 service_worker_registration_id >= 0;
34 }
35
36 std::string ToString();
37
38 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.
39 int64 service_worker_registration_id;
40 };
41
42 } // namespace content
43
44 #endif // CONTENT_PUBLIC_BROWSER_PUSH_MESSAGING_APPLICATION_ID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698