| 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/eintr_wrapper.h" | 9 #include "base/eintr_wrapper.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 13 #include "content/browser/gpu/gpu_surface_tracker.h" | 13 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 14 #include "content/browser/renderer_host/render_process_host_impl.h" | 14 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 15 #include "content/browser/renderer_host/render_view_host_impl.h" | 15 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 16 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 16 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
| 17 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 17 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 18 #include "content/common/view_messages.h" | 18 #include "content/common/view_messages.h" |
| 19 | 19 |
| 20 using content::BrowserThread; | 20 namespace content { |
| 21 using content::RenderViewHostImpl; | |
| 22 using content::ResourceDispatcherHostImpl; | |
| 23 using content::SessionStorageNamespace; | |
| 24 | |
| 25 namespace { | 21 namespace { |
| 26 | 22 |
| 27 typedef std::map<int, RenderWidgetHelper*> WidgetHelperMap; | 23 typedef std::map<int, RenderWidgetHelper*> WidgetHelperMap; |
| 28 base::LazyInstance<WidgetHelperMap> g_widget_helpers = | 24 base::LazyInstance<WidgetHelperMap> g_widget_helpers = |
| 29 LAZY_INSTANCE_INITIALIZER; | 25 LAZY_INSTANCE_INITIALIZER; |
| 30 | 26 |
| 31 void AddWidgetHelper(int render_process_id, | 27 void AddWidgetHelper(int render_process_id, |
| 32 const scoped_refptr<RenderWidgetHelper>& widget_helper) { | 28 const scoped_refptr<RenderWidgetHelper>& widget_helper) { |
| 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 34 // We don't care if RenderWidgetHelpers overwrite an existing process_id. Just | 30 // We don't care if RenderWidgetHelpers overwrite an existing process_id. Just |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 if (queue.empty()) | 225 if (queue.empty()) |
| 230 pending_paints_.erase(it); | 226 pending_paints_.erase(it); |
| 231 } | 227 } |
| 232 } | 228 } |
| 233 | 229 |
| 234 void RenderWidgetHelper::OnDispatchBackingStoreMsg( | 230 void RenderWidgetHelper::OnDispatchBackingStoreMsg( |
| 235 BackingStoreMsgProxy* proxy) { | 231 BackingStoreMsgProxy* proxy) { |
| 236 OnDiscardBackingStoreMsg(proxy); | 232 OnDiscardBackingStoreMsg(proxy); |
| 237 | 233 |
| 238 // It is reasonable for the host to no longer exist. | 234 // It is reasonable for the host to no longer exist. |
| 239 content::RenderProcessHost* host = | 235 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_); |
| 240 content::RenderProcessHost::FromID(render_process_id_); | |
| 241 if (host) | 236 if (host) |
| 242 host->OnMessageReceived(proxy->message()); | 237 host->OnMessageReceived(proxy->message()); |
| 243 } | 238 } |
| 244 | 239 |
| 245 void RenderWidgetHelper::OnCancelResourceRequests( | 240 void RenderWidgetHelper::OnCancelResourceRequests( |
| 246 int render_widget_id) { | 241 int render_widget_id) { |
| 247 resource_dispatcher_host_->CancelRequestsForRoute( | 242 resource_dispatcher_host_->CancelRequestsForRoute( |
| 248 render_process_id_, render_widget_id); | 243 render_process_id_, render_widget_id); |
| 249 } | 244 } |
| 250 | 245 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 void RenderWidgetHelper::ClearAllocatedDIBs() { | 395 void RenderWidgetHelper::ClearAllocatedDIBs() { |
| 401 for (std::map<TransportDIB::Id, int>::iterator | 396 for (std::map<TransportDIB::Id, int>::iterator |
| 402 i = allocated_dibs_.begin(); i != allocated_dibs_.end(); ++i) { | 397 i = allocated_dibs_.begin(); i != allocated_dibs_.end(); ++i) { |
| 403 if (HANDLE_EINTR(close(i->second)) < 0) | 398 if (HANDLE_EINTR(close(i->second)) < 0) |
| 404 PLOG(ERROR) << "close: " << i->first; | 399 PLOG(ERROR) << "close: " << i->first; |
| 405 } | 400 } |
| 406 | 401 |
| 407 allocated_dibs_.clear(); | 402 allocated_dibs_.clear(); |
| 408 } | 403 } |
| 409 #endif | 404 #endif |
| 405 |
| 406 } // namespace content |
| OLD | NEW |