Coverage for /Syzygy/trace/service/mapped_buffer.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%880.C++source

Line-by-line coverage:

   1    :  // Copyright 2013 Google Inc. All Rights Reserved.
   2    :  //
   3    :  // Licensed under the Apache License, Version 2.0 (the "License");
   4    :  // you may not use this file except in compliance with the License.
   5    :  // You may obtain a copy of the License at
   6    :  //
   7    :  //     http://www.apache.org/licenses/LICENSE-2.0
   8    :  //
   9    :  // Unless required by applicable law or agreed to in writing, software
  10    :  // distributed under the License is distributed on an "AS IS" BASIS,
  11    :  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12    :  // See the License for the specific language governing permissions and
  13    :  // limitations under the License.
  14    :  //
  15    :  // Declares a utility class for mapping slices of shared files (buffers, from
  16    :  // the point of view of the call-trace service) into memory.
  17    :  
  18    :  #ifndef SYZYGY_TRACE_SERVICE_MAPPED_BUFFER_H_
  19    :  #define SYZYGY_TRACE_SERVICE_MAPPED_BUFFER_H_
  20    :  
  21    :  #include "base/logging.h"
  22    :  
  23    :  namespace trace {
  24    :  namespace service {
  25    :  
  26    :  // Forward declare.
  27    :  struct Buffer;
  28    :  
  29    :  // A utility class for creating a scoped on demand memory mapped view into a
  30    :  // shared file. Automatically unmaps the buffer when destroyed.
  31    :  class MappedBuffer {
  32    :   public:
  33    :    // Constructor.
  34    :    // @param buffer The buffer to be mapped.
  35  E :    explicit MappedBuffer(Buffer* buffer)
  36    :        : buffer_(buffer), base_(NULL), data_(NULL) {
  37  E :      DCHECK(buffer != NULL);
  38  E :    }
  39    :  
  40  E :    ~MappedBuffer() {
  41  E :      Unmap();
  42  E :    }
  43    :  
  44    :    // Maps the current buffer. Logs an error message on failure.
  45    :    // @returns true on success, false otherwise.
  46    :    bool Map();
  47    :  
  48    :    // Unmaps the current buffer. Logs an error message on failure.
  49    :    // @returns true on success, false otherwise.
  50    :    bool Unmap();
  51    :  
  52    :    // @returns true if the buffer is mapped, false otherwise.
  53  E :    bool IsMapped() const { return data_ != NULL; }
  54    :  
  55    :    // Returns a pointer to the mapped buffer data.
  56  E :    uint8* data() const { return data_; }
  57    :  
  58    :   protected:
  59    :    Buffer* buffer_;
  60    :    uint8* base_;
  61    :    uint8* data_;
  62    :  };
  63    :  
  64    :  }  // namespace service
  65    :  }  // namespace trace
  66    :  
  67    :  #endif  // SYZYGY_TRACE_SERVICE_MAPPED_BUFFER_H_

Coverage information generated Thu Mar 26 16:15:41 2015.