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

Side by Side Diff: third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp

Issue 1580883002: Oilpan: move AsyncMethodRunner to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename to RawPtrOrMemberTrait<> Created 4 years, 11 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 , m_source(source) 104 , m_source(source)
105 , m_trackDefaults(TrackDefaultList::create()) 105 , m_trackDefaults(TrackDefaultList::create())
106 , m_asyncEventQueue(asyncEventQueue) 106 , m_asyncEventQueue(asyncEventQueue)
107 , m_mode(segmentsKeyword()) 107 , m_mode(segmentsKeyword())
108 , m_updating(false) 108 , m_updating(false)
109 , m_timestampOffset(0) 109 , m_timestampOffset(0)
110 , m_appendWindowStart(0) 110 , m_appendWindowStart(0)
111 , m_appendWindowEnd(std::numeric_limits<double>::infinity()) 111 , m_appendWindowEnd(std::numeric_limits<double>::infinity())
112 , m_firstInitializationSegmentReceived(false) 112 , m_firstInitializationSegmentReceived(false)
113 , m_pendingAppendDataOffset(0) 113 , m_pendingAppendDataOffset(0)
114 , m_appendBufferAsyncPartRunner(this, &SourceBuffer::appendBufferAsyncPart) 114 , m_appendBufferAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this , &SourceBuffer::appendBufferAsyncPart))
115 , m_pendingRemoveStart(-1) 115 , m_pendingRemoveStart(-1)
116 , m_pendingRemoveEnd(-1) 116 , m_pendingRemoveEnd(-1)
117 , m_removeAsyncPartRunner(this, &SourceBuffer::removeAsyncPart) 117 , m_removeAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this, &Sou rceBuffer::removeAsyncPart))
118 , m_streamMaxSizeValid(false) 118 , m_streamMaxSizeValid(false)
119 , m_streamMaxSize(0) 119 , m_streamMaxSize(0)
120 , m_appendStreamAsyncPartRunner(this, &SourceBuffer::appendStreamAsyncPart) 120 , m_appendStreamAsyncPartRunner(AsyncMethodRunner<SourceBuffer>::create(this , &SourceBuffer::appendStreamAsyncPart))
121 { 121 {
122 ASSERT(m_webSourceBuffer); 122 ASSERT(m_webSourceBuffer);
123 ASSERT(m_source); 123 ASSERT(m_source);
124 m_webSourceBuffer->setClient(this); 124 m_webSourceBuffer->setClient(this);
125 } 125 }
126 126
127 SourceBuffer::~SourceBuffer() 127 SourceBuffer::~SourceBuffer()
128 { 128 {
129 // Oilpan: a SourceBuffer might be finalized without having been 129 // Oilpan: a SourceBuffer might be finalized without having been
130 // explicitly removed first, hence the asserts below will not 130 // explicitly removed first, hence the asserts below will not
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // 7. Run the range removal algorithm with start and end as the start and en d of the removal range. 387 // 7. Run the range removal algorithm with start and end as the start and en d of the removal range.
388 // 7.3. Set the updating attribute to true. 388 // 7.3. Set the updating attribute to true.
389 m_updating = true; 389 m_updating = true;
390 390
391 // 7.4. Queue a task to fire a simple event named updatestart at this Source Buffer object. 391 // 7.4. Queue a task to fire a simple event named updatestart at this Source Buffer object.
392 scheduleEvent(EventTypeNames::updatestart); 392 scheduleEvent(EventTypeNames::updatestart);
393 393
394 // 7.5. Return control to the caller and run the rest of the steps asynchron ously. 394 // 7.5. Return control to the caller and run the rest of the steps asynchron ously.
395 m_pendingRemoveStart = start; 395 m_pendingRemoveStart = start;
396 m_pendingRemoveEnd = end; 396 m_pendingRemoveEnd = end;
397 m_removeAsyncPartRunner.runAsync(); 397 m_removeAsyncPartRunner->runAsync();
398 } 398 }
399 399
400 void SourceBuffer::setTrackDefaults(TrackDefaultList* trackDefaults, ExceptionSt ate& exceptionState) 400 void SourceBuffer::setTrackDefaults(TrackDefaultList* trackDefaults, ExceptionSt ate& exceptionState)
401 { 401 {
402 // Per 02 Dec 2014 Editor's Draft 402 // Per 02 Dec 2014 Editor's Draft
403 // http://w3c.github.io/media-source/#widl-SourceBuffer-trackDefaults 403 // http://w3c.github.io/media-source/#widl-SourceBuffer-trackDefaults
404 // 1. If this object has been removed from the sourceBuffers attribute of 404 // 1. If this object has been removed from the sourceBuffers attribute of
405 // the parent media source, then throw an InvalidStateError exception 405 // the parent media source, then throw an InvalidStateError exception
406 // and abort these steps. 406 // and abort these steps.
407 // 2. If the updating attribute equals true, then throw an InvalidStateError 407 // 2. If the updating attribute equals true, then throw an InvalidStateError
(...skipping 18 matching lines...) Expand all
426 traceEventName = "SourceBuffer::appendBuffer"; 426 traceEventName = "SourceBuffer::appendBuffer";
427 } else if (m_stream) { 427 } else if (m_stream) {
428 traceEventName = "SourceBuffer::appendStream"; 428 traceEventName = "SourceBuffer::appendStream";
429 } else if (m_pendingRemoveStart != -1) { 429 } else if (m_pendingRemoveStart != -1) {
430 traceEventName = "SourceBuffer::remove"; 430 traceEventName = "SourceBuffer::remove";
431 } else { 431 } else {
432 ASSERT_NOT_REACHED(); 432 ASSERT_NOT_REACHED();
433 } 433 }
434 434
435 // 3.1. Abort the buffer append and stream append loop algorithms if they ar e running. 435 // 3.1. Abort the buffer append and stream append loop algorithms if they ar e running.
436 m_appendBufferAsyncPartRunner.stop(); 436 m_appendBufferAsyncPartRunner->stop();
437 m_pendingAppendData.clear(); 437 m_pendingAppendData.clear();
438 m_pendingAppendDataOffset = 0; 438 m_pendingAppendDataOffset = 0;
439 439
440 m_removeAsyncPartRunner.stop(); 440 m_removeAsyncPartRunner->stop();
441 m_pendingRemoveStart = -1; 441 m_pendingRemoveStart = -1;
442 m_pendingRemoveEnd = -1; 442 m_pendingRemoveEnd = -1;
443 443
444 m_appendStreamAsyncPartRunner.stop(); 444 m_appendStreamAsyncPartRunner->stop();
445 clearAppendStreamState(); 445 clearAppendStreamState();
446 446
447 // 3.2. Set the updating attribute to false. 447 // 3.2. Set the updating attribute to false.
448 m_updating = false; 448 m_updating = false;
449 449
450 // 3.3. Queue a task to fire a simple event named abort at this SourceBuffer object. 450 // 3.3. Queue a task to fire a simple event named abort at this SourceBuffer object.
451 scheduleEvent(EventTypeNames::abort); 451 scheduleEvent(EventTypeNames::abort);
452 452
453 // 3.4. Queue a task to fire a simple event named updateend at this SourceBu ffer object. 453 // 3.4. Queue a task to fire a simple event named updateend at this SourceBu ffer object.
454 scheduleEvent(EventTypeNames::updateend); 454 scheduleEvent(EventTypeNames::updateend);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 } 494 }
495 } 495 }
496 496
497 bool SourceBuffer::hasPendingActivity() const 497 bool SourceBuffer::hasPendingActivity() const
498 { 498 {
499 return m_source; 499 return m_source;
500 } 500 }
501 501
502 void SourceBuffer::suspend() 502 void SourceBuffer::suspend()
503 { 503 {
504 m_appendBufferAsyncPartRunner.suspend(); 504 m_appendBufferAsyncPartRunner->suspend();
505 m_removeAsyncPartRunner.suspend(); 505 m_removeAsyncPartRunner->suspend();
506 m_appendStreamAsyncPartRunner.suspend(); 506 m_appendStreamAsyncPartRunner->suspend();
507 } 507 }
508 508
509 void SourceBuffer::resume() 509 void SourceBuffer::resume()
510 { 510 {
511 m_appendBufferAsyncPartRunner.resume(); 511 m_appendBufferAsyncPartRunner->resume();
512 m_removeAsyncPartRunner.resume(); 512 m_removeAsyncPartRunner->resume();
513 m_appendStreamAsyncPartRunner.resume(); 513 m_appendStreamAsyncPartRunner->resume();
514 } 514 }
515 515
516 void SourceBuffer::stop() 516 void SourceBuffer::stop()
517 { 517 {
518 m_appendBufferAsyncPartRunner.stop(); 518 m_appendBufferAsyncPartRunner->stop();
519 m_removeAsyncPartRunner.stop(); 519 m_removeAsyncPartRunner->stop();
520 m_appendStreamAsyncPartRunner.stop(); 520 m_appendStreamAsyncPartRunner->stop();
521 } 521 }
522 522
523 ExecutionContext* SourceBuffer::executionContext() const 523 ExecutionContext* SourceBuffer::executionContext() const
524 { 524 {
525 return ActiveDOMObject::executionContext(); 525 return ActiveDOMObject::executionContext();
526 } 526 }
527 527
528 const AtomicString& SourceBuffer::interfaceName() const 528 const AtomicString& SourceBuffer::interfaceName() const
529 { 529 {
530 return EventTargetNames::SourceBuffer; 530 return EventTargetNames::SourceBuffer;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 m_pendingAppendData.append(data, size); 615 m_pendingAppendData.append(data, size);
616 m_pendingAppendDataOffset = 0; 616 m_pendingAppendDataOffset = 0;
617 617
618 // 3. Set the updating attribute to true. 618 // 3. Set the updating attribute to true.
619 m_updating = true; 619 m_updating = true;
620 620
621 // 4. Queue a task to fire a simple event named updatestart at this SourceBu ffer object. 621 // 4. Queue a task to fire a simple event named updatestart at this SourceBu ffer object.
622 scheduleEvent(EventTypeNames::updatestart); 622 scheduleEvent(EventTypeNames::updatestart);
623 623
624 // 5. Asynchronously run the buffer append algorithm. 624 // 5. Asynchronously run the buffer append algorithm.
625 m_appendBufferAsyncPartRunner.runAsync(); 625 m_appendBufferAsyncPartRunner->runAsync();
626 626
627 TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendBuffer", this, "i nitialDelay"); 627 TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendBuffer", this, "i nitialDelay");
628 } 628 }
629 629
630 void SourceBuffer::appendBufferAsyncPart() 630 void SourceBuffer::appendBufferAsyncPart()
631 { 631 {
632 ASSERT(m_updating); 632 ASSERT(m_updating);
633 633
634 // Section 3.5.4 Buffer Append Algorithm 634 // Section 3.5.4 Buffer Append Algorithm
635 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#sourcebuffer-buffer-append 635 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#sourcebuffer-buffer-append
(...skipping 20 matching lines...) Expand all
656 unsigned char zero = 0; 656 unsigned char zero = 0;
657 unsigned char* appendData = &zero; 657 unsigned char* appendData = &zero;
658 if (appendSize) 658 if (appendSize)
659 appendData = m_pendingAppendData.data() + m_pendingAppendDataOffset; 659 appendData = m_pendingAppendData.data() + m_pendingAppendDataOffset;
660 660
661 m_webSourceBuffer->append(appendData, appendSize, &m_timestampOffset); 661 m_webSourceBuffer->append(appendData, appendSize, &m_timestampOffset);
662 662
663 m_pendingAppendDataOffset += appendSize; 663 m_pendingAppendDataOffset += appendSize;
664 664
665 if (m_pendingAppendDataOffset < m_pendingAppendData.size()) { 665 if (m_pendingAppendDataOffset < m_pendingAppendData.size()) {
666 m_appendBufferAsyncPartRunner.runAsync(); 666 m_appendBufferAsyncPartRunner->runAsync();
667 TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendBuffer", this , "nextPieceDelay"); 667 TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendBuffer", this , "nextPieceDelay");
668 return; 668 return;
669 } 669 }
670 670
671 // 3. Set the updating attribute to false. 671 // 3. Set the updating attribute to false.
672 m_updating = false; 672 m_updating = false;
673 m_pendingAppendData.clear(); 673 m_pendingAppendData.clear();
674 m_pendingAppendDataOffset = 0; 674 m_pendingAppendDataOffset = 0;
675 675
676 // 4. Queue a task to fire a simple event named update at this SourceBuffer object. 676 // 4. Queue a task to fire a simple event named update at this SourceBuffer object.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 // 2. Set the updating attribute to true. 729 // 2. Set the updating attribute to true.
730 m_updating = true; 730 m_updating = true;
731 731
732 // 3. Queue a task to fire a simple event named updatestart at this SourceBu ffer object. 732 // 3. Queue a task to fire a simple event named updatestart at this SourceBu ffer object.
733 scheduleEvent(EventTypeNames::updatestart); 733 scheduleEvent(EventTypeNames::updatestart);
734 734
735 // 4. Asynchronously run the stream append loop algorithm with stream and ma xSize. 735 // 4. Asynchronously run the stream append loop algorithm with stream and ma xSize.
736 stream->neuter(); 736 stream->neuter();
737 m_loader = FileReaderLoader::create(FileReaderLoader::ReadByClient, this); 737 m_loader = FileReaderLoader::create(FileReaderLoader::ReadByClient, this);
738 m_stream = stream; 738 m_stream = stream;
739 m_appendStreamAsyncPartRunner.runAsync(); 739 m_appendStreamAsyncPartRunner->runAsync();
740 } 740 }
741 741
742 void SourceBuffer::appendStreamAsyncPart() 742 void SourceBuffer::appendStreamAsyncPart()
743 { 743 {
744 ASSERT(m_updating); 744 ASSERT(m_updating);
745 ASSERT(m_loader); 745 ASSERT(m_loader);
746 ASSERT(m_stream); 746 ASSERT(m_stream);
747 TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendStream", this, "a ppendStreamAsyncPart"); 747 TRACE_EVENT_ASYNC_STEP_INTO0("media", "SourceBuffer::appendStream", this, "a ppendStreamAsyncPart");
748 748
749 // Section 3.5.6 Stream Append Loop 749 // Section 3.5.6 Stream Append Loop
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 // m_loader might be already released, in case appendStream has failed due 859 // m_loader might be already released, in case appendStream has failed due
860 // to evictCodedFrames failing in didReceiveDataForClient. In that case 860 // to evictCodedFrames failing in didReceiveDataForClient. In that case
861 // appendStreamDone will be invoked from there, no need to repeat it here. 861 // appendStreamDone will be invoked from there, no need to repeat it here.
862 if (m_loader) 862 if (m_loader)
863 appendStreamDone(false); 863 appendStreamDone(false);
864 } 864 }
865 865
866 DEFINE_TRACE(SourceBuffer) 866 DEFINE_TRACE(SourceBuffer)
867 { 867 {
868 visitor->trace(m_source); 868 visitor->trace(m_source);
869 visitor->trace(m_stream);
870 visitor->trace(m_trackDefaults); 869 visitor->trace(m_trackDefaults);
871 visitor->trace(m_asyncEventQueue); 870 visitor->trace(m_asyncEventQueue);
871 visitor->trace(m_appendBufferAsyncPartRunner);
872 visitor->trace(m_removeAsyncPartRunner);
873 visitor->trace(m_appendStreamAsyncPartRunner);
874 visitor->trace(m_stream);
872 RefCountedGarbageCollectedEventTargetWithInlineData<SourceBuffer>::trace(vis itor); 875 RefCountedGarbageCollectedEventTargetWithInlineData<SourceBuffer>::trace(vis itor);
873 ActiveDOMObject::trace(visitor); 876 ActiveDOMObject::trace(visitor);
874 } 877 }
875 878
876 } // namespace blink 879 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698