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

Side by Side Diff: webkit/api/src/SharedWorkerRepository.cpp

Issue 390017: Added lifecycle management and sharing support for SharedWorkers. SharedWorkers (Closed)
Patch Set: Changed WebWorkerBase not not call a virtual function from the destructor Created 11 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); 164 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
165 OwnPtr<WebSharedWorker> webWorker; 165 OwnPtr<WebSharedWorker> webWorker;
166 webWorker = webFrame->client()->createSharedWorker(webFrame, url, name, getId(document)); 166 webWorker = webFrame->client()->createSharedWorker(webFrame, url, name, getId(document));
167 167
168 if (!webWorker) { 168 if (!webWorker) {
169 // Existing worker does not match this url, so return an error back to the caller. 169 // Existing worker does not match this url, so return an error back to the caller.
170 ec = URL_MISMATCH_ERR; 170 ec = URL_MISMATCH_ERR;
171 return; 171 return;
172 } 172 }
173 173
174 WebKit::webKitClient()->sharedWorkerRepository()->addSharedWorker(
175 webWorker.get(), getId(document));
176
174 // The loader object manages its own lifecycle (and the lifecycles of the two worker objects). 177 // The loader object manages its own lifecycle (and the lifecycles of the two worker objects).
175 // It will free itself once loading is completed. 178 // It will free itself once loading is completed.
176 SharedWorkerScriptLoader* loader = new SharedWorkerScriptLoader(worker, url, name, port.release(), webWorker.release()); 179 SharedWorkerScriptLoader* loader = new SharedWorkerScriptLoader(worker, url, name, port.release(), webWorker.release());
177 loader->load(); 180 loader->load();
178 } 181 }
179 182
180 void SharedWorkerRepository::documentDetached(Document* document) 183 void SharedWorkerRepository::documentDetached(Document* document)
181 { 184 {
182 WebSharedWorkerRepository* repo = WebKit::webKitClient()->sharedWorkerRepository(); 185 WebSharedWorkerRepository* repo = WebKit::webKitClient()->sharedWorkerRepository();
183 if (repo) 186 if (repo)
184 repo->documentDetached(getId(document)); 187 repo->documentDetached(getId(document));
185 } 188 }
186 189
187 bool SharedWorkerRepository::hasSharedWorkers(Document* document) 190 bool SharedWorkerRepository::hasSharedWorkers(Document* document)
188 { 191 {
189 WebSharedWorkerRepository* repo = WebKit::webKitClient()->sharedWorkerRepository(); 192 WebSharedWorkerRepository* repo = WebKit::webKitClient()->sharedWorkerRepository();
190 return repo && repo->hasSharedWorkers(getId(document)); 193 return repo && repo->hasSharedWorkers(getId(document));
191 } 194 }
192 195
193 196
194 197
195 } // namespace WebCore 198 } // namespace WebCore
196 199
197 #endif // ENABLE(SHARED_WORKERS) 200 #endif // ENABLE(SHARED_WORKERS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698