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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainerClient.cpp

Issue 2317483005: Clear LifecycleObserver::m_context when LifecycleObserver::contextDestroyed gets called (Closed)
Patch Set: temp Created 4 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 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 5 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/ExecutionContext.h" 8 #include "core/dom/ExecutionContext.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/loader/FrameLoaderClient.h" 10 #include "core/loader/FrameLoaderClient.h"
(...skipping 17 matching lines...) Expand all
28 { 28 {
29 } 29 }
30 30
31 const char* ServiceWorkerContainerClient::supplementName() 31 const char* ServiceWorkerContainerClient::supplementName()
32 { 32 {
33 return "ServiceWorkerContainerClient"; 33 return "ServiceWorkerContainerClient";
34 } 34 }
35 35
36 ServiceWorkerContainerClient* ServiceWorkerContainerClient::from(ExecutionContex t* context) 36 ServiceWorkerContainerClient* ServiceWorkerContainerClient::from(ExecutionContex t* context)
37 { 37 {
38 if (!context)
39 return nullptr;
38 if (context->isWorkerGlobalScope()) { 40 if (context->isWorkerGlobalScope()) {
39 WorkerClients* clients = toWorkerGlobalScope(context)->clients(); 41 WorkerClients* clients = toWorkerGlobalScope(context)->clients();
40 ASSERT(clients); 42 ASSERT(clients);
41 return static_cast<ServiceWorkerContainerClient*>(Supplement<WorkerClien ts>::from(clients, supplementName())); 43 return static_cast<ServiceWorkerContainerClient*>(Supplement<WorkerClien ts>::from(clients, supplementName()));
42 } 44 }
43 Document* document = toDocument(context); 45 Document* document = toDocument(context);
44 if (!document->frame()) 46 if (!document->frame())
45 return nullptr; 47 return nullptr;
46 48
47 ServiceWorkerContainerClient* client = static_cast<ServiceWorkerContainerCli ent*>(Supplement<Document>::from(document, supplementName())); 49 ServiceWorkerContainerClient* client = static_cast<ServiceWorkerContainerCli ent*>(Supplement<Document>::from(document, supplementName()));
48 if (!client) { 50 if (!client) {
49 client = new ServiceWorkerContainerClient(document->frame()->loader().cl ient()->createServiceWorkerProvider()); 51 client = new ServiceWorkerContainerClient(document->frame()->loader().cl ient()->createServiceWorkerProvider());
50 Supplement<Document>::provideTo(*document, supplementName(), client); 52 Supplement<Document>::provideTo(*document, supplementName(), client);
51 } 53 }
52 return client; 54 return client;
53 } 55 }
54 56
55 void provideServiceWorkerContainerClientToWorker(WorkerClients* clients, std::un ique_ptr<WebServiceWorkerProvider> provider) 57 void provideServiceWorkerContainerClientToWorker(WorkerClients* clients, std::un ique_ptr<WebServiceWorkerProvider> provider)
56 { 58 {
57 clients->provideSupplement(ServiceWorkerContainerClient::supplementName(), S erviceWorkerContainerClient::create(std::move(provider))); 59 clients->provideSupplement(ServiceWorkerContainerClient::supplementName(), S erviceWorkerContainerClient::create(std::move(provider)));
58 } 60 }
59 61
60 } // namespace blink 62 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698