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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // Delete this RWH from the map if it is found. | 90 // Delete this RWH from the map if it is found. |
91 WidgetHelperMap& widget_map = g_widget_helpers.Get(); | 91 WidgetHelperMap& widget_map = g_widget_helpers.Get(); |
92 WidgetHelperMap::iterator it = widget_map.find(render_process_id_); | 92 WidgetHelperMap::iterator it = widget_map.find(render_process_id_); |
93 if (it != widget_map.end() && it->second == this) | 93 if (it != widget_map.end() && it->second == this) |
94 widget_map.erase(it); | 94 widget_map.erase(it); |
95 | 95 |
96 // The elements of pending_paints_ each hold an owning reference back to this | 96 // The elements of pending_paints_ each hold an owning reference back to this |
97 // object, so we should not be destroyed unless pending_paints_ is empty! | 97 // object, so we should not be destroyed unless pending_paints_ is empty! |
98 DCHECK(pending_paints_.empty()); | 98 DCHECK(pending_paints_.empty()); |
99 | 99 |
100 #if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID) | 100 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
101 ClearAllocatedDIBs(); | 101 ClearAllocatedDIBs(); |
102 #endif | 102 #endif |
103 } | 103 } |
104 | 104 |
105 void RenderWidgetHelper::Init( | 105 void RenderWidgetHelper::Init( |
106 int render_process_id, | 106 int render_process_id, |
107 ResourceDispatcherHostImpl* resource_dispatcher_host) { | 107 ResourceDispatcherHostImpl* resource_dispatcher_host) { |
108 render_process_id_ = render_process_id; | 108 render_process_id_ = render_process_id; |
109 resource_dispatcher_host_ = resource_dispatcher_host; | 109 resource_dispatcher_host_ = resource_dispatcher_host; |
110 | 110 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } | 335 } |
336 | 336 |
337 void RenderWidgetHelper::OnCreateFullscreenWidgetOnUI(int opener_id, | 337 void RenderWidgetHelper::OnCreateFullscreenWidgetOnUI(int opener_id, |
338 int route_id) { | 338 int route_id) { |
339 RenderViewHostImpl* host = RenderViewHostImpl::FromID( | 339 RenderViewHostImpl* host = RenderViewHostImpl::FromID( |
340 render_process_id_, opener_id); | 340 render_process_id_, opener_id); |
341 if (host) | 341 if (host) |
342 host->CreateNewFullscreenWidget(route_id); | 342 host->CreateNewFullscreenWidget(route_id); |
343 } | 343 } |
344 | 344 |
345 #if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID) | 345 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
346 TransportDIB* RenderWidgetHelper::MapTransportDIB(TransportDIB::Id dib_id) { | 346 TransportDIB* RenderWidgetHelper::MapTransportDIB(TransportDIB::Id dib_id) { |
347 base::AutoLock locked(allocated_dibs_lock_); | 347 base::AutoLock locked(allocated_dibs_lock_); |
348 | 348 |
349 const std::map<TransportDIB::Id, int>::iterator | 349 const std::map<TransportDIB::Id, int>::iterator |
350 i = allocated_dibs_.find(dib_id); | 350 i = allocated_dibs_.find(dib_id); |
351 if (i == allocated_dibs_.end()) | 351 if (i == allocated_dibs_.end()) |
352 return NULL; | 352 return NULL; |
353 | 353 |
354 base::FileDescriptor fd(dup(i->second), true); | 354 base::FileDescriptor fd(dup(i->second), true); |
355 return TransportDIB::Map(fd); | 355 return TransportDIB::Map(fd); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 i = allocated_dibs_.begin(); i != allocated_dibs_.end(); ++i) { | 394 i = allocated_dibs_.begin(); i != allocated_dibs_.end(); ++i) { |
395 if (IGNORE_EINTR(close(i->second)) < 0) | 395 if (IGNORE_EINTR(close(i->second)) < 0) |
396 PLOG(ERROR) << "close: " << i->first; | 396 PLOG(ERROR) << "close: " << i->first; |
397 } | 397 } |
398 | 398 |
399 allocated_dibs_.clear(); | 399 allocated_dibs_.clear(); |
400 } | 400 } |
401 #endif | 401 #endif |
402 | 402 |
403 } // namespace content | 403 } // namespace content |
OLD | NEW |