OLD | NEW |
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 #include "ui/surface/transport_dib.h" | 5 #include "ui/surface/transport_dib.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (!is_valid_handle(shared_memory_.handle())) | 72 if (!is_valid_handle(shared_memory_.handle())) |
73 return false; | 73 return false; |
74 #if defined(OS_ANDROID) | 74 #if defined(OS_ANDROID) |
75 if (!shared_memory_.Map(0)) | 75 if (!shared_memory_.Map(0)) |
76 return false; | 76 return false; |
77 size_ = shared_memory_.mapped_size(); | 77 size_ = shared_memory_.mapped_size(); |
78 #else | 78 #else |
79 if (memory()) | 79 if (memory()) |
80 return true; | 80 return true; |
81 | 81 |
82 size_t size; | 82 size_t size = shared_memory_.handle().GetSize(); |
83 bool success = base::SharedMemory::GetSizeFromSharedMemoryHandle( | 83 if (!shared_memory_.Map(size)) |
84 shared_memory_.handle(), &size); | |
85 if (!success || !shared_memory_.Map(size)) | |
86 return false; | 84 return false; |
87 | 85 |
88 size_ = size; | 86 size_ = size; |
89 #endif | 87 #endif |
90 return true; | 88 return true; |
91 } | 89 } |
92 | 90 |
93 void* TransportDIB::memory() const { | 91 void* TransportDIB::memory() const { |
94 return shared_memory_.memory(); | 92 return shared_memory_.memory(); |
95 } | 93 } |
OLD | NEW |