OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 APP_SURFACE_TRANSPORT_DIB_H_ | 5 #ifndef APP_SURFACE_TRANSPORT_DIB_H_ |
6 #define APP_SURFACE_TRANSPORT_DIB_H_ | 6 #define APP_SURFACE_TRANSPORT_DIB_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 | 9 |
10 #if defined(OS_WIN) || defined(OS_MACOSX) | 10 #if defined(OS_WIN) || defined(OS_MACOSX) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 | 67 |
68 HANDLE handle; | 68 HANDLE handle; |
69 uint32 sequence_num; | 69 uint32 sequence_num; |
70 }; | 70 }; |
71 typedef HandleAndSequenceNum Id; | 71 typedef HandleAndSequenceNum Id; |
72 | 72 |
73 // Returns a default, invalid handle, that is meant to indicate a missing | 73 // Returns a default, invalid handle, that is meant to indicate a missing |
74 // Transport DIB. | 74 // Transport DIB. |
75 static Handle DefaultHandleValue() { return NULL; } | 75 static Handle DefaultHandleValue() { return NULL; } |
| 76 |
| 77 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE |
| 78 // ACTUALLY USED AS A REAL HANDLE. |
| 79 static Handle GetFakeHandleForTest() { |
| 80 static int fake_handle = 10; |
| 81 return reinterpret_cast<Handle>(fake_handle++); |
| 82 } |
76 #elif defined(OS_MACOSX) | 83 #elif defined(OS_MACOSX) |
77 typedef base::SharedMemoryHandle Handle; | 84 typedef base::SharedMemoryHandle Handle; |
78 // On Mac, the inode number of the backing file is used as an id. | 85 // On Mac, the inode number of the backing file is used as an id. |
79 typedef base::SharedMemoryId Id; | 86 typedef base::SharedMemoryId Id; |
80 | 87 |
81 // Returns a default, invalid handle, that is meant to indicate a missing | 88 // Returns a default, invalid handle, that is meant to indicate a missing |
82 // Transport DIB. | 89 // Transport DIB. |
83 static Handle DefaultHandleValue() { return Handle(); } | 90 static Handle DefaultHandleValue() { return Handle(); } |
| 91 |
| 92 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE |
| 93 // ACTUALLY USED AS A REAL HANDLE. |
| 94 static Handle GetFakeHandleForTest() { |
| 95 static int fake_handle = 10; |
| 96 return Handle(fake_handle++, false); |
| 97 } |
84 #elif defined(USE_X11) | 98 #elif defined(USE_X11) |
85 typedef int Handle; // These two ints are SysV IPC shared memory keys | 99 typedef int Handle; // These two ints are SysV IPC shared memory keys |
86 typedef int Id; | 100 typedef int Id; |
87 | 101 |
88 // Returns a default, invalid handle, that is meant to indicate a missing | 102 // Returns a default, invalid handle, that is meant to indicate a missing |
89 // Transport DIB. | 103 // Transport DIB. |
90 static Handle DefaultHandleValue() { return -1; } | 104 static Handle DefaultHandleValue() { return -1; } |
| 105 |
| 106 // Returns a value that is ONLY USEFUL FOR TESTS WHERE IT WON'T BE |
| 107 // ACTUALLY USED AS A REAL HANDLE. |
| 108 static Handle GetFakeHandleForTest() { |
| 109 static int fake_handle = 10; |
| 110 return fake_handle++; |
| 111 } |
91 #endif | 112 #endif |
92 | 113 |
93 // Create a new TransportDIB, returning NULL on failure. | 114 // Create a new TransportDIB, returning NULL on failure. |
94 // | 115 // |
95 // The size is the minimum size in bytes of the memory backing the transport | 116 // The size is the minimum size in bytes of the memory backing the transport |
96 // DIB (we may actually allocate more than that to give us better reuse when | 117 // DIB (we may actually allocate more than that to give us better reuse when |
97 // cached). | 118 // cached). |
98 // | 119 // |
99 // The sequence number is used to uniquely identify the transport DIB. It | 120 // The sequence number is used to uniquely identify the transport DIB. It |
100 // should be unique for all transport DIBs ever created in the same | 121 // should be unique for all transport DIBs ever created in the same |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 Display* display_; // connection to the X server | 168 Display* display_; // connection to the X server |
148 #endif | 169 #endif |
149 size_t size_; // length, in bytes | 170 size_t size_; // length, in bytes |
150 | 171 |
151 DISALLOW_COPY_AND_ASSIGN(TransportDIB); | 172 DISALLOW_COPY_AND_ASSIGN(TransportDIB); |
152 }; | 173 }; |
153 | 174 |
154 class MessageLoop; | 175 class MessageLoop; |
155 | 176 |
156 #endif // APP_SURFACE_TRANSPORT_DIB_H_ | 177 #endif // APP_SURFACE_TRANSPORT_DIB_H_ |
OLD | NEW |