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

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

Issue 23506013: Make the embedder responsible for creating the WebFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add WebViewHelper for unittests. Created 7 years, 3 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // Note that we have to pass a URL with valid protocol in order to follo w 85 // Note that we have to pass a URL with valid protocol in order to follo w
86 // the path to do static value initializations. 86 // the path to do static value initializations.
87 RefPtr<SecurityOrigin> origin = 87 RefPtr<SecurityOrigin> origin =
88 SecurityOrigin::create(KURL(ParsedURLString, "http://localhost")); 88 SecurityOrigin::create(KURL(ParsedURLString, "http://localhost"));
89 origin.release(); 89 origin.release();
90 } 90 }
91 } 91 }
92 92
93 WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) 93 WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client)
94 : m_webView(0) 94 : m_webView(0)
95 , m_mainFrame(0)
95 , m_askedToTerminate(false) 96 , m_askedToTerminate(false)
96 , m_client(client) 97 , m_client(client)
97 , m_pauseWorkerContextOnStart(false) 98 , m_pauseWorkerContextOnStart(false)
98 { 99 {
99 initializeWebKitStaticValues(); 100 initializeWebKitStaticValues();
100 } 101 }
101 102
102 WebSharedWorkerImpl::~WebSharedWorkerImpl() 103 WebSharedWorkerImpl::~WebSharedWorkerImpl()
103 { 104 {
104 ASSERT(m_webView); 105 ASSERT(m_webView);
105 WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame()); 106 // Detach the client before closing the view to avoid getting called back.
106 if (webFrame) 107 toWebFrameImpl(m_mainFrame)->setClient(0);
107 webFrame->setClient(0); 108
108 m_webView->close(); 109 m_webView->close();
110 m_mainFrame->close();
109 } 111 }
110 112
111 void WebSharedWorkerImpl::stopWorkerThread() 113 void WebSharedWorkerImpl::stopWorkerThread()
112 { 114 {
113 if (m_askedToTerminate) 115 if (m_askedToTerminate)
114 return; 116 return;
115 m_askedToTerminate = true; 117 m_askedToTerminate = true;
116 if (m_workerThread) 118 if (m_workerThread)
117 m_workerThread->stop(); 119 m_workerThread->stop();
118 } 120 }
119 121
120 void WebSharedWorkerImpl::initializeLoader(const WebURL& url) 122 void WebSharedWorkerImpl::initializeLoader(const WebURL& url)
121 { 123 {
122 // Create 'shadow page'. This page is never displayed, it is used to proxy t he 124 // Create 'shadow page'. This page is never displayed, it is used to proxy t he
123 // loading requests from the worker context to the rest of WebKit and Chromi um 125 // loading requests from the worker context to the rest of WebKit and Chromi um
124 // infrastructure. 126 // infrastructure.
125 ASSERT(!m_webView); 127 ASSERT(!m_webView);
126 m_webView = WebView::create(0); 128 m_webView = WebView::create(0);
127 m_webView->settings()->setOfflineWebApplicationCacheEnabled(WebRuntimeFeatur es::isApplicationCacheEnabled()); 129 m_webView->settings()->setOfflineWebApplicationCacheEnabled(WebRuntimeFeatur es::isApplicationCacheEnabled());
128 // FIXME: Settings information should be passed to the Worker process from B rowser process when the worker 130 // FIXME: Settings information should be passed to the Worker process from B rowser process when the worker
129 // is created (similar to RenderThread::OnCreateNewView). 131 // is created (similar to RenderThread::OnCreateNewView).
130 m_webView->initializeMainFrame(this); 132 m_mainFrame = WebFrame::create(this);
133 m_webView->initializeMainFrame(m_mainFrame);
131 134
132 WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame()); 135 WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame());
133 136
134 // Construct substitute data source for the 'shadow page'. We only need it 137 // Construct substitute data source for the 'shadow page'. We only need it
135 // to have same origin as the worker so the loading checks work correctly. 138 // to have same origin as the worker so the loading checks work correctly.
136 CString content(""); 139 CString content("");
137 int length = static_cast<int>(content.length()); 140 int length = static_cast<int>(content.length());
138 RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length)); 141 RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length));
139 webFrame->frame()->loader()->load(FrameLoadRequest(0, ResourceRequest(url), SubstituteData(buffer, "text/html", "UTF-8", KURL()))); 142 webFrame->frame()->loader()->load(FrameLoadRequest(0, ResourceRequest(url), SubstituteData(buffer, "text/html", "UTF-8", KURL())));
140 143
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 workerThread()->runLoop().postTaskForMode(createCallbackTask(dispatchOnInspe ctorBackendTask, String(message)), WorkerDebuggerAgent::debuggerTaskMode); 451 workerThread()->runLoop().postTaskForMode(createCallbackTask(dispatchOnInspe ctorBackendTask, String(message)), WorkerDebuggerAgent::debuggerTaskMode);
449 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(workerThread()); 452 WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(workerThread());
450 } 453 }
451 454
452 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) 455 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client)
453 { 456 {
454 return new WebSharedWorkerImpl(client); 457 return new WebSharedWorkerImpl(client);
455 } 458 }
456 459
457 } // namespace WebKit 460 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698