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

Side by Side Diff: Source/wtf/ArrayBuffer.cpp

Issue 20804003: Re-land: Ensure that ArrayBuffers actively being used by the Web Audio API cannot be neutered (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/webaudio/AudioBuffer.cpp ('k') | Source/wtf/ArrayBufferContents.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 25 matching lines...) Expand all
36 36
37 bool ArrayBuffer::transfer(ArrayBufferContents& result, Vector<RefPtr<ArrayBuffe rView> >& neuteredViews) 37 bool ArrayBuffer::transfer(ArrayBufferContents& result, Vector<RefPtr<ArrayBuffe rView> >& neuteredViews)
38 { 38 {
39 RefPtr<ArrayBuffer> keepAlive(this); 39 RefPtr<ArrayBuffer> keepAlive(this);
40 40
41 if (!m_contents.data()) { 41 if (!m_contents.data()) {
42 result.clear(); 42 result.clear();
43 return false; 43 return false;
44 } 44 }
45 45
46 m_contents.transfer(result); 46 bool allViewsAreNeuterable = true;
47 for (ArrayBufferView* i = m_firstView; i; i = i->m_nextView) {
48 if (!i->isNeuterable())
49 allViewsAreNeuterable = false;
50 }
51
52 if (allViewsAreNeuterable) {
53 m_contents.transfer(result);
54 } else {
55 m_contents.copyTo(result);
56 if (!result.data())
57 return false;
58 }
47 59
48 while (m_firstView) { 60 while (m_firstView) {
49 ArrayBufferView* current = m_firstView; 61 ArrayBufferView* current = m_firstView;
50 removeView(current); 62 removeView(current);
51 current->neuter(); 63 if (allViewsAreNeuterable || current->isNeuterable())
64 current->neuter();
52 neuteredViews.append(current); 65 neuteredViews.append(current);
53 } 66 }
54 67
55 m_isNeutered = true; 68 m_isNeutered = true;
56 69
57 return true; 70 return true;
58 } 71 }
59 72
60 void ArrayBuffer::addView(ArrayBufferView* view) 73 void ArrayBuffer::addView(ArrayBufferView* view)
61 { 74 {
(...skipping 11 matching lines...) Expand all
73 if (view->m_nextView) 86 if (view->m_nextView)
74 view->m_nextView->m_prevView = view->m_prevView; 87 view->m_nextView->m_prevView = view->m_prevView;
75 if (view->m_prevView) 88 if (view->m_prevView)
76 view->m_prevView->m_nextView = view->m_nextView; 89 view->m_prevView->m_nextView = view->m_nextView;
77 if (m_firstView == view) 90 if (m_firstView == view)
78 m_firstView = view->m_nextView; 91 m_firstView = view->m_nextView;
79 view->m_prevView = view->m_nextView = 0; 92 view->m_prevView = view->m_nextView = 0;
80 } 93 }
81 94
82 } 95 }
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioBuffer.cpp ('k') | Source/wtf/ArrayBufferContents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698