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

Side by Side Diff: content/browser/background_sync/background_sync_registration.h

Issue 1763123002: [BackgroundSync] Remove BackgroundSyncRegistrationHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS7 Created 4 years, 9 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
OLDNEW
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 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.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" 18 #include "content/common/background_sync_service.mojom.h"
19 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
20 #include "mojo/public/cpp/bindings/type_converter.h" 20 #include "mojo/public/cpp/bindings/type_converter.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(); 30 BackgroundSyncRegistration() = default;
31 ~BackgroundSyncRegistration(); 31 BackgroundSyncRegistration(const BackgroundSyncRegistration& other) = default;
32 BackgroundSyncRegistration& operator=(
33 const BackgroundSyncRegistration& other) = default;
34 ~BackgroundSyncRegistration() = default;
32 35
33 bool Equals(const BackgroundSyncRegistration& other) const; 36 bool Equals(const BackgroundSyncRegistration& other) const;
34 bool IsValid() const; 37 bool IsValid() const;
35 bool IsFiring() const; 38 bool IsFiring() const;
36 39
37 const BackgroundSyncRegistrationOptions* options() const { return &options_; } 40 const BackgroundSyncRegistrationOptions* options() const { return &options_; }
38 BackgroundSyncRegistrationOptions* options() { return &options_; } 41 BackgroundSyncRegistrationOptions* options() { return &options_; }
39 42
40 RegistrationId id() const { return id_; } 43 RegistrationId id() const { return id_; }
41 void set_id(RegistrationId id) { id_ = id; } 44 void set_id(RegistrationId id) { id_ = id; }
42 45
43 BackgroundSyncState sync_state() const { return sync_state_; } 46 BackgroundSyncState sync_state() const { return sync_state_; }
44 void set_sync_state(BackgroundSyncState state) { sync_state_ = state; } 47 void set_sync_state(BackgroundSyncState state) { sync_state_ = state; }
45 48
46 int num_attempts() const { return num_attempts_; } 49 int num_attempts() const { return num_attempts_; }
47 void set_num_attempts(int num_attempts) { num_attempts_ = num_attempts; } 50 void set_num_attempts(int num_attempts) { num_attempts_ = num_attempts; }
48 51
49 base::Time delay_until() const { return delay_until_; } 52 base::Time delay_until() const { return delay_until_; }
50 void set_delay_until(base::Time delay_until) { delay_until_ = delay_until; } 53 void set_delay_until(base::Time delay_until) { delay_until_ = delay_until; }
51 54
52 private: 55 private:
53 static const RegistrationId kInvalidRegistrationId; 56 static const RegistrationId kInvalidRegistrationId;
54 57
55 BackgroundSyncRegistrationOptions options_; 58 BackgroundSyncRegistrationOptions options_;
56 RegistrationId id_ = kInvalidRegistrationId; 59 RegistrationId id_ = kInvalidRegistrationId;
57 BackgroundSyncState sync_state_ = BackgroundSyncState::PENDING; 60 BackgroundSyncState sync_state_ = BackgroundSyncState::PENDING;
58 int num_attempts_ = 0; 61 int num_attempts_ = 0;
59 base::Time delay_until_; 62 base::Time delay_until_;
60
61
62 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncRegistration);
63 }; 63 };
64 64
65 } // namespace content 65 } // namespace content
66 66
67 namespace mojo { 67 namespace mojo {
68 68
69 template <> 69 template <>
70 struct CONTENT_EXPORT 70 struct CONTENT_EXPORT
71 TypeConverter<scoped_ptr<content::BackgroundSyncRegistration>, 71 TypeConverter<scoped_ptr<content::BackgroundSyncRegistration>,
72 content::SyncRegistrationPtr> { 72 content::SyncRegistrationPtr> {
73 static scoped_ptr<content::BackgroundSyncRegistration> Convert( 73 static scoped_ptr<content::BackgroundSyncRegistration> Convert(
74 const content::SyncRegistrationPtr& input); 74 const content::SyncRegistrationPtr& input);
75 }; 75 };
76 76
77 template <> 77 template <>
78 struct CONTENT_EXPORT TypeConverter<content::SyncRegistrationPtr, 78 struct CONTENT_EXPORT TypeConverter<content::SyncRegistrationPtr,
79 content::BackgroundSyncRegistration> { 79 content::BackgroundSyncRegistration> {
80 static content::SyncRegistrationPtr Convert( 80 static content::SyncRegistrationPtr Convert(
81 const content::BackgroundSyncRegistration& input); 81 const content::BackgroundSyncRegistration& input);
82 }; 82 };
83 83
84 } // namespace 84 } // namespace
85 85
86 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_ 86 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698