private void OnDownloadProcessing(HTTPRequest request, HTTPResponse response) { Debug.Assert(response != null); Debug.Log("Processing request from " + request.Uri.AbsoluteUri); RemoteFileFragmentMetadata fragmentMetadata = m_RemoteFileMetadata.GetFileFragmentDataFromUri(request.Uri.AbsoluteUri); Debug.Log("Fragment index: " + fragmentMetadata.index); lock (fragmentMetadata) { if (!response.HasStreamedFragments()) { return; } List <byte[]> fragmentBytesList = response.GetStreamedFragments(); //if (lastDownloadedURI == request.Uri.AbsoluteUri) { // Debug.LogWarning("Download callback called twice in a row -- ignoring the second one"); // return; //} if (fragmentBytesList == null) { return; } for (int i = 0; i < fragmentBytesList.Count; ++i) { byte[] fragmentBytes = fragmentBytesList[i]; int offset = m_RemoteFileMetadata.GetFileFragmentMemoryOffset(fragmentMetadata) + (int)fragmentMetadata.GetDownloadedBytes(); int length = fragmentBytes.Length; Debug.Log("Copying " + length + " bytes at offset " + offset); CopyDownloadedFragment(offset, length, ref fragmentBytes); fragmentMetadata.AddDownloadedBytes(length); Interlocked.Add(ref mDownloadedContentSize, length); Debug.Log("Downloaded content size: " + mDownloadedContentSize + " / " + mContentSize); } fragmentMetadata.ProcessGetResponse(response); } lastDownloadedURI = request.Uri.AbsoluteUri; // for error checking }