summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host/mock_render_process_host.cc
blob: 951a648bcb63179601de37a2181477508fdc5976 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/renderer_host/mock_render_process_host.h"

MockRenderProcessHost::MockRenderProcessHost(Profile* profile)
    : RenderProcessHost(profile),
      transport_dib_(NULL),
      bad_msg_count_(0) {
}

MockRenderProcessHost::~MockRenderProcessHost() {
  delete transport_dib_;
}

bool MockRenderProcessHost::Init() {
  return true;
}

int MockRenderProcessHost::GetNextRoutingID() {
  static int prev_routing_id = 0;
  return ++prev_routing_id;
}

void MockRenderProcessHost::CancelResourceRequests(int render_widget_id) {
}

void MockRenderProcessHost::CrossSiteClosePageACK(
    const ViewMsg_ClosePage_Params& params) {
}

bool MockRenderProcessHost::WaitForPaintMsg(int render_widget_id,
                                            const base::TimeDelta& max_delay,
                                            IPC::Message* msg) {
  return false;
}

void MockRenderProcessHost::ReceivedBadMessage(uint16 msg_type) {
  ++bad_msg_count_;
}

void MockRenderProcessHost::WidgetRestored() {
}

void MockRenderProcessHost::WidgetHidden() {
}

void MockRenderProcessHost::ViewCreated() {
}

void MockRenderProcessHost::AddWord(const std::wstring& word) {
}

void MockRenderProcessHost::AddVisitedLinks(
    const VisitedLinkCommon::Fingerprints& links) {
}

void MockRenderProcessHost::ResetVisitedLinks() {
}

bool MockRenderProcessHost::FastShutdownIfPossible() {
  return false;
}

bool MockRenderProcessHost::SendWithTimeout(IPC::Message* msg, int timeout_ms) {
  // Save the message in the sink. Just ignore timeout_ms.
  sink_.OnMessageReceived(*msg);
  delete msg;
  return true;
}

bool MockRenderProcessHost::Send(IPC::Message* msg) {
  // Save the message in the sink.
  sink_.OnMessageReceived(*msg);
  delete msg;
  return true;
}

TransportDIB* MockRenderProcessHost::GetTransportDIB(TransportDIB::Id dib_id) {
  if (transport_dib_)
    return transport_dib_;
#if defined(OS_WIN)
  HANDLE duped;
  DuplicateHandle(GetCurrentProcess(), dib_id.handle, GetCurrentProcess(),
                  &duped, 0, TRUE, DUPLICATE_SAME_ACCESS);
  transport_dib_ = TransportDIB::Map(duped);
#elif defined(OS_MACOSX)
  // On Mac, TransportDIBs are always created in the browser, so we cannot map
  // one from a dib_id.
  transport_dib_ = TransportDIB::Create(100 * 100 * 4, 0);
#elif defined(OS_LINUX)
  transport_dib_ = TransportDIB::Map(dib_id);
#endif

  return transport_dib_;
}

void MockRenderProcessHost::OnMessageReceived(const IPC::Message& msg) {
}

void MockRenderProcessHost::OnChannelConnected(int32 peer_pid) {
}