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

Side by Side Diff: content/child/service_worker/scoped_service_worker_reference.h

Issue 261533003: Populate .current when navigator.serviceWorker is accessed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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_CHILD_SERVICE_WORKER_SCOPED_SERVICE_WORKER_REFERENCE_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_SCOPED_SERVICE_WORKER_REFERENCE_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/common/service_worker/service_worker_types.h"
11
12 namespace content {
13
14 class ThreadSafeSender;
15
16 // Automatically increments and decrement ServiceWorker's ref-count (in the
michaeln 2014/05/01 01:25:18 there are lots of classes so it would help to be r
kinuko 2014/05/02 10:00:56 Sg, done.
17 // browser side) in ctor and dtor.
18 class ScopedServiceWorkerReference {
19 public:
20 // Creates a new ScopedServiceWorkerReference (and increments ref-count).
21 static scoped_ptr<ScopedServiceWorkerReference> Create(
22 const ServiceWorkerObjectInfo& info,
23 ThreadSafeSender* sender);
24 // This doesn't increment ref-count in ctor.
25 static scoped_ptr<ScopedServiceWorkerReference> CreateForDeleter(
26 const ServiceWorkerObjectInfo& info,
27 ThreadSafeSender* sender);
28
29 ~ScopedServiceWorkerReference();
30
31 const ServiceWorkerObjectInfo& info() const { return info_; }
32 int handle_id() const { return info_.handle_id; }
33 const GURL& scope() const { return info_.scope; }
34 const GURL& url() const { return info_.url; }
35 blink::WebServiceWorkerState state() const { return info_.state; }
36 void set_state(blink::WebServiceWorkerState state) { info_.state = state; }
37
38 private:
39 ScopedServiceWorkerReference(const ServiceWorkerObjectInfo& info,
40 ThreadSafeSender* sender,
41 bool increment_ref_in_ctor);
42 ServiceWorkerObjectInfo info_;
43 scoped_refptr<ThreadSafeSender> sender_;
44 DISALLOW_COPY_AND_ASSIGN(ScopedServiceWorkerReference);
45 };
46
47 } // namespace content
48
49 #endif // CONTENT_CHILD_SERVICE_WORKER_SCOPED_SERVICE_WORKER_REFERENCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698