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

Coverage information generated Thu Jul 04 09:34:53 2013.