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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp

Issue 2104913002: Rename threadSafeBind() to crossThreadBind() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@TRV_CTCPointer
Patch Set: Rebase Created 4 years, 5 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/CompositorProxy.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/ScriptStreamer.h" 5 #include "bindings/core/v8/ScriptStreamer.h"
6 6
7 #include "bindings/core/v8/ScriptStreamerThread.h" 7 #include "bindings/core/v8/ScriptStreamerThread.h"
8 #include "bindings/core/v8/V8ScriptRunner.h" 8 #include "bindings/core/v8/V8ScriptRunner.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
11 #include "core/dom/PendingScript.h" 11 #include "core/dom/PendingScript.h"
12 #include "core/fetch/ScriptResource.h" 12 #include "core/fetch/ScriptResource.h"
13 #include "core/frame/Settings.h" 13 #include "core/frame/Settings.h"
14 #include "core/html/parser/TextResourceDecoder.h" 14 #include "core/html/parser/TextResourceDecoder.h"
15 #include "platform/CrossThreadFunctional.h"
15 #include "platform/Histogram.h" 16 #include "platform/Histogram.h"
16 #include "platform/SharedBuffer.h" 17 #include "platform/SharedBuffer.h"
17 #include "platform/ThreadSafeFunctional.h"
18 #include "platform/TraceEvent.h" 18 #include "platform/TraceEvent.h"
19 #include "public/platform/WebScheduler.h" 19 #include "public/platform/WebScheduler.h"
20 #include "wtf/Deque.h" 20 #include "wtf/Deque.h"
21 #include "wtf/PtrUtil.h" 21 #include "wtf/PtrUtil.h"
22 #include "wtf/text/TextEncodingRegistry.h" 22 #include "wtf/text/TextEncodingRegistry.h"
23 #include <memory> 23 #include <memory>
24 24
25 namespace blink { 25 namespace blink {
26 26
27 namespace { 27 namespace {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 MutexLocker locker(m_mutex); 225 MutexLocker locker(m_mutex);
226 m_queueLeadPosition = m_bookmarkPosition; 226 m_queueLeadPosition = m_bookmarkPosition;
227 // See comments at m_lengthOfBOM declaration below for why 227 // See comments at m_lengthOfBOM declaration below for why
228 // we need this here. 228 // we need this here.
229 m_queueTailPosition = m_bookmarkPosition + m_lengthOfBOM; 229 m_queueTailPosition = m_bookmarkPosition + m_lengthOfBOM;
230 m_dataQueue.clear(); 230 m_dataQueue.clear();
231 } 231 }
232 232
233 // Inform main thread to re-queue the data. 233 // Inform main thread to re-queue the data.
234 m_loadingTaskRunner->postTask( 234 m_loadingTaskRunner->postTask(
235 BLINK_FROM_HERE, threadSafeBind(&SourceStream::fetchDataFromResource Buffer, crossThreadUnretained(this), 0)); 235 BLINK_FROM_HERE, crossThreadBind(&SourceStream::fetchDataFromResourc eBuffer, crossThreadUnretained(this), 0));
236 } 236 }
237 237
238 void didFinishLoading() 238 void didFinishLoading()
239 { 239 {
240 ASSERT(isMainThread()); 240 ASSERT(isMainThread());
241 241
242 // ResetToBookmark may reset the data queue's 'finished' status, 242 // ResetToBookmark may reset the data queue's 'finished' status,
243 // so we may need to re-finish after a ResetToBookmark happened. 243 // so we may need to re-finish after a ResetToBookmark happened.
244 // We do this by remembering m_finished, and always checking for it 244 // We do this by remembering m_finished, and always checking for it
245 // at the end ot fetchDataFromResourceBuffer. 245 // at the end ot fetchDataFromResourceBuffer.
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 void ScriptStreamer::streamingCompleteOnBackgroundThread() 434 void ScriptStreamer::streamingCompleteOnBackgroundThread()
435 { 435 {
436 ASSERT(!isMainThread()); 436 ASSERT(!isMainThread());
437 { 437 {
438 MutexLocker locker(m_mutex); 438 MutexLocker locker(m_mutex);
439 m_parsingFinished = true; 439 m_parsingFinished = true;
440 } 440 }
441 441
442 // notifyFinished might already be called, or it might be called in the 442 // notifyFinished might already be called, or it might be called in the
443 // future (if the parsing finishes earlier because of a parse error). 443 // future (if the parsing finishes earlier because of a parse error).
444 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&ScriptStreame r::streamingComplete, wrapCrossThreadPersistent(this))); 444 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, crossThreadBind(&ScriptStream er::streamingComplete, wrapCrossThreadPersistent(this)));
445 445
446 // The task might delete ScriptStreamer, so it's not safe to do anything 446 // The task might delete ScriptStreamer, so it's not safe to do anything
447 // after posting it. Note that there's no way to guarantee that this 447 // after posting it. Note that there's no way to guarantee that this
448 // function has returned before the task is ran - however, we should not 448 // function has returned before the task is ran - however, we should not
449 // access the "this" object after posting the task. (Especially, we should 449 // access the "this" object after posting the task. (Especially, we should
450 // not be holding the mutex at this point.) 450 // not be holding the mutex at this point.)
451 } 451 }
452 452
453 void ScriptStreamer::cancel() 453 void ScriptStreamer::cancel()
454 { 454 {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 if (!scriptStreamingTask) { 542 if (!scriptStreamingTask) {
543 // V8 cannot stream the script. 543 // V8 cannot stream the script.
544 suppressStreaming(); 544 suppressStreaming();
545 m_stream = 0; 545 m_stream = 0;
546 m_source.reset(); 546 m_source.reset();
547 recordNotStreamingReasonHistogram(m_scriptType, V8CannotStream); 547 recordNotStreamingReasonHistogram(m_scriptType, V8CannotStream);
548 recordStartedStreamingHistogram(m_scriptType, 0); 548 recordStartedStreamingHistogram(m_scriptType, 0);
549 return; 549 return;
550 } 550 }
551 551
552 ScriptStreamerThread::shared()->postTask(threadSafeBind(&ScriptStreamerT hread::runScriptStreamingTask, passed(std::move(scriptStreamingTask)), wrapCross ThreadPersistent(this))); 552 ScriptStreamerThread::shared()->postTask(crossThreadBind(&ScriptStreamer Thread::runScriptStreamingTask, passed(std::move(scriptStreamingTask)), wrapCros sThreadPersistent(this)));
553 recordStartedStreamingHistogram(m_scriptType, 1); 553 recordStartedStreamingHistogram(m_scriptType, 1);
554 } 554 }
555 if (m_stream) 555 if (m_stream)
556 m_stream->didReceiveData(this, lengthOfBOM); 556 m_stream->didReceiveData(this, lengthOfBOM);
557 } 557 }
558 558
559 void ScriptStreamer::notifyFinished(Resource* resource) 559 void ScriptStreamer::notifyFinished(Resource* resource)
560 { 560 {
561 ASSERT(isMainThread()); 561 ASSERT(isMainThread());
562 ASSERT(m_resource == resource); 562 ASSERT(m_resource == resource);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 674
675 // The Resource might go out of scope if the script is no longer 675 // The Resource might go out of scope if the script is no longer
676 // needed. This makes PendingScript notify the ScriptStreamer when it is 676 // needed. This makes PendingScript notify the ScriptStreamer when it is
677 // destroyed. 677 // destroyed.
678 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState, compileOption, loadingTaskRunner)); 678 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState, compileOption, loadingTaskRunner));
679 679
680 return true; 680 return true;
681 } 681 }
682 682
683 } // namespace blink 683 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/CompositorProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698