Chromium Code Reviews| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "content/browser/background_sync/background_sync.pb.h" | 16 #include "content/browser/background_sync/background_sync.pb.h" |
| 17 #include "content/browser/background_sync/background_sync_registration_options.h " | 17 #include "content/browser/background_sync/background_sync_registration_options.h " |
| 18 #include "content/common/background_sync_service.mojom.h" | |
| 19 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 20 #include "mojo/public/cpp/bindings/type_converter.h" | 19 #include "mojo/public/cpp/bindings/type_converter.h" |
| 20 #include "third_party/WebKit/public/platform/modules/background_sync/background_ sync.mojom.h" | |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 class CONTENT_EXPORT BackgroundSyncRegistration { | 24 class CONTENT_EXPORT BackgroundSyncRegistration { |
| 25 public: | 25 public: |
| 26 using RegistrationId = int64_t; | 26 using RegistrationId = int64_t; |
| 27 | 27 |
| 28 static const RegistrationId kInitialId; | 28 static const RegistrationId kInitialId; |
| 29 | 29 |
| 30 BackgroundSyncRegistration() = default; | 30 BackgroundSyncRegistration() = default; |
| 31 BackgroundSyncRegistration(const BackgroundSyncRegistration& other) = default; | 31 BackgroundSyncRegistration(const BackgroundSyncRegistration& other) = default; |
| 32 BackgroundSyncRegistration& operator=( | 32 BackgroundSyncRegistration& operator=( |
| 33 const BackgroundSyncRegistration& other) = default; | 33 const BackgroundSyncRegistration& other) = default; |
| 34 ~BackgroundSyncRegistration() = default; | 34 ~BackgroundSyncRegistration() = default; |
| 35 | 35 |
| 36 bool Equals(const BackgroundSyncRegistration& other) const; | 36 bool Equals(const BackgroundSyncRegistration& other) const; |
| 37 bool IsValid() const; | 37 bool IsValid() const; |
| 38 bool IsFiring() const; | 38 bool IsFiring() const; |
| 39 | 39 |
| 40 const BackgroundSyncRegistrationOptions* options() const { return &options_; } | 40 const BackgroundSyncRegistrationOptions* options() const { return &options_; } |
| 41 BackgroundSyncRegistrationOptions* options() { return &options_; } | 41 BackgroundSyncRegistrationOptions* options() { return &options_; } |
| 42 | 42 |
| 43 RegistrationId id() const { return id_; } | 43 RegistrationId id() const { return id_; } |
| 44 void set_id(RegistrationId id) { id_ = id; } | 44 void set_id(RegistrationId id) { id_ = id; } |
| 45 | 45 |
| 46 mojom::BackgroundSyncState sync_state() const { return sync_state_; } | 46 blink::mojom::BackgroundSyncState sync_state() const { return sync_state_; } |
| 47 void set_sync_state(mojom::BackgroundSyncState state) { sync_state_ = state; } | 47 void set_sync_state(blink::mojom::BackgroundSyncState state) { |
| 48 sync_state_ = state; | |
| 49 } | |
| 48 | 50 |
| 49 int num_attempts() const { return num_attempts_; } | 51 int num_attempts() const { return num_attempts_; } |
| 50 void set_num_attempts(int num_attempts) { num_attempts_ = num_attempts; } | 52 void set_num_attempts(int num_attempts) { num_attempts_ = num_attempts; } |
| 51 | 53 |
| 52 base::Time delay_until() const { return delay_until_; } | 54 base::Time delay_until() const { return delay_until_; } |
| 53 void set_delay_until(base::Time delay_until) { delay_until_ = delay_until; } | 55 void set_delay_until(base::Time delay_until) { delay_until_ = delay_until; } |
| 54 | 56 |
| 55 private: | 57 private: |
| 56 static const RegistrationId kInvalidRegistrationId; | 58 static const RegistrationId kInvalidRegistrationId; |
| 57 | 59 |
| 58 BackgroundSyncRegistrationOptions options_; | 60 BackgroundSyncRegistrationOptions options_; |
| 59 RegistrationId id_ = kInvalidRegistrationId; | 61 RegistrationId id_ = kInvalidRegistrationId; |
| 60 mojom::BackgroundSyncState sync_state_ = mojom::BackgroundSyncState::PENDING; | 62 blink::mojom::BackgroundSyncState sync_state_ = |
| 63 blink::mojom::BackgroundSyncState::PENDING; | |
| 61 int num_attempts_ = 0; | 64 int num_attempts_ = 0; |
| 62 base::Time delay_until_; | 65 base::Time delay_until_; |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 } // namespace content | 68 } // namespace content |
| 66 | 69 |
| 67 namespace mojo { | 70 namespace mojo { |
| 68 | 71 |
| 69 template <> | 72 template <> |
| 70 struct CONTENT_EXPORT | 73 struct CONTENT_EXPORT |
| 71 TypeConverter<std::unique_ptr<content::BackgroundSyncRegistration>, | 74 TypeConverter<std::unique_ptr<content::BackgroundSyncRegistration>, |
| 72 content::mojom::SyncRegistrationPtr> { | 75 blink::mojom::SyncRegistrationPtr> { |
| 73 static std::unique_ptr<content::BackgroundSyncRegistration> Convert( | 76 static std::unique_ptr<content::BackgroundSyncRegistration> Convert( |
| 74 const content::mojom::SyncRegistrationPtr& input); | 77 const blink::mojom::SyncRegistrationPtr& input); |
| 75 }; | 78 }; |
| 76 | 79 |
| 77 template <> | 80 template <> |
| 78 struct CONTENT_EXPORT TypeConverter<content::mojom::SyncRegistrationPtr, | 81 struct CONTENT_EXPORT TypeConverter<blink::mojom::SyncRegistrationPtr, |
| 79 content::BackgroundSyncRegistration> { | 82 content::BackgroundSyncRegistration> { |
| 80 static content::mojom::SyncRegistrationPtr Convert( | 83 static blink::mojom::SyncRegistrationPtr Convert( |
| 81 const content::BackgroundSyncRegistration& input); | 84 const content::BackgroundSyncRegistration& input); |
| 82 }; | 85 }; |
|
dcheng
2016/05/10 05:06:03
Can we try to clean up these type converters in a
juncai
2016/05/10 20:40:13
It seems that the implementation of these were del
| |
| 83 | 86 |
| 84 } // namespace | 87 } // namespace |
| 85 | 88 |
| 86 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_ | 89 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_ |
| OLD | NEW |