| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/global_descriptors_posix.h" | 5 #include "base/global_descriptors_posix.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 GlobalDescriptors* GlobalDescriptors::GetInstance() { | 15 GlobalDescriptors* GlobalDescriptors::GetInstance() { |
| 16 typedef Singleton<base::GlobalDescriptors, | 16 typedef Singleton<base::GlobalDescriptors, |
| 17 LeakySingletonTraits<base::GlobalDescriptors> > | 17 LeakySingletonTraits<base::GlobalDescriptors> > |
| 18 GlobalDescriptorsSingleton; | 18 GlobalDescriptorsSingleton; |
| 19 return GlobalDescriptorsSingleton::get(); | 19 return GlobalDescriptorsSingleton::get(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 int GlobalDescriptors::Get(Key key) const { | 22 int GlobalDescriptors::Get(Key key) const { |
| 23 const int ret = MaybeGet(key); | 23 const int ret = MaybeGet(key); |
| 24 | 24 |
| 25 if (ret == -1) | 25 if (ret == -1) |
| 26 DLOG(FATAL) << "Unknown global descriptor: " << key; | 26 LOG(FATAL) << "Unknown global descriptor: " << key; |
| 27 return ret; | 27 return ret; |
| 28 } | 28 } |
| 29 | 29 |
| 30 int GlobalDescriptors::MaybeGet(Key key) const { | 30 int GlobalDescriptors::MaybeGet(Key key) const { |
| 31 for (Mapping::const_iterator | 31 for (Mapping::const_iterator |
| 32 i = descriptors_.begin(); i != descriptors_.end(); ++i) { | 32 i = descriptors_.begin(); i != descriptors_.end(); ++i) { |
| 33 if (i->first == key) | 33 if (i->first == key) |
| 34 return i->second; | 34 return i->second; |
| 35 } | 35 } |
| 36 | 36 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 53 | 53 |
| 54 void GlobalDescriptors::Reset(const Mapping& mapping) { | 54 void GlobalDescriptors::Reset(const Mapping& mapping) { |
| 55 descriptors_ = mapping; | 55 descriptors_ = mapping; |
| 56 } | 56 } |
| 57 | 57 |
| 58 GlobalDescriptors::GlobalDescriptors() {} | 58 GlobalDescriptors::GlobalDescriptors() {} |
| 59 | 59 |
| 60 GlobalDescriptors::~GlobalDescriptors() {} | 60 GlobalDescriptors::~GlobalDescriptors() {} |
| 61 | 61 |
| 62 } // namespace base | 62 } // namespace base |
| OLD | NEW |