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

Side by Side Diff: base/posix/global_descriptors.h

Issue 196343019: IPC: Make ipc_perftests run on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 9 months 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
« no previous file with comments | « no previous file | base/test/multiprocess_test_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #ifndef BASE_POSIX_GLOBAL_DESCRIPTORS_H_ 5 #ifndef BASE_POSIX_GLOBAL_DESCRIPTORS_H_
6 #define BASE_POSIX_GLOBAL_DESCRIPTORS_H_ 6 #define BASE_POSIX_GLOBAL_DESCRIPTORS_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #include <vector> 10 #include <vector>
(...skipping 23 matching lines...) Expand all
34 // need to define keys, then values should be chosen randomly so as not to 34 // need to define keys, then values should be chosen randomly so as not to
35 // collide. 35 // collide.
36 class BASE_EXPORT GlobalDescriptors { 36 class BASE_EXPORT GlobalDescriptors {
37 public: 37 public:
38 typedef uint32_t Key; 38 typedef uint32_t Key;
39 typedef std::pair<Key, int> KeyFDPair; 39 typedef std::pair<Key, int> KeyFDPair;
40 typedef std::vector<KeyFDPair> Mapping; 40 typedef std::vector<KeyFDPair> Mapping;
41 41
42 // Often we want a canonical descriptor for a given Key. In this case, we add 42 // Often we want a canonical descriptor for a given Key. In this case, we add
43 // the following constant to the key value: 43 // the following constant to the key value:
44 #if !defined(OS_ANDROID)
44 static const int kBaseDescriptor = 3; // 0, 1, 2 are already taken. 45 static const int kBaseDescriptor = 3; // 0, 1, 2 are already taken.
46 #else
47 static const int kBaseDescriptor = 4; // 3 used by __android_log_write().
48 #endif
45 49
46 // Return the singleton instance of GlobalDescriptors. 50 // Return the singleton instance of GlobalDescriptors.
47 static GlobalDescriptors* GetInstance(); 51 static GlobalDescriptors* GetInstance();
48 52
49 // Get a descriptor given a key. It is a fatal error if the key is not known. 53 // Get a descriptor given a key. It is a fatal error if the key is not known.
50 int Get(Key key) const; 54 int Get(Key key) const;
51 55
52 // Get a descriptor give a key. Returns -1 on error. 56 // Get a descriptor give a key. Returns -1 on error.
53 int MaybeGet(Key key) const; 57 int MaybeGet(Key key) const;
54 58
55 // Set the descriptor for the given key. 59 // Set the descriptor for the given key.
56 void Set(Key key, int fd); 60 void Set(Key key, int fd);
57 61
58 void Reset(const Mapping& mapping); 62 void Reset(const Mapping& mapping);
59 63
60 private: 64 private:
61 friend struct DefaultSingletonTraits<GlobalDescriptors>; 65 friend struct DefaultSingletonTraits<GlobalDescriptors>;
62 GlobalDescriptors(); 66 GlobalDescriptors();
63 ~GlobalDescriptors(); 67 ~GlobalDescriptors();
64 68
65 Mapping descriptors_; 69 Mapping descriptors_;
66 }; 70 };
67 71
68 } // namespace base 72 } // namespace base
69 73
70 #endif // BASE_POSIX_GLOBAL_DESCRIPTORS_H_ 74 #endif // BASE_POSIX_GLOBAL_DESCRIPTORS_H_
OLDNEW
« no previous file with comments | « no previous file | base/test/multiprocess_test_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698