Chromium Code Reviews| Index: content/browser/background_sync/background_sync_registration_handle.h |
| diff --git a/content/browser/background_sync/background_sync_registration_handle.h b/content/browser/background_sync/background_sync_registration_handle.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..70a6cb10ad0692c1420523063d0ae7d23a42edd4 |
| --- /dev/null |
| +++ b/content/browser/background_sync/background_sync_registration_handle.h |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_HANDLE_H_ |
| +#define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_HANDLE_H_ |
| + |
| +#include "base/callback.h" |
| +#include "content/browser/background_sync/background_sync_registration.h" |
| +#include "content/browser/background_sync/background_sync_status.h" |
| +#include "content/common/content_export.h" |
| + |
| +namespace content { |
| + |
| +class BackgroundSyncManager; |
| + |
| +// Handle to BackgroundSyncRegistration that is exposed to clients. Each |
| +// BackgroundSyncRegistrationHandle is given a unique handle id (by the |
| +// BackgroundSyncManager) which is released at destruction. |
| +// BackgroundSyncRegistrationHandle objects must be deleted before the |
| +// BackgroundSyncManager is deleted. |
| +class CONTENT_EXPORT BackgroundSyncRegistrationHandle { |
| + public: |
| + using HandleId = int32_t; |
|
michaeln
2015/08/21 02:39:24
is 'int' good enough for this
jkarlin
2015/08/25 17:32:58
Done.
|
| + using StatusCallback = base::Callback<void(BackgroundSyncStatus)>; |
| + |
| + BackgroundSyncRegistrationHandle( |
| + BackgroundSyncManager* background_sync_manager, |
| + HandleId handle_id); |
| + virtual ~BackgroundSyncRegistrationHandle(); |
|
michaeln
2015/08/21 02:39:24
does this need to be virtual?
jkarlin
2015/08/25 17:32:58
Done.
|
| + |
| + const BackgroundSyncRegistrationOptions* options() const { |
| + return registration_->options(); |
| + } |
| + |
| + const BackgroundSyncRegistration* RegistrationForTests() const { |
|
michaeln
2015/08/21 02:39:24
maybe put this at the end of the public section in
jkarlin
2015/08/25 17:32:58
Removed.
|
| + return registration_; |
| + } |
| + |
| + // Unregisters the background sync registration. Calls |callback| |
| + // with BACKGROUND_SYNC_STATUS_OK if it succeeds. |
| + void Unregister(int64 service_worker_id, const StatusCallback& callback); |
|
michaeln
2015/08/21 02:39:24
int64_t?
jkarlin
2015/08/25 17:32:58
Done.
|
| + |
| + // Returns true if the handle is backed by a BackgroundSyncRegistration in the |
| + // BackgroundSyncManager. |
| + bool IsValid() const; |
| + |
| + HandleId handle_id() const { return handle_id_; } |
| + |
| + private: |
| + // This object must be deleted before the BackgroundSyncManager |
| + // is deleted. |
| + BackgroundSyncManager* background_sync_manager_; |
| + |
| + // Each BacckgroundSyncRegistrationHandle is assigned a unique handle id. |
| + // The BackgroundSyncManager maps the id to an internal pointer. |
| + HandleId handle_id_; |
| + |
| + // This is owned by background_sync_manager_ and is valid until handle_id_ is |
| + // released in the destructor. |
| + const BackgroundSyncRegistration* registration_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BackgroundSyncRegistrationHandle); |
| +}; |
| + |
| +} // namespace |
| + |
| +#endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_HANDLE_H_ |