Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / child / service_worker / web_service_worker_registration_impl.h
blob3feb71b40c56be9559c311b9e4672f46ba7593b7
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 "content/common/content_export.h"
12 #include "third_party/WebKit/public/platform/WebServiceWorkerRegistration.h"
14 namespace blink {
15 class WebServiceWorker;
16 class WebServiceWorkerRegistrationProxy;
19 namespace content {
21 class ServiceWorkerRegistrationHandleReference;
22 class ThreadSafeSender;
23 struct ServiceWorkerObjectInfo;
25 class CONTENT_EXPORT WebServiceWorkerRegistrationImpl
26 : NON_EXPORTED_BASE(public blink::WebServiceWorkerRegistration) {
27 public:
28 explicit WebServiceWorkerRegistrationImpl(
29 scoped_ptr<ServiceWorkerRegistrationHandleReference> handle_ref);
30 virtual ~WebServiceWorkerRegistrationImpl();
32 void SetInstalling(blink::WebServiceWorker* service_worker);
33 void SetWaiting(blink::WebServiceWorker* service_worker);
34 void SetActive(blink::WebServiceWorker* service_worker);
36 void OnUpdateFound();
38 // blink::WebServiceWorkerRegistration overrides.
39 virtual void setProxy(blink::WebServiceWorkerRegistrationProxy* proxy);
40 virtual blink::WebServiceWorkerRegistrationProxy* proxy();
41 virtual blink::WebURL scope() const;
43 int64 registration_id() const;
45 private:
46 enum QueuedTaskType {
47 INSTALLING,
48 WAITING,
49 ACTIVE,
50 UPDATE_FOUND,
53 struct QueuedTask {
54 QueuedTask(QueuedTaskType type,
55 blink::WebServiceWorker* worker);
56 QueuedTaskType type;
57 blink::WebServiceWorker* worker;
60 void RunQueuedTasks();
61 void ClearQueuedTasks();
63 scoped_ptr<ServiceWorkerRegistrationHandleReference> handle_ref_;
64 blink::WebServiceWorkerRegistrationProxy* proxy_;
66 std::vector<QueuedTask> queued_tasks_;
68 DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerRegistrationImpl);
71 } // namespace content
73 #endif // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_REGISTRATION_IMPL_H_