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 "app/surface/transport_dib.h" | 5 #include "app/surface/transport_dib.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #include "base/eintr_wrapper.h" | 10 #include "base/eintr_wrapper.h" |
| 11 #include "base/logging.h" |
11 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
12 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
13 #include "skia/ext/platform_canvas.h" | 14 #include "skia/ext/platform_canvas.h" |
14 | 15 |
15 TransportDIB::TransportDIB() | 16 TransportDIB::TransportDIB() |
16 : size_(0) { | 17 : size_(0) { |
17 } | 18 } |
18 | 19 |
19 TransportDIB::TransportDIB(TransportDIB::Handle dib) | 20 TransportDIB::TransportDIB(TransportDIB::Handle dib) |
20 : shared_memory_(dib, false /* read write */), | 21 : shared_memory_(dib, false /* read write */), |
(...skipping 19 matching lines...) Expand all Loading... |
40 // static | 41 // static |
41 TransportDIB* TransportDIB::Map(TransportDIB::Handle handle) { | 42 TransportDIB* TransportDIB::Map(TransportDIB::Handle handle) { |
42 if (!is_valid(handle)) | 43 if (!is_valid(handle)) |
43 return NULL; | 44 return NULL; |
44 | 45 |
45 TransportDIB* dib = new TransportDIB(handle); | 46 TransportDIB* dib = new TransportDIB(handle); |
46 struct stat st; | 47 struct stat st; |
47 if ((fstat(handle.fd, &st) != 0) || | 48 if ((fstat(handle.fd, &st) != 0) || |
48 (!dib->shared_memory_.Map(st.st_size))) { | 49 (!dib->shared_memory_.Map(st.st_size))) { |
49 delete dib; | 50 delete dib; |
50 HANDLE_EINTR(close(handle.fd)); | 51 if (HANDLE_EINTR(close(handle.fd)) < 0) |
| 52 PLOG(ERROR) << "close"; |
51 return NULL; | 53 return NULL; |
52 } | 54 } |
53 | 55 |
54 dib->size_ = st.st_size; | 56 dib->size_ = st.st_size; |
55 | 57 |
56 return dib; | 58 return dib; |
57 } | 59 } |
58 | 60 |
59 bool TransportDIB::is_valid(Handle dib) { | 61 bool TransportDIB::is_valid(Handle dib) { |
60 return dib.fd >= 0; | 62 return dib.fd >= 0; |
(...skipping 10 matching lines...) Expand all Loading... |
71 return shared_memory_.memory(); | 73 return shared_memory_.memory(); |
72 } | 74 } |
73 | 75 |
74 TransportDIB::Id TransportDIB::id() const { | 76 TransportDIB::Id TransportDIB::id() const { |
75 return shared_memory_.id(); | 77 return shared_memory_.id(); |
76 } | 78 } |
77 | 79 |
78 TransportDIB::Handle TransportDIB::handle() const { | 80 TransportDIB::Handle TransportDIB::handle() const { |
79 return shared_memory_.handle(); | 81 return shared_memory_.handle(); |
80 } | 82 } |
OLD | NEW |