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

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: sigh, rebased 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 // |sender| and |thread_id| will be used to send messages to the
34 // corresponding WebServiceWorkerImpl (which should live on |thread_id|
35 // in the child process).
36 static scoped_ptr<ServiceWorkerHandle> Create(
37 base::WeakPtr<ServiceWorkerContextCore> context,
38 IPC::Sender* sender,
39 int thread_id,
40 ServiceWorkerVersion* version);
41
42 ServiceWorkerHandle(base::WeakPtr<ServiceWorkerContextCore> context,
43 IPC::Sender* sender,
44 int thread_id,
45 ServiceWorkerRegistration* registration,
46 ServiceWorkerVersion* version);
47 virtual ~ServiceWorkerHandle();
48
49 // ServiceWorkerVersion::Listener overrides.
50 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) OVERRIDE;
51
52 ServiceWorkerRegistration* registration() { return registration_.get(); }
53 ServiceWorkerVersion* version() { return version_.get(); }
54
55 private:
56 base::WeakPtr<ServiceWorkerContextCore> context_;
57 IPC::Sender* sender_; // Not owned, it should always outlive this.
58 const int thread_id_;
59 scoped_refptr<ServiceWorkerRegistration> registration_;
60 scoped_refptr<ServiceWorkerVersion> version_;
61
62 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandle);
63 };
64
65 } // namespace content
66
67 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698