Coverage for /Syzygy/trace/service/trace_file_writer_factory.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
88.9%16180.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 implements the TraceFileWriter and TraceFileWriterFactory classes
  16    :  // which provide an implementation and factory, respectively, for the default
  17    :  // buffer consumer used by the call trace service.
  18    :  
  19    :  #include "syzygy/trace/service/trace_file_writer_factory.h"
  20    :  
  21    :  #include <time.h>
  22    :  
  23    :  #include "base/atomicops.h"
  24    :  #include "base/bind.h"
  25    :  #include "base/file_util.h"
  26    :  #include "base/logging.h"
  27    :  #include "base/message_loop.h"
  28    :  #include "base/stringprintf.h"
  29    :  #include "base/files/file_path.h"
  30    :  #include "base/memory/scoped_ptr.h"
  31    :  #include "sawbuck/common/com_utils.h"
  32    :  #include "syzygy/common/align.h"
  33    :  #include "syzygy/common/buffer_writer.h"
  34    :  #include "syzygy/common/path_util.h"
  35    :  #include "syzygy/trace/protocol/call_trace_defs.h"
  36    :  #include "syzygy/trace/service/buffer_pool.h"
  37    :  #include "syzygy/trace/service/session.h"
  38    :  #include "syzygy/trace/service/trace_file_writer.h"
  39    :  
  40    :  namespace trace {
  41    :  namespace service {
  42    :  
  43    :  TraceFileWriterFactory::TraceFileWriterFactory(base::MessageLoop* message_loop)
  44  E :      : message_loop_(message_loop), trace_file_directory_(L".") {
  45  E :    DCHECK(message_loop != NULL);
  46  E :    DCHECK_EQ(base::MessageLoop::TYPE_IO, message_loop->type());
  47  E :  }
  48    :  
  49  E :  bool TraceFileWriterFactory::SetTraceFileDirectory(const base::FilePath& path) {
  50  E :    DCHECK(!path.empty());
  51  E :    if (!file_util::CreateDirectory(path)) {
  52  i :      LOG(ERROR) << "Failed to create trace file directory '" << path.value()
  53    :                 << "'.";
  54  i :      return false;
  55    :    }
  56    :  
  57  E :    trace_file_directory_ = path;
  58  E :    return true;
  59  E :  }
  60    :  
  61    :  bool TraceFileWriterFactory::CreateConsumer(
  62  E :      scoped_refptr<BufferConsumer>* consumer) {
  63  E :    DCHECK(consumer != NULL);
  64  E :    DCHECK(message_loop_ != NULL);
  65    :  
  66    :    // Allocate a new trace file writer.
  67  E :    *consumer = new TraceFileWriter(message_loop_, trace_file_directory_);
  68  E :    return true;
  69  E :  }
  70    :  
  71    :  }  // namespace service
  72    :  }  // namespace trace

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