Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / content / browser / background_sync / background_sync_registration.h
blobe9653293fa200a1732993fc821bf883e9e5ff5ba
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/background_sync/background_sync.pb.h"
10 #include "content/browser/background_sync/background_sync_registration_options.h"
11 #include "content/common/background_sync_service.mojom.h"
12 #include "content/common/content_export.h"
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/type_converter.h"
15 namespace content {
17 class CONTENT_EXPORT BackgroundSyncRegistration {
18 public:
19 using RegistrationId = int64_t;
20 static const RegistrationId kInitialId;
22 bool Equals(const BackgroundSyncRegistration& other) const;
23 bool IsValid() const;
25 const BackgroundSyncRegistrationOptions* options() const { return &options_; }
26 BackgroundSyncRegistrationOptions* options() { return &options_; }
28 RegistrationId id() const { return id_; }
29 void set_id(RegistrationId id) { id_ = id; }
31 SyncState sync_state() const { return sync_state_; }
32 void set_sync_state(SyncState state) { sync_state_ = state; }
34 private:
35 static const RegistrationId kInvalidRegistrationId;
37 BackgroundSyncRegistrationOptions options_;
38 RegistrationId id_ = kInvalidRegistrationId;
39 SyncState sync_state_ = SYNC_STATE_PENDING;
42 } // namespace content
44 namespace mojo {
46 template <>
47 struct CONTENT_EXPORT
48 TypeConverter<scoped_ptr<content::BackgroundSyncRegistration>,
49 content::SyncRegistrationPtr> {
50 static scoped_ptr<content::BackgroundSyncRegistration> Convert(
51 const content::SyncRegistrationPtr& input);
54 template <>
55 struct CONTENT_EXPORT TypeConverter<content::SyncRegistrationPtr,
56 content::BackgroundSyncRegistration> {
57 static content::SyncRegistrationPtr Convert(
58 const content::BackgroundSyncRegistration& input);
61 } // namespace
63 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_