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

Side by Side Diff: Source/web/WebSharedWorkerImpl.cpp

Issue 106353005: Expose performance.memory in workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@Perf-Memory-SharedWorker
Patch Set: Created 6 years, 9 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 /* 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 150
151 WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) 151 WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client)
152 : m_webView(0) 152 : m_webView(0)
153 , m_mainFrame(0) 153 , m_mainFrame(0)
154 , m_askedToTerminate(false) 154 , m_askedToTerminate(false)
155 , m_client(WeakReference<WebSharedWorkerClient>::create(client)) 155 , m_client(WeakReference<WebSharedWorkerClient>::create(client))
156 , m_clientWeakPtr(WeakPtr<WebSharedWorkerClient>(m_client)) 156 , m_clientWeakPtr(WeakPtr<WebSharedWorkerClient>(m_client))
157 , m_pauseWorkerContextOnStart(false) 157 , m_pauseWorkerContextOnStart(false)
158 , m_attachDevToolsOnStart(false) 158 , m_attachDevToolsOnStart(false)
159 , m_settings(WebWorkerSettings::create())
kinuko 2014/03/10 05:55:52 not needed
159 { 160 {
160 initializeWebKitStaticValues(); 161 initializeWebKitStaticValues();
161 } 162 }
162 163
163 WebSharedWorkerImpl::~WebSharedWorkerImpl() 164 WebSharedWorkerImpl::~WebSharedWorkerImpl()
164 { 165 {
165 ASSERT(m_webView); 166 ASSERT(m_webView);
166 // Detach the client before closing the view to avoid getting called back. 167 // Detach the client before closing the view to avoid getting called back.
167 toWebFrameImpl(m_mainFrame)->setClient(0); 168 toWebFrameImpl(m_mainFrame)->setClient(0);
168 169
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 void WebSharedWorkerImpl::connectTask(ExecutionContext* context, PassOwnPtr<WebM essagePortChannel> channel) 307 void WebSharedWorkerImpl::connectTask(ExecutionContext* context, PassOwnPtr<WebM essagePortChannel> channel)
307 { 308 {
308 // Wrap the passed-in channel in a MessagePort, and send it off via a connec t event. 309 // Wrap the passed-in channel in a MessagePort, and send it off via a connec t event.
309 RefPtr<MessagePort> port = MessagePort::create(*context); 310 RefPtr<MessagePort> port = MessagePort::create(*context);
310 port->entangle(channel); 311 port->entangle(channel);
311 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); 312 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
312 ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScop e()); 313 ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScop e());
313 workerGlobalScope->dispatchEvent(createConnectEvent(port)); 314 workerGlobalScope->dispatchEvent(createConnectEvent(port));
314 } 315 }
315 316
316 void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString& name, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType poli cyType) 317 void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString& name, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType poli cyType, const WebWorkerSettings& settings)
317 { 318 {
318 m_url = url; 319 m_url = url;
319 m_name = name; 320 m_name = name;
320 m_contentSecurityPolicy = contentSecurityPolicy; 321 m_contentSecurityPolicy = contentSecurityPolicy;
321 m_policyType = policyType; 322 m_policyType = policyType;
323 m_settings = settings;
322 initializeLoader(url); 324 initializeLoader(url);
323 } 325 }
324 326
325 void WebSharedWorkerImpl::didReceiveScriptLoaderResponse() 327 void WebSharedWorkerImpl::didReceiveScriptLoaderResponse()
326 { 328 {
327 InspectorInstrumentation::didReceiveScriptResponse(m_loadingDocument.get(), m_mainScriptLoader->identifier()); 329 InspectorInstrumentation::didReceiveScriptResponse(m_loadingDocument.get(), m_mainScriptLoader->identifier());
328 if (client()) 330 if (client())
329 client()->selectAppCacheID(m_mainScriptLoader->appCacheID()); 331 client()->selectAppCacheID(m_mainScriptLoader->appCacheID());
330 } 332 }
331 333
(...skipping 11 matching lines...) Expand all
343 if (client()) 345 if (client())
344 client()->workerScriptLoadFailed(); 346 client()->workerScriptLoadFailed();
345 return; 347 return;
346 } 348 }
347 WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerG lobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart; 349 WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerG lobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart;
348 OwnPtr<WorkerClients> workerClients = WorkerClients::create(); 350 OwnPtr<WorkerClients> workerClients = WorkerClients::create();
349 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c reate()); 351 provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::c reate());
350 provideDatabaseClientToWorker(workerClients.get(), DatabaseClientImpl::creat e()); 352 provideDatabaseClientToWorker(workerClients.get(), DatabaseClientImpl::creat e());
351 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin()); 353 WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin());
352 providePermissionClientToWorker(workerClients.get(), adoptPtr(client()->crea teWorkerPermissionClientProxy(webSecurityOrigin))); 354 providePermissionClientToWorker(workerClients.get(), adoptPtr(client()->crea teWorkerPermissionClientProxy(webSecurityOrigin)));
353 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat e(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->script(), star tMode, m_contentSecurityPolicy, static_cast<WebCore::ContentSecurityPolicy::Head erType>(m_policyType), workerClients.release()); 355 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat e(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->script(), star tMode, m_contentSecurityPolicy, static_cast<WebCore::ContentSecurityPolicy::Head erType>(m_policyType), workerClients.release(), PassOwnPtr<WorkerSettings>(m_set tings));
kinuko 2014/03/10 13:50:41 I don't think we need this explicit cast (just pas
356
354 setWorkerThread(SharedWorkerThread::create(m_name, *this, *this, startupData .release())); 357 setWorkerThread(SharedWorkerThread::create(m_name, *this, *this, startupData .release()));
355 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri ptLoader->identifier(), m_mainScriptLoader->script()); 358 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri ptLoader->identifier(), m_mainScriptLoader->script());
356 m_mainScriptLoader.clear(); 359 m_mainScriptLoader.clear();
357 360
358 if (m_attachDevToolsOnStart) 361 if (m_attachDevToolsOnStart)
359 workerThread()->runLoop().postDebuggerTask(createCallbackTask(connectToW orkerContextInspectorTask, true)); 362 workerThread()->runLoop().postDebuggerTask(createCallbackTask(connectToW orkerContextInspectorTask, true));
360 363
361 workerThread()->start(); 364 workerThread()->start();
362 if (client()) 365 if (client())
363 client()->workerScriptLoaded(); 366 client()->workerScriptLoaded();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 workerThread()->runLoop().postDebuggerTask(createCallbackTask(dispatchOnInsp ectorBackendTask, String(message))); 434 workerThread()->runLoop().postDebuggerTask(createCallbackTask(dispatchOnInsp ectorBackendTask, String(message)));
432 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(workerThread()); 435 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(workerThread());
433 } 436 }
434 437
435 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) 438 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client)
436 { 439 {
437 return new WebSharedWorkerImpl(client); 440 return new WebSharedWorkerImpl(client);
438 } 441 }
439 442
440 } // namespace blink 443 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698