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

Side by Side Diff: content/browser/service_worker/service_worker_handle.h

Issue 224733014: Introduce ServiceWorkerHandle for tracking WebServiceWorkerImpl reference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/browser/service_worker/service_worker_version.h"
13
14 namespace IPC {
15 class Sender;
16 }
17
18 namespace content {
19
20 class ServiceWorkerContextCore;
21 class ServiceWorkerRegistration;
22
23 // Roughly corresponds to one ServiceWorker object in the renderer process
24 // (WebServiceWorkerImpl).
25 // Has references to the corresponding ServiceWorkerVersion and
26 // ServiceWorkerRegistration (therefore they're guaranteed to be alive while
27 // this handle is around).
28 class ServiceWorkerHandle : public ServiceWorkerVersion::Listener {
29 public:
30 // Creates a handle for a live version. The version's corresponding
31 // registration must be also alive.
32 // This may return NULL if |context|.get() or |version| is NULL.
33 static scoped_ptr<ServiceWorkerHandle> Create(
34 base::WeakPtr<ServiceWorkerContextCore> context,
35 IPC::Sender* sender,
36 ServiceWorkerVersion* version);
37
38 ServiceWorkerHandle(base::WeakPtr<ServiceWorkerContextCore> context,
39 IPC::Sender* sender,
40 ServiceWorkerRegistration* registration,
41 ServiceWorkerVersion* version);
42 ~ServiceWorkerHandle();
43
44 // ServiceWorkerVersion::Listener overrides.
45 virtual void OnVersionStateChanged() OVERRIDE;
46
47 ServiceWorkerRegistration* registration() { return registration_.get(); }
48 ServiceWorkerVersion* version() { return version_.get(); }
49
50 private:
51 base::WeakPtr<ServiceWorkerContextCore> context_;
52 IPC::Sender* sender_; // Not owned, it should always outlive this.
53 scoped_refptr<ServiceWorkerRegistration> registration_;
54 scoped_refptr<ServiceWorkerVersion> version_;
55
56 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandle);
57 };
58
59 } // namespace content
60
61 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698