| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/render_widget_helper.h" | 5 #include "chrome/browser/renderer_host/render_widget_helper.h" |
| 6 | 6 |
| 7 #include "base/thread.h" | 7 #include "base/thread.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/renderer_host/render_process_host.h" | 9 #include "chrome/browser/renderer_host/render_process_host.h" |
| 10 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 10 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 scoped_refptr<RenderWidgetHelper> helper; | 37 scoped_refptr<RenderWidgetHelper> helper; |
| 38 IPC::Message message; | 38 IPC::Message message; |
| 39 bool cancelled; // If true, then the message will not be dispatched. | 39 bool cancelled; // If true, then the message will not be dispatched. |
| 40 | 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(PaintMsgProxy); | 41 DISALLOW_COPY_AND_ASSIGN(PaintMsgProxy); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 RenderWidgetHelper::RenderWidgetHelper( | 44 RenderWidgetHelper::RenderWidgetHelper() |
| 45 int render_process_id, ResourceDispatcherHost* resource_dispatcher_host) | 45 : render_process_id_(-1), |
| 46 : render_process_id_(render_process_id), | |
| 47 ui_loop_(MessageLoop::current()), | 46 ui_loop_(MessageLoop::current()), |
| 48 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 49 event_(CreateEvent(NULL, FALSE /* auto-reset */, FALSE, NULL)), | 48 event_(CreateEvent(NULL, FALSE /* auto-reset */, FALSE, NULL)), |
| 50 #elif defined(OS_POSIX) | 49 #elif defined(OS_POSIX) |
| 51 event_(false /* auto-reset */, false), | 50 event_(false /* auto-reset */, false), |
| 52 #endif | 51 #endif |
| 53 block_popups_(false), | 52 block_popups_(false), |
| 54 resource_dispatcher_host_(resource_dispatcher_host) { | 53 resource_dispatcher_host_(NULL) { |
| 55 } | 54 } |
| 56 | 55 |
| 57 RenderWidgetHelper::~RenderWidgetHelper() { | 56 RenderWidgetHelper::~RenderWidgetHelper() { |
| 58 // The elements of pending_paints_ each hold an owning reference back to this | 57 // The elements of pending_paints_ each hold an owning reference back to this |
| 59 // object, so we should not be destroyed unless pending_paints_ is empty! | 58 // object, so we should not be destroyed unless pending_paints_ is empty! |
| 60 DCHECK(pending_paints_.empty()); | 59 DCHECK(pending_paints_.empty()); |
| 61 | 60 |
| 62 #if defined(OS_MACOSX) | 61 #if defined(OS_MACOSX) |
| 63 ClearAllocatedDIBs(); | 62 ClearAllocatedDIBs(); |
| 64 #endif | 63 #endif |
| 65 } | 64 } |
| 66 | 65 |
| 66 void RenderWidgetHelper::Init( |
| 67 int render_process_id, |
| 68 ResourceDispatcherHost* resource_dispatcher_host) { |
| 69 render_process_id_ = render_process_id; |
| 70 resource_dispatcher_host_ = resource_dispatcher_host; |
| 71 } |
| 72 |
| 67 int RenderWidgetHelper::GetNextRoutingID() { | 73 int RenderWidgetHelper::GetNextRoutingID() { |
| 68 return next_routing_id_.GetNext() + 1; | 74 return next_routing_id_.GetNext() + 1; |
| 69 } | 75 } |
| 70 | 76 |
| 71 void RenderWidgetHelper::CancelResourceRequests(int render_widget_id) { | 77 void RenderWidgetHelper::CancelResourceRequests(int render_widget_id) { |
| 72 if (g_browser_process->io_thread()) { | 78 if (g_browser_process->io_thread() && render_process_id_ != -1) { |
| 73 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 79 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
| 74 NewRunnableMethod(this, | 80 NewRunnableMethod(this, |
| 75 &RenderWidgetHelper::OnCancelResourceRequests, | 81 &RenderWidgetHelper::OnCancelResourceRequests, |
| 76 render_widget_id)); | 82 render_widget_id)); |
| 77 } | 83 } |
| 78 } | 84 } |
| 79 | 85 |
| 80 void RenderWidgetHelper::CrossSiteClosePageACK(int new_render_process_host_id, | 86 void RenderWidgetHelper::CrossSiteClosePageACK(int new_render_process_host_id, |
| 81 int new_request_id) { | 87 int new_request_id) { |
| 82 if (g_browser_process->io_thread()) { | 88 if (g_browser_process->io_thread()) { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 322 |
| 317 void RenderWidgetHelper::ClearAllocatedDIBs() { | 323 void RenderWidgetHelper::ClearAllocatedDIBs() { |
| 318 for (std::map<TransportDIB::Id, int>::iterator | 324 for (std::map<TransportDIB::Id, int>::iterator |
| 319 i = allocated_dibs_.begin(); i != allocated_dibs_.end(); ++i) { | 325 i = allocated_dibs_.begin(); i != allocated_dibs_.end(); ++i) { |
| 320 close(i->second); | 326 close(i->second); |
| 321 } | 327 } |
| 322 | 328 |
| 323 allocated_dibs_.clear(); | 329 allocated_dibs_.clear(); |
| 324 } | 330 } |
| 325 #endif | 331 #endif |
| OLD | NEW |