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

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

Issue 2583093002: Reduce SuspendableObjects (Closed)
Patch Set: Created 4 years 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 if (!handle) 137 if (!handle)
138 return nullptr; 138 return nullptr;
139 139
140 ServiceWorker* existingWorker = 140 ServiceWorker* existingWorker =
141 static_cast<ServiceWorker*>(handle->serviceWorker()->proxy()); 141 static_cast<ServiceWorker*>(handle->serviceWorker()->proxy());
142 if (existingWorker) { 142 if (existingWorker) {
143 ASSERT(existingWorker->getExecutionContext() == executionContext); 143 ASSERT(existingWorker->getExecutionContext() == executionContext);
144 return existingWorker; 144 return existingWorker;
145 } 145 }
146 146
147 ServiceWorker* newWorker = 147 return new ServiceWorker(executionContext, std::move(handle));
148 new ServiceWorker(executionContext, std::move(handle));
149 newWorker->suspendIfNeeded();
150 return newWorker;
151 } 148 }
152 149
153 ServiceWorker::ServiceWorker(ExecutionContext* executionContext, 150 ServiceWorker::ServiceWorker(ExecutionContext* executionContext,
154 std::unique_ptr<WebServiceWorker::Handle> handle) 151 std::unique_ptr<WebServiceWorker::Handle> handle)
155 : AbstractWorker(executionContext), 152 : AbstractWorker(executionContext),
156 m_handle(std::move(handle)), 153 m_handle(std::move(handle)),
157 m_wasStopped(false) { 154 m_wasStopped(false) {
158 ASSERT(m_handle); 155 ASSERT(m_handle);
159 m_handle->serviceWorker()->setProxy(this); 156 m_handle->serviceWorker()->setProxy(this);
160 } 157 }
161 158
162 ServiceWorker::~ServiceWorker() {} 159 ServiceWorker::~ServiceWorker() {}
163 160
164 DEFINE_TRACE(ServiceWorker) { 161 DEFINE_TRACE(ServiceWorker) {
165 AbstractWorker::trace(visitor); 162 AbstractWorker::trace(visitor);
166 } 163 }
167 164
168 } // namespace blink 165 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698