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

Unified Diff: third_party/WebKit/Source/core/exported/WebSharedWorkerImpl.cpp

Issue 2939623002: [DONT COMMIT] WIP: WorkerClientsInitializer (Closed)
Patch Set: finalize2 Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/exported/WebSharedWorkerImpl.cpp
diff --git a/third_party/WebKit/Source/core/exported/WebSharedWorkerImpl.cpp b/third_party/WebKit/Source/core/exported/WebSharedWorkerImpl.cpp
index 33c956687c779ba06f83f2e461109465f8a48b37..7523950c9b1cbab0375af6df91a5c4454038a725 100644
--- a/third_party/WebKit/Source/core/exported/WebSharedWorkerImpl.cpp
+++ b/third_party/WebKit/Source/core/exported/WebSharedWorkerImpl.cpp
@@ -47,7 +47,6 @@
#include "core/workers/ParentFrameTaskRunners.h"
#include "core/workers/SharedWorkerGlobalScope.h"
#include "core/workers/SharedWorkerThread.h"
-#include "core/workers/WorkerClients.h"
#include "core/workers/WorkerContentSettingsClient.h"
#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerInspectorProxy.h"
@@ -78,21 +77,12 @@
namespace blink {
-namespace {
-
-// Vector of callbacks for the OnScriptLoaderFinished method.
-using WorkerClientsCreatedCallbackVector =
- WTF::Vector<WebSharedWorkerImpl::WorkerClientsCreatedCallback>;
-WorkerClientsCreatedCallbackVector& GetWorkerClientsCreatedCallbackVector() {
- DEFINE_STATIC_LOCAL(WorkerClientsCreatedCallbackVector, callback_vector, ());
- return callback_vector;
-}
-
-} // namespace
-
// TODO(toyoshim): Share implementation with WebEmbeddedWorkerImpl as much as
// possible.
+template class CORE_TEMPLATE_EXPORT
+ WorkerClientsInitializer<WebSharedWorkerImpl>;
+
WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client)
: web_view_(nullptr),
main_frame_(nullptr),
@@ -263,11 +253,6 @@ void WebSharedWorkerImpl::DidTerminateWorkerThread() {
delete this;
}
-void WebSharedWorkerImpl::RegisterWorkerClientsCreatedCallback(
- WorkerClientsCreatedCallback callback) {
- GetWorkerClientsCreatedCallbackVector().push_back(callback);
-}
-
void WebSharedWorkerImpl::Connect(
std::unique_ptr<WebMessagePortChannel> web_channel) {
DCHECK(IsMainThread());
@@ -338,10 +323,7 @@ void WebSharedWorkerImpl::OnScriptLoaderFinished() {
SecurityOrigin* starter_origin = loading_document_->GetSecurityOrigin();
WorkerClients* worker_clients = WorkerClients::Create();
- DCHECK(!GetWorkerClientsCreatedCallbackVector().IsEmpty());
- for (auto& callback : GetWorkerClientsCreatedCallbackVector()) {
- callback(worker_clients);
- }
+ WorkerClientsInitializer<WebSharedWorkerImpl>::Run(worker_clients);
WebSecurityOrigin web_security_origin(loading_document_->GetSecurityOrigin());
ProvideContentSettingsClientToWorker(
« no previous file with comments | « third_party/WebKit/Source/core/exported/WebSharedWorkerImpl.h ('k') | third_party/WebKit/Source/core/workers/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698