OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_SYNC_BACKGROUND_SYNC_REGISTRATION_H_ | 5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_ |
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_ | 6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_ |
7 | 7 |
| 8 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "content/browser/background_sync/background_sync.pb.h" | 10 #include "content/browser/background_sync/background_sync.pb.h" |
10 #include "content/browser/background_sync/background_sync_registration_options.h
" | 11 #include "content/browser/background_sync/background_sync_registration_options.h
" |
11 #include "content/common/background_sync_service.mojom.h" | 12 #include "content/common/background_sync_service.mojom.h" |
12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/type_converter.h" | 14 #include "third_party/mojo/src/mojo/public/cpp/bindings/type_converter.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 class CONTENT_EXPORT BackgroundSyncRegistration { | 18 class CONTENT_EXPORT BackgroundSyncRegistration { |
18 public: | 19 public: |
19 using RegistrationId = int64_t; | 20 using RegistrationId = int64_t; |
20 static const RegistrationId kInitialId; | 21 static const RegistrationId kInitialId; |
21 | 22 |
| 23 BackgroundSyncRegistration() = default; |
| 24 ~BackgroundSyncRegistration() = default; |
| 25 |
22 bool Equals(const BackgroundSyncRegistration& other) const; | 26 bool Equals(const BackgroundSyncRegistration& other) const; |
23 bool IsValid() const; | 27 bool IsValid() const; |
24 | 28 |
25 const BackgroundSyncRegistrationOptions* options() const { return &options_; } | 29 const BackgroundSyncRegistrationOptions* options() const { return &options_; } |
26 BackgroundSyncRegistrationOptions* options() { return &options_; } | 30 BackgroundSyncRegistrationOptions* options() { return &options_; } |
27 | 31 |
28 RegistrationId id() const { return id_; } | 32 RegistrationId id() const { return id_; } |
29 void set_id(RegistrationId id) { id_ = id; } | 33 void set_id(RegistrationId id) { id_ = id; } |
30 | 34 |
31 SyncState sync_state() const { return sync_state_; } | 35 SyncState sync_state() const { return sync_state_; } |
32 void set_sync_state(SyncState state) { sync_state_ = state; } | 36 void set_sync_state(SyncState state) { sync_state_ = state; } |
33 | 37 |
34 private: | 38 private: |
35 static const RegistrationId kInvalidRegistrationId; | 39 static const RegistrationId kInvalidRegistrationId; |
36 | 40 |
37 BackgroundSyncRegistrationOptions options_; | 41 BackgroundSyncRegistrationOptions options_; |
38 RegistrationId id_ = kInvalidRegistrationId; | 42 RegistrationId id_ = kInvalidRegistrationId; |
39 SyncState sync_state_ = SYNC_STATE_PENDING; | 43 SyncState sync_state_ = SYNC_STATE_PENDING; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncRegistration); |
40 }; | 46 }; |
41 | 47 |
42 } // namespace content | 48 } // namespace content |
43 | 49 |
44 namespace mojo { | 50 namespace mojo { |
45 | 51 |
46 template <> | 52 template <> |
47 struct CONTENT_EXPORT | 53 struct CONTENT_EXPORT |
48 TypeConverter<scoped_ptr<content::BackgroundSyncRegistration>, | 54 TypeConverter<scoped_ptr<content::BackgroundSyncRegistration>, |
49 content::SyncRegistrationPtr> { | 55 content::SyncRegistrationPtr> { |
50 static scoped_ptr<content::BackgroundSyncRegistration> Convert( | 56 static scoped_ptr<content::BackgroundSyncRegistration> Convert( |
51 const content::SyncRegistrationPtr& input); | 57 const content::SyncRegistrationPtr& input); |
52 }; | 58 }; |
53 | 59 |
54 template <> | 60 template <> |
55 struct CONTENT_EXPORT TypeConverter<content::SyncRegistrationPtr, | 61 struct CONTENT_EXPORT TypeConverter<content::SyncRegistrationPtr, |
56 content::BackgroundSyncRegistration> { | 62 content::BackgroundSyncRegistration> { |
57 static content::SyncRegistrationPtr Convert( | 63 static content::SyncRegistrationPtr Convert( |
58 const content::BackgroundSyncRegistration& input); | 64 const content::BackgroundSyncRegistration& input); |
59 }; | 65 }; |
60 | 66 |
61 } // namespace | 67 } // namespace |
62 | 68 |
63 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_ | 69 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_ |
OLD | NEW |