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

Side by Side Diff: Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 214413004: Dispatch the ServiceWorker "activate" event during activation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Workers, activate! Created 6 years, 9 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
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 23 matching lines...) Expand all
34 #include "WebEmbeddedWorkerImpl.h" 34 #include "WebEmbeddedWorkerImpl.h"
35 #include "WebSerializedScriptValue.h" 35 #include "WebSerializedScriptValue.h"
36 #include "WebServiceWorkerContextClient.h" 36 #include "WebServiceWorkerContextClient.h"
37 #include "bindings/v8/WorkerScriptController.h" 37 #include "bindings/v8/WorkerScriptController.h"
38 #include "core/dom/ExecutionContext.h" 38 #include "core/dom/ExecutionContext.h"
39 #include "core/dom/MessagePort.h" 39 #include "core/dom/MessagePort.h"
40 #include "core/events/MessageEvent.h" 40 #include "core/events/MessageEvent.h"
41 #include "core/workers/WorkerGlobalScope.h" 41 #include "core/workers/WorkerGlobalScope.h"
42 #include "modules/serviceworkers/FetchEvent.h" 42 #include "modules/serviceworkers/FetchEvent.h"
43 #include "modules/serviceworkers/InstallEvent.h" 43 #include "modules/serviceworkers/InstallEvent.h"
44 #include "modules/serviceworkers/InstallPhaseEvent.h"
44 #include "modules/serviceworkers/WaitUntilObserver.h" 45 #include "modules/serviceworkers/WaitUntilObserver.h"
45 #include "platform/NotImplemented.h" 46 #include "platform/NotImplemented.h"
46 #include "wtf/Functional.h" 47 #include "wtf/Functional.h"
47 #include "wtf/PassOwnPtr.h" 48 #include "wtf/PassOwnPtr.h"
48 49
49 using namespace WebCore; 50 using namespace WebCore;
50 51
51 namespace blink { 52 namespace blink {
52 53
53 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create( WebEmbeddedWorkerImpl& embeddedWorker, ExecutionContext& executionContext, WebSe rviceWorkerContextClient& client) 54 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create( WebEmbeddedWorkerImpl& embeddedWorker, ExecutionContext& executionContext, WebSe rviceWorkerContextClient& client)
54 { 55 {
55 return adoptPtr(new ServiceWorkerGlobalScopeProxy(embeddedWorker, executionC ontext, client)); 56 return adoptPtr(new ServiceWorkerGlobalScopeProxy(embeddedWorker, executionC ontext, client));
56 } 57 }
57 58
58 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy() 59 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy()
59 { 60 {
60 } 61 }
61 62
62 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID) 63 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID)
63 { 64 {
64 ASSERT(m_workerGlobalScope); 65 ASSERT(m_workerGlobalScope);
65 RefPtr<WaitUntilObserver> observer = WaitUntilObserver::create(m_workerGloba lScope, eventID); 66 RefPtr<WaitUntilObserver> observer = WaitUntilObserver::create(m_workerGloba lScope, WaitUntilObserver::Install, eventID);
66 observer->willDispatchEvent(); 67 observer->willDispatchEvent();
67 m_workerGlobalScope->dispatchEvent(InstallEvent::create(EventTypeNames::inst all, EventInit(), observer)); 68 m_workerGlobalScope->dispatchEvent(InstallEvent::create(EventTypeNames::inst all, EventInit(), observer));
68 observer->didDispatchEvent(); 69 observer->didDispatchEvent();
69 } 70 }
70 71
72 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID)
73 {
74 ASSERT(m_workerGlobalScope);
75 RefPtr<WaitUntilObserver> observer = WaitUntilObserver::create(m_workerGloba lScope, WaitUntilObserver::Activate, eventID);
76 observer->willDispatchEvent();
77 m_workerGlobalScope->dispatchEvent(InstallPhaseEvent::create(EventTypeNames: :activate, EventInit(), observer));
78 observer->didDispatchEvent();
79 }
80
71 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID) 81 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID)
72 { 82 {
73 ASSERT(m_workerGlobalScope); 83 ASSERT(m_workerGlobalScope);
74 RefPtr<RespondWithObserver> observer = RespondWithObserver::create(m_workerG lobalScope, eventID); 84 RefPtr<RespondWithObserver> observer = RespondWithObserver::create(m_workerG lobalScope, eventID);
75 m_workerGlobalScope->dispatchEvent(FetchEvent::create(observer)); 85 m_workerGlobalScope->dispatchEvent(FetchEvent::create(observer));
76 observer->didDispatchEvent(); 86 observer->didDispatchEvent();
77 } 87 }
78 88
79 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(const WebString& messag e, const WebMessagePortChannelArray& webChannels) 89 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(const WebString& messag e, const WebMessagePortChannelArray& webChannels)
80 { 90 {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 142
133 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, ExecutionContext& executionContext, WebServiceWorkerContextC lient& client) 143 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, ExecutionContext& executionContext, WebServiceWorkerContextC lient& client)
134 : m_embeddedWorker(embeddedWorker) 144 : m_embeddedWorker(embeddedWorker)
135 , m_executionContext(executionContext) 145 , m_executionContext(executionContext)
136 , m_client(client) 146 , m_client(client)
137 , m_workerGlobalScope(0) 147 , m_workerGlobalScope(0)
138 { 148 {
139 } 149 }
140 150
141 } // namespace blink 151 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698