LCOV - code coverage report
Current view: top level - dom/file - BlobSet.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 23 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "mozilla/dom/BlobSet.h"
       8             : #include "mozilla/CheckedInt.h"
       9             : #include "mozilla/dom/File.h"
      10             : #include "MemoryBlobImpl.h"
      11             : #include "MultipartBlobImpl.h"
      12             : 
      13             : namespace mozilla {
      14             : namespace dom {
      15             : 
      16             : nsresult
      17           0 : BlobSet::AppendVoidPtr(const void* aData, uint32_t aLength)
      18             : {
      19           0 :   NS_ENSURE_ARG_POINTER(aData);
      20           0 :   if (!aLength) {
      21           0 :     return NS_OK;
      22             :   }
      23             : 
      24           0 :   void* data = malloc(aLength);
      25           0 :   if (!data) {
      26           0 :     return NS_ERROR_OUT_OF_MEMORY;
      27             :   }
      28             : 
      29           0 :   memcpy((char*)data, aData, aLength);
      30             : 
      31           0 :   RefPtr<BlobImpl> blobImpl = new MemoryBlobImpl(data, aLength, EmptyString());
      32           0 :   mBlobImpls.AppendElement(blobImpl);
      33             : 
      34           0 :   return NS_OK;
      35             : }
      36             : 
      37             : nsresult
      38           0 : BlobSet::AppendString(const nsAString& aString, bool nativeEOL)
      39             : {
      40           0 :   nsCString utf8Str = NS_ConvertUTF16toUTF8(aString);
      41             : 
      42           0 :   if (nativeEOL) {
      43           0 :     if (utf8Str.Contains('\r')) {
      44           0 :       utf8Str.ReplaceSubstring("\r\n", "\n");
      45           0 :       utf8Str.ReplaceSubstring("\r", "\n");
      46             :     }
      47             : #ifdef XP_WIN
      48             :     utf8Str.ReplaceSubstring("\n", "\r\n");
      49             : #endif
      50             :   }
      51             : 
      52             :   RefPtr<StringBlobImpl> blobImpl =
      53           0 :     StringBlobImpl::Create(utf8Str, EmptyString());
      54           0 :   return AppendBlobImpl(blobImpl);
      55             : }
      56             : 
      57             : nsresult
      58           0 : BlobSet::AppendBlobImpl(BlobImpl* aBlobImpl)
      59             : {
      60           0 :   NS_ENSURE_ARG_POINTER(aBlobImpl);
      61           0 :   mBlobImpls.AppendElement(aBlobImpl);
      62           0 :   return NS_OK;
      63             : }
      64             : 
      65             : } // dom namespace
      66             : } // mozilla namespace

Generated by: LCOV version 1.13