Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / content / child / service_worker / web_service_worker_registration_impl.h
blob51d28fa016659adf30dcee64b019ebe752fa64b1
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_WEB_SERVICE_WORKER_REGISTRATION_IMPL_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_REGISTRATION_IMPL_H_
8 #include <vector>
10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h"
12 #include "content/common/content_export.h"
13 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRegistration.h"
15 namespace blink {
16 class WebServiceWorker;
17 class WebServiceWorkerRegistrationProxy;
20 namespace content {
22 class ServiceWorkerRegistrationHandleReference;
23 class ThreadSafeSender;
24 struct ServiceWorkerObjectInfo;
26 class CONTENT_EXPORT WebServiceWorkerRegistrationImpl
27 : NON_EXPORTED_BASE(public blink::WebServiceWorkerRegistration),
28 public base::RefCounted<WebServiceWorkerRegistrationImpl> {
29 public:
30 explicit WebServiceWorkerRegistrationImpl(
31 scoped_ptr<ServiceWorkerRegistrationHandleReference> handle_ref);
33 void SetInstalling(blink::WebServiceWorker* service_worker);
34 void SetWaiting(blink::WebServiceWorker* service_worker);
35 void SetActive(blink::WebServiceWorker* service_worker);
37 void OnUpdateFound();
39 // blink::WebServiceWorkerRegistration overrides.
40 virtual void setProxy(blink::WebServiceWorkerRegistrationProxy* proxy);
41 virtual blink::WebServiceWorkerRegistrationProxy* proxy();
42 virtual blink::WebURL scope() const;
43 virtual void update(blink::WebServiceWorkerProvider* provider,
44 WebServiceWorkerUpdateCallbacks* callbacks);
45 virtual void unregister(blink::WebServiceWorkerProvider* provider,
46 WebServiceWorkerUnregistrationCallbacks* callbacks);
48 int64 registration_id() const;
50 using WebServiceWorkerRegistrationHandle =
51 blink::WebServiceWorkerRegistration::Handle;
53 // Creates WebServiceWorkerRegistrationHandle object that owns a reference to
54 // this WebServiceWorkerRegistrationImpl object.
55 blink::WebPassOwnPtr<WebServiceWorkerRegistrationHandle> CreateHandle();
57 // Same with CreateHandle(), but returns a raw pointer to the handle w/ its
58 // ownership instead. The caller must manage the ownership. This function must
59 // be used only for passing the handle to Blink API that does not support
60 // blink::WebPassOwnPtr.
61 WebServiceWorkerRegistrationHandle* CreateLeakyHandle();
63 private:
64 friend class base::RefCounted<WebServiceWorkerRegistrationImpl>;
65 virtual ~WebServiceWorkerRegistrationImpl();
67 enum QueuedTaskType {
68 INSTALLING,
69 WAITING,
70 ACTIVE,
71 UPDATE_FOUND,
74 struct QueuedTask {
75 QueuedTask(QueuedTaskType type,
76 blink::WebServiceWorker* worker);
77 QueuedTaskType type;
78 blink::WebServiceWorker* worker;
81 void RunQueuedTasks();
82 void ClearQueuedTasks();
84 scoped_ptr<ServiceWorkerRegistrationHandleReference> handle_ref_;
85 blink::WebServiceWorkerRegistrationProxy* proxy_;
87 std::vector<QueuedTask> queued_tasks_;
89 DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerRegistrationImpl);
92 } // namespace content
94 #endif // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_REGISTRATION_IMPL_H_