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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerContainer.h

Issue 476043002: ServiceWorker: Make '.ready' return a promise to be resolved with ServiceWorkerRegistration (1/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix win build Created 6 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #ifndef ServiceWorkerContainer_h 31 #ifndef ServiceWorkerContainer_h
32 #define ServiceWorkerContainer_h 32 #define ServiceWorkerContainer_h
33 33
34 #include "bindings/core/v8/ScriptPromise.h" 34 #include "bindings/core/v8/ScriptPromise.h"
35 #include "bindings/core/v8/ScriptPromiseProperty.h" 35 #include "bindings/core/v8/ScriptPromiseProperty.h"
36 #include "bindings/core/v8/ScriptWrappable.h" 36 #include "bindings/core/v8/ScriptWrappable.h"
37 #include "core/dom/ContextLifecycleObserver.h" 37 #include "core/dom/ContextLifecycleObserver.h"
38 #include "modules/serviceworkers/ServiceWorker.h" 38 #include "modules/serviceworkers/ServiceWorker.h"
39 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
39 #include "platform/heap/Handle.h" 40 #include "platform/heap/Handle.h"
40 #include "public/platform/WebServiceWorkerProviderClient.h" 41 #include "public/platform/WebServiceWorkerProviderClient.h"
41 #include "wtf/Forward.h" 42 #include "wtf/Forward.h"
42 #include "wtf/PassRefPtr.h" 43 #include "wtf/PassRefPtr.h"
43 #include "wtf/RefCounted.h" 44 #include "wtf/RefCounted.h"
44 #include "wtf/RefPtr.h" 45 #include "wtf/RefPtr.h"
45 46
46 namespace blink { 47 namespace blink {
47 48
48 class Dictionary; 49 class Dictionary;
49 class ExecutionContext; 50 class ExecutionContext;
50 class ServiceWorker;
51 class WebServiceWorker; 51 class WebServiceWorker;
52 class WebServiceWorkerProvider; 52 class WebServiceWorkerProvider;
53 class WebServiceWorkerRegistration;
53 54
54 class ServiceWorkerContainer FINAL 55 class ServiceWorkerContainer FINAL
55 : public RefCountedWillBeGarbageCollectedFinalized<ServiceWorkerContainer> 56 : public RefCountedWillBeGarbageCollectedFinalized<ServiceWorkerContainer>
56 , public ScriptWrappable 57 , public ScriptWrappable
57 , public ContextLifecycleObserver 58 , public ContextLifecycleObserver
58 , public WebServiceWorkerProviderClient { 59 , public WebServiceWorkerProviderClient {
59 public: 60 public:
60 static PassRefPtrWillBeRawPtr<ServiceWorkerContainer> create(ExecutionContex t*); 61 static PassRefPtrWillBeRawPtr<ServiceWorkerContainer> create(ExecutionContex t*);
61 ~ServiceWorkerContainer(); 62 ~ServiceWorkerContainer();
62 63
63 void willBeDetachedFromFrame(); 64 void willBeDetachedFromFrame();
64 65
65 void trace(Visitor*); 66 void trace(Visitor*);
66 67
67 PassRefPtrWillBeRawPtr<ServiceWorker> active() { return m_active.get(); } 68 PassRefPtrWillBeRawPtr<ServiceWorker> active() { return m_active.get(); }
68 PassRefPtrWillBeRawPtr<ServiceWorker> controller() { return m_controller.get (); } 69 PassRefPtrWillBeRawPtr<ServiceWorker> controller() { return m_controller.get (); }
69 PassRefPtrWillBeRawPtr<ServiceWorker> installing() { return m_installing.get (); } 70 PassRefPtrWillBeRawPtr<ServiceWorker> installing() { return m_installing.get (); }
70 PassRefPtrWillBeRawPtr<ServiceWorker> waiting() { return m_waiting.get(); } 71 PassRefPtrWillBeRawPtr<ServiceWorker> waiting() { return m_waiting.get(); }
71 ScriptPromise ready(ScriptState*); 72 ScriptPromise ready(ScriptState*);
72 WebServiceWorkerProvider* provider() { return m_provider; } 73 WebServiceWorkerProvider* provider() { return m_provider; }
73 74
74 ScriptPromise registerServiceWorker(ScriptState*, const String& pattern, con st Dictionary&); 75 ScriptPromise registerServiceWorker(ScriptState*, const String& pattern, con st Dictionary&);
75 ScriptPromise unregisterServiceWorker(ScriptState*, const String& scope); 76 ScriptPromise unregisterServiceWorker(ScriptState*, const String& scope);
76 77
77 // WebServiceWorkerProviderClient overrides. 78 // WebServiceWorkerProviderClient overrides.
78 virtual void setActive(WebServiceWorker*) OVERRIDE; 79 virtual void setActive(WebServiceWorker*) OVERRIDE;
79 virtual void setController(WebServiceWorker*) OVERRIDE; 80 virtual void setController(WebServiceWorker*) OVERRIDE;
80 virtual void setInstalling(WebServiceWorker*) OVERRIDE; 81 virtual void setInstalling(WebServiceWorker*) OVERRIDE;
81 virtual void setWaiting(WebServiceWorker*) OVERRIDE; 82 virtual void setWaiting(WebServiceWorker*) OVERRIDE;
83 virtual void setReady(WebServiceWorkerRegistration*) OVERRIDE;
michaeln 2014/09/03 22:17:48 Should this method be named setRegistration or may
nhiroki 2014/09/04 08:55:58 Sounds reasonable. Replaced 'setReady' with 'setRe
82 virtual void dispatchMessageEvent(const WebString& message, const WebMessage PortChannelArray&) OVERRIDE; 84 virtual void dispatchMessageEvent(const WebString& message, const WebMessage PortChannelArray&) OVERRIDE;
83 85
84 private: 86 private:
85 explicit ServiceWorkerContainer(ExecutionContext*); 87 explicit ServiceWorkerContainer(ExecutionContext*);
86 88
87 typedef ScriptPromiseProperty<RawPtrWillBeMember<ServiceWorkerContainer>, Re fPtrWillBeMember<ServiceWorker>, RefPtrWillBeMember<ServiceWorker> > ReadyProper ty; 89 typedef ScriptPromiseProperty<RawPtrWillBeMember<ServiceWorkerContainer>, Re fPtrWillBeMember<ServiceWorkerRegistration>, RefPtrWillBeMember<ServiceWorkerReg istration> > ReadyProperty;
88 ReadyProperty* createReadyProperty(); 90 ReadyProperty* createReadyProperty();
89 void checkReadyChanged(PassRefPtrWillBeRawPtr<ServiceWorker> previousReadyWo rker); 91 void checkReadyChanged(PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> pre viousReadyRegistration);
90 92
91 WebServiceWorkerProvider* m_provider; 93 WebServiceWorkerProvider* m_provider;
92 RefPtrWillBeMember<ServiceWorker> m_active; 94 RefPtrWillBeMember<ServiceWorker> m_active;
93 RefPtrWillBeMember<ServiceWorker> m_controller; 95 RefPtrWillBeMember<ServiceWorker> m_controller;
94 RefPtrWillBeMember<ServiceWorker> m_installing; 96 RefPtrWillBeMember<ServiceWorker> m_installing;
95 RefPtrWillBeMember<ServiceWorker> m_waiting; 97 RefPtrWillBeMember<ServiceWorker> m_waiting;
98 RefPtrWillBeMember<ServiceWorkerRegistration> m_readyRegistration;
96 PersistentWillBeMember<ReadyProperty> m_ready; 99 PersistentWillBeMember<ReadyProperty> m_ready;
97 }; 100 };
98 101
99 } // namespace blink 102 } // namespace blink
100 103
101 #endif // ServiceWorkerContainer_h 104 #endif // ServiceWorkerContainer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698