Coverage for /Syzygy/kasko/dll_lifetime.cc

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

Line-by-line coverage:

   1    :  // Copyright 2015 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    :  #include "syzygy/kasko/dll_lifetime.h"
  16    :  
  17    :  #include "base/at_exit.h"
  18    :  #include "base/logging_win.h"
  19    :  
  20    :  namespace kasko {
  21    :  
  22    :  class DllLifetime::Core : public base::RefCounted<DllLifetime::Core> {
  23    :   public:
  24    :    // Returns a reference to the single Core instance, creating it if necessary.
  25    :    static scoped_refptr<Core> Get();
  26    :  
  27    :   private:
  28    :    friend class base::RefCounted<Core>;
  29    :  
  30    :    Core();
  31    :    ~Core();
  32    :  
  33    :    // The exit manager is in charge of calling the dtors of singletons.
  34    :    base::AtExitManager exit_manager_;
  35    :  
  36    :    // The single Core instance.
  37    :    static Core* instance_;
  38    :  
  39    :    DISALLOW_COPY_AND_ASSIGN(Core);
  40    :  };
  41    :  
  42    :  DllLifetime::Core* DllLifetime::Core::instance_ = nullptr;
  43    :  
  44    :  namespace {
  45    :  // Use the same log facility as Chrome for convenience.
  46    :  // {3A8A3990-64BC-4143-AEAF-0AA1A0123BCB}
  47    :  static const GUID kKaskoTraceProviderName = {
  48    :      0x3a8a3990,
  49    :      0x64bc,
  50    :      0x4143,
  51    :      {0xae, 0xaf, 0xa, 0xa1, 0xa0, 0x12, 0x3b, 0xcb}};
  52    :  }  // namespace
  53    :  
  54  E :  DllLifetime::DllLifetime() : core_(DllLifetime::Core::Get()) {
  55  E :  }
  56    :  
  57  E :  DllLifetime::~DllLifetime() {
  58  E :  }
  59    :  
  60    :  // static
  61  E :  scoped_refptr<DllLifetime::Core> DllLifetime::Core::Get() {
  62  E :    if (!instance_)
  63  E :      instance_ = new Core();
  64  E :    return scoped_refptr<Core>(instance_);
  65  E :  }
  66    :  
  67  E :  DllLifetime::Core::Core() {
  68  E :    logging::LogEventProvider::Initialize(kKaskoTraceProviderName);
  69  E :  }
  70    :  
  71  E :  DllLifetime::Core::~Core() {
  72  E :    logging::LogEventProvider::Uninitialize();
  73  E :    DCHECK_EQ(this, instance_);
  74  E :    instance_ = nullptr;
  75  E :  }
  76    :  
  77    :  }  // namespace kasko

Coverage information generated Thu Jan 14 17:40:38 2016.