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 "content/browser/renderer_host/render_widget_helper.h" | 5 #include "content/browser/renderer_host/render_widget_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/posix/eintr_wrapper.h" | 10 #include "base/posix/eintr_wrapper.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 341 |
342 const std::map<TransportDIB::Id, int>::iterator | 342 const std::map<TransportDIB::Id, int>::iterator |
343 i = allocated_dibs_.find(dib_id); | 343 i = allocated_dibs_.find(dib_id); |
344 if (i == allocated_dibs_.end()) | 344 if (i == allocated_dibs_.end()) |
345 return NULL; | 345 return NULL; |
346 | 346 |
347 base::FileDescriptor fd(dup(i->second), true); | 347 base::FileDescriptor fd(dup(i->second), true); |
348 return TransportDIB::Map(fd); | 348 return TransportDIB::Map(fd); |
349 } | 349 } |
350 | 350 |
351 void RenderWidgetHelper::AllocTransportDIB( | 351 void RenderWidgetHelper::AllocTransportDIB(uint32 size, |
352 size_t size, bool cache_in_browser, TransportDIB::Handle* result) { | 352 bool cache_in_browser, |
| 353 TransportDIB::Handle* result) { |
353 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); | 354 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); |
354 if (!shared_memory->CreateAnonymous(size)) { | 355 if (!shared_memory->CreateAnonymous(size)) { |
355 result->fd = -1; | 356 result->fd = -1; |
356 result->auto_close = false; | 357 result->auto_close = false; |
357 return; | 358 return; |
358 } | 359 } |
359 | 360 |
360 shared_memory->GiveToProcess(0 /* pid, not needed */, result); | 361 shared_memory->GiveToProcess(0 /* pid, not needed */, result); |
361 | 362 |
362 if (cache_in_browser) { | 363 if (cache_in_browser) { |
(...skipping 23 matching lines...) Expand all Loading... |
386 i = allocated_dibs_.begin(); i != allocated_dibs_.end(); ++i) { | 387 i = allocated_dibs_.begin(); i != allocated_dibs_.end(); ++i) { |
387 if (HANDLE_EINTR(close(i->second)) < 0) | 388 if (HANDLE_EINTR(close(i->second)) < 0) |
388 PLOG(ERROR) << "close: " << i->first; | 389 PLOG(ERROR) << "close: " << i->first; |
389 } | 390 } |
390 | 391 |
391 allocated_dibs_.clear(); | 392 allocated_dibs_.clear(); |
392 } | 393 } |
393 #endif | 394 #endif |
394 | 395 |
395 } // namespace content | 396 } // namespace content |
OLD | NEW |