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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* vim: set sw=4 ts=8 et 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/devtools/HeapSnapshot.h"
       8             : #include "mozilla/devtools/HeapSnapshotTempFileHelperParent.h"
       9             : #include "mozilla/ErrorResult.h"
      10             : #include "private/pprio.h"
      11             : 
      12             : #include "nsIFile.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace devtools {
      16             : 
      17             : using ipc::FileDescriptor;
      18             : 
      19             : static bool
      20           0 : openFileFailure(ErrorResult& rv,
      21             :                 OpenHeapSnapshotTempFileResponse* outResponse)
      22             : {
      23           0 :     *outResponse = rv.StealNSResult();
      24           0 :     return true;
      25             : }
      26             : 
      27             : mozilla::ipc::IPCResult
      28           0 : HeapSnapshotTempFileHelperParent::RecvOpenHeapSnapshotTempFile(
      29             :     OpenHeapSnapshotTempFileResponse* outResponse)
      30             : {
      31           0 :     auto start = TimeStamp::Now();
      32           0 :     ErrorResult rv;
      33           0 :     nsAutoString filePath;
      34           0 :     nsAutoString snapshotId;
      35           0 :     nsCOMPtr<nsIFile> file = HeapSnapshot::CreateUniqueCoreDumpFile(rv,
      36             :                                                                     start,
      37             :                                                                     filePath,
      38           0 :                                                                     snapshotId);
      39           0 :     if (NS_WARN_IF(rv.Failed())) {
      40           0 :         if (!openFileFailure(rv, outResponse)) {
      41           0 :           return IPC_FAIL_NO_REASON(this);
      42             :         }
      43           0 :         return IPC_OK();
      44             :     }
      45             : 
      46             :     PRFileDesc* prfd;
      47           0 :     rv = file->OpenNSPRFileDesc(PR_WRONLY, 0, &prfd);
      48           0 :     if (NS_WARN_IF(rv.Failed())) {
      49           0 :         if (!openFileFailure(rv, outResponse)) {
      50           0 :           return IPC_FAIL_NO_REASON(this);
      51             :         }
      52           0 :         return IPC_OK();
      53             :     }
      54             : 
      55             :     FileDescriptor::PlatformHandleType handle =
      56           0 :         FileDescriptor::PlatformHandleType(PR_FileDesc2NativeHandle(prfd));
      57           0 :     FileDescriptor fd(handle);
      58           0 :     *outResponse = OpenedFile(filePath, snapshotId, fd);
      59           0 :     return IPC_OK();
      60             : }
      61             : 
      62             : } // namespace devtools
      63             : } // namespace mozilla

Generated by: LCOV version 1.13