Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / content / child / service_worker / service_worker_provider_context.h
blob03a1d289c42eb2992cbaacbffa77a7b7faf58df2
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.
5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_
8 #include <set>
9 #include <vector>
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"
16 namespace base {
17 class MessageLoopProxy;
20 namespace IPC {
21 class Message;
24 namespace content {
26 class ServiceWorkerHandleReference;
27 class ServiceWorkerRegistrationHandleReference;
28 struct ServiceWorkerProviderContextDeleter;
29 class ThreadSafeSender;
31 // An instance of this class holds document-related information (e.g.
32 // .controller). Created and destructed on the main thread.
33 // TODO(kinuko): To support navigator.serviceWorker in dedicated workers
34 // this needs to be RefCountedThreadSafe and .controller info needs to be
35 // handled in a thread-safe manner (e.g. by a lock etc).
36 class ServiceWorkerProviderContext
37 : public base::RefCounted<ServiceWorkerProviderContext> {
38 public:
39 explicit ServiceWorkerProviderContext(int provider_id);
41 // Called from ServiceWorkerDispatcher.
42 void OnAssociateRegistration(const ServiceWorkerRegistrationObjectInfo& info,
43 const ServiceWorkerVersionAttributes& attrs);
44 void OnDisassociateRegistration();
45 void OnServiceWorkerStateChanged(int handle_id,
46 blink::WebServiceWorkerState state);
47 void OnSetControllerServiceWorker(const ServiceWorkerObjectInfo& info);
49 int provider_id() const { return provider_id_; }
51 ServiceWorkerHandleReference* controller();
52 ServiceWorkerRegistrationHandleReference* registration();
54 ServiceWorkerVersionAttributes GetVersionAttributes();
55 void SetVersionAttributes(ChangedVersionAttributesMask mask,
56 const ServiceWorkerVersionAttributes& attrs);
58 // Gets the handle ID of the installing Service Worker, or
59 // kInvalidServiceWorkerHandleId if the provider does not have a
60 // installing Service Worker.
61 int installing_handle_id() const;
63 // Gets the handle ID of the waiting Service Worker, or
64 // kInvalidServiceWorkerHandleId if the provider does not have a
65 // waiting Service Worker.
66 int waiting_handle_id() const;
68 // Gets the handle ID of the active Service Worker, or
69 // kInvalidServiceWorkerHandleId if the provider does not have an active
70 // Service Worker.
71 int active_handle_id() const;
73 // Gets the handle ID of the controller Service Worker, or
74 // kInvalidServiceWorkerHandleId if the provider is not controlled
75 // by a Service Worker.
76 int controller_handle_id() const;
78 // Gets the handle ID of the associated registration, or
79 // kInvalidRegistrationHandleId if the provider is not associated with any
80 // registration.
81 int registration_handle_id() const;
83 private:
84 friend class base::RefCounted<ServiceWorkerProviderContext>;
85 ~ServiceWorkerProviderContext();
87 const int provider_id_;
88 scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_;
89 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
90 scoped_ptr<ServiceWorkerHandleReference> installing_;
91 scoped_ptr<ServiceWorkerHandleReference> waiting_;
92 scoped_ptr<ServiceWorkerHandleReference> active_;
93 scoped_ptr<ServiceWorkerHandleReference> controller_;
94 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration_;
96 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderContext);
99 } // namespace content
101 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_