Skip to content

Commit

Permalink
make the process() and routing_id() functiosn virtual so baseo f Memo…
Browse files Browse the repository at this point in the history
…ryRenderHostImpl must not be known
  • Loading branch information
danielrh committed Oct 5, 2009
1 parent 0dfd7ad commit e1f51c7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 17 deletions.
36 changes: 26 additions & 10 deletions src/MemoryRenderViewHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ void MemoryRenderViewHost::OnMessageReceived(const IPC::Message& msg) {
///////// MemoryRenderWidgetHost /////////

MemoryRenderWidgetHost::MemoryRenderWidgetHost(
WindowImpl *win,
RenderWidget *wid,
RenderViewHostDelegate *delegate,
RenderWidgetHostView *wid,
RenderProcessHost* host,
int routing_id)
: RenderWidgetHost(host, routing_id) {
Expand All @@ -92,15 +92,15 @@ MemoryRenderWidgetHost::MemoryRenderWidgetHost(
set_view(wid);
}

MemoryRenderWidgetHost::~MemoryRenderViewHost() {
MemoryRenderWidgetHost::~MemoryRenderWidgetHost() {
}

void MemoryRenderWidgetHost::OnMessageReceived(const IPC::Message& msg) {
bool msg_is_ok = true;
IPC_BEGIN_MESSAGE_MAP_EX(MemoryRenderViewHost, msg, msg_is_ok)
IPC_MESSAGE_HANDLER(ViewHostMsg_ScrollRect, Memory_OnMsgScrollRect)
IPC_MESSAGE_HANDLER(ViewHostMsg_PaintRect, Memory_OnMsgPaintRect)
IPC_MESSAGE_UNHANDLED(RenderViewHost::OnMessageReceived(msg))
IPC_MESSAGE_UNHANDLED(this->RenderWidgetHost::OnMessageReceived(msg))
IPC_END_MESSAGE_MAP_EX()
;

Expand Down Expand Up @@ -142,7 +142,7 @@ void MemoryRenderHostBase::Memory_OnMsgScrollRect(
// This must be done AFTER we're done painting with the bitmap supplied by the
// renderer. This ACK is a signal to the renderer that the backing store can
// be re-used, so the bitmap may be invalid after this call.
Send(new ViewMsg_ScrollRect_ACK(routing_id()));
process()->Send(new ViewMsg_ScrollRect_ACK(routing_id()));

// Paint the view. Watch out: it might be destroyed already.
if (view()) {
Expand All @@ -154,8 +154,7 @@ void MemoryRenderHostBase::Memory_OnMsgScrollRect(

}
void MemoryRenderHostBase::Memory_WasResized() {
if (mResizeAckPending || !process()->HasConnection() || !view() ||
!renderer_initialized_) {
if (mResizeAckPending || !process()->HasConnection() || !view() ) {
return;
}

Expand All @@ -174,8 +173,8 @@ void MemoryRenderHostBase::Memory_WasResized() {
if (!new_size.IsEmpty())
mResizeAckPending = true;

if (!Send(new ViewMsg_Resize(routing_id(), new_size,
GetRootWindowResizerRect())))
if (!process()->Send(new ViewMsg_Resize(routing_id(), new_size,
RootWindowResizerRectSize())))
mResizeAckPending = false;
else
mInFlightSize = new_size;
Expand Down Expand Up @@ -228,7 +227,7 @@ void MemoryRenderHostBase::Memory_OnMsgPaintRect(
// This must be done AFTER we're done painting with the bitmap supplied by the
// renderer. This ACK is a signal to the renderer that the backing store can
// be re-used, so the bitmap may be invalid after this call.
Send(new ViewMsg_PaintRect_ACK(routing_id()));
process()->Send(new ViewMsg_PaintRect_ACK(routing_id()));

// Now paint the view. Watch out: it might be destroyed already.
if (view()) {
Expand Down Expand Up @@ -284,8 +283,25 @@ void MemoryRenderHostBase::Memory_PaintBackingStoreRect(
}


gfx::Rect MemoryRenderViewHost::RootWindowResizerRectSize()const{
return GetRootWindowResizerRect();
}

RenderProcessHost* MemoryRenderViewHost::process() {
return RenderViewHost::process();
}

int MemoryRenderViewHost::routing_id()const{
return RenderViewHost::routing_id();
}

RenderProcessHost* MemoryRenderWidgetHost::process() {
return RenderWidgetHost::process();
}

int MemoryRenderWidgetHost::routing_id()const{
return RenderWidgetHost::routing_id();
}
///////// MemoryRenderViewHostFactory /////////

MemoryRenderViewHostFactory::MemoryRenderViewHostFactory() {
Expand Down
26 changes: 19 additions & 7 deletions src/MemoryRenderViewHost.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_view_host_factory.h"

class RenderWidgetHostView;
namespace Berkelium {
class RenderWidget;
class WindowImpl;


Expand All @@ -47,6 +47,7 @@ class MemoryRenderHostBase {
~MemoryRenderHostBase() {}

void Memory_WasResized();
public:

void Memory_OnMsgScrollRect(const ViewHostMsg_ScrollRect_Params&params);
void Memory_OnMsgPaintRect(const ViewHostMsg_PaintRect_Params&params);
Expand All @@ -56,20 +57,31 @@ class MemoryRenderHostBase {
const gfx::Rect& clip_rect);
void Memory_PaintBackingStoreRect(TransportDIB* bitmap,
const gfx::Rect& bitmap_rect);

RenderWidgetHostView *view() {return mWidget;}
const RenderWidgetHostView *view() const{return mWidget;}
virtual RenderProcessHost * process()=0;
virtual int routing_id()const=0;
virtual gfx::Rect RootWindowResizerRectSize()const=0;
WindowImpl *mWindow;
RenderWidget *mWidget;
RenderWidgetHostView *mWidget;
gfx::Size current_size_;
bool mResizeAckPending;
gfx::Size mInFlightSize;
};

class MemoryRenderWidgetHost : public RenderWidgetHost, public MemoryRenderHostBase {
public:
MemoryRenderWidgetHost(
RenderViewHostDelegate *win,
RenderWidgetHostView*wid,
RenderProcessHost* process,
int routing_id);
~MemoryRenderWidgetHost();

virtual bool Send(IPC::Message*msg);
virtual RenderProcessHost * process();
virtual int routing_id()const;
virtual void OnMessageReceived(const IPC::Message& msg);
virtual gfx::Rect RootWindowResizerRectSize()const;
};

class MemoryRenderViewHost : public RenderViewHost, public MemoryRenderHostBase {
Expand All @@ -80,11 +92,11 @@ class MemoryRenderViewHost : public RenderViewHost, public MemoryRenderHostBase
int routing_id,
base::WaitableEvent* modal_dialog_event);
~MemoryRenderViewHost();

virtual RenderProcessHost * process();
virtual int routing_id()const;
virtual void OnMessageReceived(const IPC::Message& msg);
virtual gfx::Rect RootWindowResizerRectSize()const;
protected:
bool mResizeAckPending;
gfx::Size mInFlightSize;
};

class MemoryRenderViewHostFactory : public RenderViewHostFactory {
Expand Down

0 comments on commit e1f51c7

Please sign in to comment.