OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_REGISTRATION_ID_H_ | 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_REGISTRATION_ID_H_ |
6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_REGISTRATION_ID_H_ | 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_REGISTRATION_ID_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "url/origin.h" | 12 #include "url/origin.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 // The Background Fetch registration id corresponds to the information required | 16 // The Background Fetch registration id corresponds to the information required |
17 // to uniquely identify a Background Fetch registration in scope of a profile. | 17 // to uniquely identify a Background Fetch registration in scope of a profile. |
18 class CONTENT_EXPORT BackgroundFetchRegistrationId { | 18 class CONTENT_EXPORT BackgroundFetchRegistrationId { |
19 public: | 19 public: |
20 BackgroundFetchRegistrationId(); | 20 BackgroundFetchRegistrationId(); |
21 BackgroundFetchRegistrationId(int64_t service_worker_registration_id, | 21 BackgroundFetchRegistrationId(int64_t service_worker_registration_id, |
22 const url::Origin& origin, | 22 const url::Origin& origin, |
23 const std::string& tag); | 23 const std::string& tag); |
24 BackgroundFetchRegistrationId(const BackgroundFetchRegistrationId& other); | 24 BackgroundFetchRegistrationId(const BackgroundFetchRegistrationId& other); |
25 BackgroundFetchRegistrationId(BackgroundFetchRegistrationId&& other); | 25 BackgroundFetchRegistrationId(BackgroundFetchRegistrationId&& other); |
26 ~BackgroundFetchRegistrationId(); | 26 ~BackgroundFetchRegistrationId(); |
27 | 27 |
| 28 // Deserialize the string format of a registration_id. |
| 29 static bool Deserialize(const std::string& serialized_registration_id, |
| 30 BackgroundFetchRegistrationId* out_registration_id); |
| 31 |
| 32 // Serialize the registration_id into a string so that it can be sent to |
| 33 // embedders in a neutral format. |
| 34 std::string Serialize() const; |
| 35 |
28 BackgroundFetchRegistrationId& operator=( | 36 BackgroundFetchRegistrationId& operator=( |
29 const BackgroundFetchRegistrationId& other); | 37 const BackgroundFetchRegistrationId& other); |
30 | 38 |
31 // Returns whether the |other| registration id are identical or different. | 39 // Returns whether the |other| registration id are identical or different. |
32 bool operator==(const BackgroundFetchRegistrationId& other) const; | 40 bool operator==(const BackgroundFetchRegistrationId& other) const; |
33 bool operator!=(const BackgroundFetchRegistrationId& other) const; | 41 bool operator!=(const BackgroundFetchRegistrationId& other) const; |
34 | 42 |
35 // Enables this type to be used in an std::map and std::set. | 43 // Enables this type to be used in an std::map and std::set. |
36 // TODO(peter): Delete this when we switch away from using maps. | 44 // TODO(peter): Delete this when we switch away from using maps. |
37 bool operator<(const BackgroundFetchRegistrationId& other) const; | 45 bool operator<(const BackgroundFetchRegistrationId& other) const; |
38 | 46 |
39 // Returns whether this registration id refers to valid data. | 47 // Returns whether this registration id refers to valid data. |
40 bool is_null() const; | 48 bool is_null() const; |
41 | 49 |
42 int64_t service_worker_registration_id() const { | 50 int64_t service_worker_registration_id() const { |
43 return service_worker_registration_id_; | 51 return service_worker_registration_id_; |
44 } | 52 } |
45 const url::Origin& origin() const { return origin_; } | 53 const url::Origin& origin() const { return origin_; } |
46 const std::string& tag() const { return tag_; } | 54 const std::string& tag() const { return tag_; } |
47 | 55 |
48 private: | 56 private: |
49 int64_t service_worker_registration_id_; | 57 int64_t service_worker_registration_id_; |
50 url::Origin origin_; | 58 url::Origin origin_; |
51 std::string tag_; | 59 std::string tag_; |
52 }; | 60 }; |
53 | 61 |
54 } // namespace content | 62 } // namespace content |
55 | 63 |
56 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_REGISTRATION_ID_H_ | 64 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_REGISTRATION_ID_H_ |
OLD | NEW |