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

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

Issue 261533003: Populate .current when navigator.serviceWorker is accessed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dropped dedicated worker support 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_SERVICE_WORKER_PROVIDER_CONTEXT_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_
7
8 #include <set>
9 #include <vector>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/sequenced_task_runner_helpers.h"
13 #include "base/synchronization/lock.h"
14 #include "content/common/service_worker/service_worker_types.h"
15
16 namespace base {
17 class MessageLoopProxy;
18 }
19
20 namespace IPC {
21 class Message;
22 }
23
24 namespace content {
25
26 class ServiceWorkerHandleReference;
27 struct ServiceWorkerProviderContextDeleter;
28 class ThreadSafeSender;
29
30 // An instance of this class holds document-related information (e.g.
31 // .current). Created and destructed on the main thread.
32 // TODO(kinuko): To support navigator.serviceWorker in dedicated workers
33 // this needs to be RefCountedThreadSafe and .current info needs to be
34 // handled in a thread-safe manner (e.g. by a lock etc).
35 class ServiceWorkerProviderContext
36 : public base::RefCounted<ServiceWorkerProviderContext> {
37 public:
38 explicit ServiceWorkerProviderContext(int provider_id);
39
40 // Gets the initial provider context information (e.g. to populate
41 // .current).
42 void GetInitializationInfo(
43 scoped_ptr<ServiceWorkerHandleReference>* current);
michaeln 2014/05/05 23:18:03 would it make sense to have this method return the
kinuko 2014/05/06 00:39:37 If we started to have more fields (e.g. pending?)
44
45 // Called from ServiceWorkerDispatcher.
46 void OnServiceWorkerStateChanged(int thread_id,
michaeln 2014/05/05 23:18:03 Does thread_id make sense here now? If i understa
kinuko 2014/05/06 00:39:37 It's not needed, my very early patch used to have
47 int handle_id,
48 blink::WebServiceWorkerState state);
49 void OnSetCurrentServiceWorker(int thread_id,
50 int provider_id,
51 const ServiceWorkerObjectInfo& info);
52
53 int provider_id() const { return provider_id_; }
54 int current_handle_id() const;
55
56 private:
57 friend class base::RefCounted<ServiceWorkerProviderContext>;
58 ~ServiceWorkerProviderContext();
59
60 const int provider_id_;
61 scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_;
62 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
63 scoped_ptr<ServiceWorkerHandleReference> current_;
64
65 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderContext);
66 };
67
68 } // namespace content
69
70 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698