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

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

Line-by-line coverage:

   1    :  // Copyright 2012 Google Inc.
   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    :  // This file declares the BufferConsumer and BufferConsumerFactory interfaces.
  16    :  
  17    :  #ifndef SYZYGY_TRACE_SERVICE_BUFFER_CONSUMER_H_
  18    :  #define SYZYGY_TRACE_SERVICE_BUFFER_CONSUMER_H_
  19    :  
  20    :  #include "base/memory/ref_counted.h"
  21    :  
  22    :  // Forward declarations.
  23    :  class FilePath;
  24    :  
  25    :  namespace trace {
  26    :  namespace service {
  27    :  
  28    :  // Forward declarations.
  29    :  struct Buffer;
  30    :  class Service;
  31    :  class Session;
  32    :  
  33    :  // This class defines the interface the writer thread expects a session's
  34    :  // buffer consumer to support. This interface is reference counted because
  35    :  // a given BufferConsumerFactory (see below) is not obligated to hand out a
  36    :  // new BufferConsumer instance on each request. Where appropriate, a single
  37    :  // consumer may be shared by multiple sessions.
  38    :  class BufferConsumer : public base::RefCountedThreadSafe<BufferConsumer> {
  39    :   public:
  40    :    // Open this consumer for the given session. This affords the buffer
  41    :    // consumer the opportunity to perform any per-session initialization
  42    :    // it requires.
  43    :    virtual bool Open(Session* session) = 0;
  44    :  
  45    :    // Inform the BufferConsumer to that this session will no longer be
  46    :    // generating buffers to consume. This affords the buffer consumer the
  47    :    // opportunity to perform and per-session cleanup it requires. After
  48    :    // calling this, the session MUST release all references it holds to the
  49    :    // BufferConsumer. The session should not call this until there are no
  50    :    // outstanding buffers being held by the consumer (see ConsumeBuffer()).
  51    :    virtual bool Close(Session* session) = 0;
  52    :  
  53    :    // Consume the given buffer. The session that owns the buffer will be
  54    :    // notified when the consumption has completed via a call to
  55    :    // Session::RecycleBuffer();
  56    :    virtual bool ConsumeBuffer(Buffer* buffer) = 0;
  57    :  
  58    :    // Get the block size used when consuming buffers. The buffer consumer will
  59    :    // expect that buffers are sized as a multiple of the block size.
  60    :    virtual size_t block_size() const = 0;
  61    :  
  62    :   protected:
  63  E :    virtual ~BufferConsumer() = 0 {}
  64    :    friend class base::RefCountedThreadSafe<BufferConsumer>;
  65    :  };
  66    :  
  67    :  // This class defines the interface the call trace service uses to create
  68    :  // and manage buffer consumers when sessions are instantiated.
  69    :  class BufferConsumerFactory {
  70    :   public:
  71    :    // Creates a new consumer.
  72    :    virtual bool CreateConsumer(scoped_refptr<BufferConsumer>* consumer) = 0;
  73    :  };
  74    :  
  75    :  }  // namespace service
  76    :  }  // namespace trace
  77    :  
  78    :  #endif  // SYZYGY_TRACE_SERVICE_BUFFER_CONSUMER_H_

Coverage information generated Thu Sep 06 11:30:46 2012.