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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorker.cpp

Issue 682003003: Simplify WebServiceWorker{Registration}Proxy interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove Impl wrapper layer; extend to also cover WebServiceWorkerProxy Created 6 years, 1 month 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 void ServiceWorker::stop() 234 void ServiceWorker::stop()
235 { 235 {
236 setProxyState(ContextStopped); 236 setProxyState(ContextStopped);
237 } 237 }
238 238
239 PassRefPtrWillBeRawPtr<ServiceWorker> ServiceWorker::getOrCreate(ExecutionContex t* executionContext, WebType* outerWorker) 239 PassRefPtrWillBeRawPtr<ServiceWorker> ServiceWorker::getOrCreate(ExecutionContex t* executionContext, WebType* outerWorker)
240 { 240 {
241 if (!outerWorker) 241 if (!outerWorker)
242 return nullptr; 242 return nullptr;
243 243
244 WebServiceWorkerProxy* proxy = outerWorker->proxy(); 244 ServiceWorker* existingServiceWorker = static_cast<ServiceWorker*>(outerWork er->proxy());
245 ServiceWorker* existingServiceWorker = proxy ? proxy->unwrap() : 0;
246 if (existingServiceWorker) { 245 if (existingServiceWorker) {
247 ASSERT(existingServiceWorker->executionContext() == executionContext); 246 ASSERT(existingServiceWorker->executionContext() == executionContext);
248 return existingServiceWorker; 247 return existingServiceWorker;
249 } 248 }
250 249
251 RefPtrWillBeRawPtr<ServiceWorker> worker = adoptRefWillBeNoop(new ServiceWor ker(executionContext, adoptPtr(outerWorker))); 250 RefPtrWillBeRawPtr<ServiceWorker> worker = adoptRefWillBeNoop(new ServiceWor ker(executionContext, adoptPtr(outerWorker)));
252 worker->suspendIfNeeded(); 251 worker->suspendIfNeeded();
253 return worker.release(); 252 return worker.release();
254 } 253 }
255 254
256 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS erviceWorker> worker) 255 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, PassOwnPtr<WebS erviceWorker> worker)
257 : AbstractWorker(executionContext) 256 : AbstractWorker(executionContext)
258 , WebServiceWorkerProxy(this)
259 , m_outerWorker(worker) 257 , m_outerWorker(worker)
260 , m_proxyState(Initial) 258 , m_proxyState(Initial)
261 { 259 {
262 ASSERT(m_outerWorker); 260 ASSERT(m_outerWorker);
263 m_outerWorker->setProxy(this); 261 m_outerWorker->setProxy(this);
264 } 262 }
265 263
266 } // namespace blink 264 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/modules/serviceworkers/ServiceWorkerRegistration.cpp » ('j') | public/platform/WebServiceWorkerProxy.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698