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

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

Issue 1282013004: BackgroundSyncManager tracks client registrations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up Created 5 years, 4 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
(Empty)
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.
4
5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_HANDLE_H_
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_HANDLE_H_
7
8 #include "base/callback.h"
9 #include "content/browser/background_sync/background_sync_registration.h"
10 #include "content/browser/background_sync/background_sync_status.h"
11 #include "content/common/content_export.h"
12
13 namespace content {
14
15 class BackgroundSyncManager;
16
17 // Handle to BackgroundSyncRegistration that is exposed to clients. Each
18 // BackgroundSyncRegistrationHandle is given a unique handle id (by the
19 // BackgroundSyncManager) which is released at destruction.
20 // BackgroundSyncRegistrationHandle objects must be deleted before the
21 // BackgroundSyncManager is deleted.
22 class CONTENT_EXPORT BackgroundSyncRegistrationHandle {
23 public:
24 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.
25 using StatusCallback = base::Callback<void(BackgroundSyncStatus)>;
26
27 BackgroundSyncRegistrationHandle(
28 BackgroundSyncManager* background_sync_manager,
29 HandleId handle_id);
30 virtual ~BackgroundSyncRegistrationHandle();
michaeln 2015/08/21 02:39:24 does this need to be virtual?
jkarlin 2015/08/25 17:32:58 Done.
31
32 const BackgroundSyncRegistrationOptions* options() const {
33 return registration_->options();
34 }
35
36 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.
37 return registration_;
38 }
39
40 // Unregisters the background sync registration. Calls |callback|
41 // with BACKGROUND_SYNC_STATUS_OK if it succeeds.
42 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.
43
44 // Returns true if the handle is backed by a BackgroundSyncRegistration in the
45 // BackgroundSyncManager.
46 bool IsValid() const;
47
48 HandleId handle_id() const { return handle_id_; }
49
50 private:
51 // This object must be deleted before the BackgroundSyncManager
52 // is deleted.
53 BackgroundSyncManager* background_sync_manager_;
54
55 // Each BacckgroundSyncRegistrationHandle is assigned a unique handle id.
56 // The BackgroundSyncManager maps the id to an internal pointer.
57 HandleId handle_id_;
58
59 // This is owned by background_sync_manager_ and is valid until handle_id_ is
60 // released in the destructor.
61 const BackgroundSyncRegistration* registration_;
62
63 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncRegistrationHandle);
64 };
65
66 } // namespace
67
68 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_HANDLE_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698