OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/safe_browsing/render_view_fake_resources_test.h" | 5 #include "chrome/renderer/safe_browsing/render_view_fake_resources_test.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 body = "content not found"; | 154 body = "content not found"; |
155 } else { | 155 } else { |
156 headers = "HTTP/1.1 200 OK\0Content-Type:text/html\0\0"; | 156 headers = "HTTP/1.1 200 OK\0Content-Type:text/html\0\0"; |
157 body = it->second; | 157 body = it->second; |
158 } | 158 } |
159 | 159 |
160 ResourceResponseHead response_head; | 160 ResourceResponseHead response_head; |
161 response_head.headers = new net::HttpResponseHeaders(headers); | 161 response_head.headers = new net::HttpResponseHeaders(headers); |
162 response_head.mime_type = "text/html"; | 162 response_head.mime_type = "text/html"; |
163 ASSERT_TRUE(channel_->Send(new ResourceMsg_ReceivedResponse( | 163 ASSERT_TRUE(channel_->Send(new ResourceMsg_ReceivedResponse( |
164 message.routing_id(), request_id, response_head))); | 164 message.routing_id(), request_id, response_head, base::TimeTicks(), |
| 165 base::TimeTicks()))); |
165 | 166 |
166 base::SharedMemory shared_memory; | 167 base::SharedMemory shared_memory; |
167 ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(body.size())); | 168 ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(body.size())); |
168 memcpy(shared_memory.memory(), body.data(), body.size()); | 169 memcpy(shared_memory.memory(), body.data(), body.size()); |
169 | 170 |
170 base::SharedMemoryHandle handle; | 171 base::SharedMemoryHandle handle; |
171 ASSERT_TRUE(shared_memory.GiveToProcess(base::Process::Current().handle(), | 172 ASSERT_TRUE(shared_memory.GiveToProcess(base::Process::Current().handle(), |
172 &handle)); | 173 &handle)); |
173 ASSERT_TRUE(channel_->Send(new ResourceMsg_DataReceived( | 174 ASSERT_TRUE(channel_->Send(new ResourceMsg_DataReceived( |
174 message.routing_id(), | 175 message.routing_id(), |
175 request_id, | 176 request_id, |
176 handle, | 177 handle, |
177 body.size(), | 178 body.size(), |
178 body.size()))); | 179 body.size()))); |
179 | 180 |
180 ASSERT_TRUE(channel_->Send(new ResourceMsg_RequestComplete( | 181 ASSERT_TRUE(channel_->Send(new ResourceMsg_RequestComplete( |
181 message.routing_id(), | 182 message.routing_id(), |
182 request_id, | 183 request_id, |
183 net::URLRequestStatus(), | 184 net::URLRequestStatus(), |
184 std::string(), | 185 std::string(), |
185 base::Time()))); | 186 base::TimeTicks()))); |
186 } | 187 } |
187 | 188 |
188 void RenderViewFakeResourcesTest::OnRenderViewReady() { | 189 void RenderViewFakeResourcesTest::OnRenderViewReady() { |
189 // Grab a pointer to the new view using RenderViewVisitor. | 190 // Grab a pointer to the new view using RenderViewVisitor. |
190 ASSERT_TRUE(!view_); | 191 ASSERT_TRUE(!view_); |
191 RenderView::ForEach(this); | 192 RenderView::ForEach(this); |
192 ASSERT_TRUE(view_); | 193 ASSERT_TRUE(view_); |
193 message_loop_.Quit(); | 194 message_loop_.Quit(); |
194 } | 195 } |
195 | 196 |
(...skipping 10 matching lines...) Expand all Loading... |
206 params.url = GURL(history_item.urlString()); | 207 params.url = GURL(history_item.urlString()); |
207 params.transition = PageTransition::FORWARD_BACK; | 208 params.transition = PageTransition::FORWARD_BACK; |
208 params.state = webkit_glue::HistoryItemToString(history_item); | 209 params.state = webkit_glue::HistoryItemToString(history_item); |
209 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; | 210 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
210 params.request_time = base::Time::Now(); | 211 params.request_time = base::Time::Now(); |
211 channel_->Send(new ViewMsg_Navigate(view_->routing_id(), params)); | 212 channel_->Send(new ViewMsg_Navigate(view_->routing_id(), params)); |
212 message_loop_.Run(); | 213 message_loop_.Run(); |
213 } | 214 } |
214 | 215 |
215 } // namespace safe_browsing | 216 } // namespace safe_browsing |
OLD | NEW |