Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: base/global_descriptors_posix.cc

Issue 11293210: Move global_descriptors to base/posix. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/global_descriptors_posix.h ('k') | base/posix/global_descriptors.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/global_descriptors_posix.h"
6
7 #include <vector>
8 #include <utility>
9
10 #include "base/logging.h"
11
12 namespace base {
13
14 // static
15 GlobalDescriptors* GlobalDescriptors::GetInstance() {
16 typedef Singleton<base::GlobalDescriptors,
17 LeakySingletonTraits<base::GlobalDescriptors> >
18 GlobalDescriptorsSingleton;
19 return GlobalDescriptorsSingleton::get();
20 }
21
22 int GlobalDescriptors::Get(Key key) const {
23 const int ret = MaybeGet(key);
24
25 if (ret == -1)
26 DLOG(FATAL) << "Unknown global descriptor: " << key;
27 return ret;
28 }
29
30 int GlobalDescriptors::MaybeGet(Key key) const {
31 for (Mapping::const_iterator
32 i = descriptors_.begin(); i != descriptors_.end(); ++i) {
33 if (i->first == key)
34 return i->second;
35 }
36
37 return -1;
38 }
39
40 void GlobalDescriptors::Set(Key key, int fd) {
41 for (Mapping::iterator
42 i = descriptors_.begin(); i != descriptors_.end(); ++i) {
43 if (i->first == key) {
44 i->second = fd;
45 return;
46 }
47 }
48
49 descriptors_.push_back(std::make_pair(key, fd));
50 }
51
52 void GlobalDescriptors::Reset(const Mapping& mapping) {
53 descriptors_ = mapping;
54 }
55
56 GlobalDescriptors::GlobalDescriptors() {}
57
58 GlobalDescriptors::~GlobalDescriptors() {}
59
60 } // namespace base
OLDNEW
« no previous file with comments | « base/global_descriptors_posix.h ('k') | base/posix/global_descriptors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698