ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / services / gcm / push_messaging_application_id.h
blobddb24d64dbbea8a648c49fdaeba152785e0f3bf7
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.
5 #ifndef CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_
6 #define CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "url/gurl.h"
14 class Profile;
16 namespace user_prefs {
17 class PrefRegistrySyncable;
20 namespace gcm {
22 // The prefix used for all push messaging application ids.
23 extern const char kPushMessagingApplicationIdPrefix[];
25 // Type used to identify a web app from a Push API perspective.
26 // These can be persisted to disk, in a 1:1 mapping between app_id_guid and
27 // pair<origin, service_worker_registration_id>.
28 class PushMessagingApplicationId {
29 public:
30 // Register profile-specific prefs.
31 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
33 // Generates a new application id with random app_id_guid.
34 static PushMessagingApplicationId Generate(
35 const GURL& origin,
36 int64 service_worker_registration_id);
38 // Looks up an application id by app_id_guid. Will be invalid if not found.
39 static PushMessagingApplicationId Get(Profile* profile,
40 const std::string& app_id_guid);
42 // Looks up an application id by origin & service worker registration id.
43 // Will be invalid if not found.
44 static PushMessagingApplicationId Get(Profile* profile,
45 const GURL& origin,
46 int64 service_worker_registration_id);
48 // Returns all the PushMessagingApplicationId currently registered for the
49 // given |profile|.
50 static std::vector<PushMessagingApplicationId> GetAll(Profile* profile);
52 ~PushMessagingApplicationId();
54 // Persist this application id to disk.
55 void PersistToDisk(Profile* profile) const;
57 // Delete this application id from disk.
58 void DeleteFromDisk(Profile* profile) const; // TODO: Does const make sense?
60 bool IsValid() const;
62 const std::string& app_id_guid() const { return app_id_guid_; }
63 const GURL& origin() const { return origin_; }
64 int64 service_worker_registration_id() const {
65 return service_worker_registration_id_;
68 private:
69 friend class PushMessagingApplicationIdTest;
71 // Constructs an invalid app id.
72 PushMessagingApplicationId();
73 // Constructs a valid app id.
74 PushMessagingApplicationId(const std::string& app_id_guid,
75 const GURL& origin,
76 int64 service_worker_registration_id);
78 std::string app_id_guid_;
79 GURL origin_;
80 int64 service_worker_registration_id_;
83 } // namespace gcm
85 #endif // CHROME_BROWSER_SERVICES_GCM_PUSH_MESSAGING_APPLICATION_ID_H_