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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
12 #include "content/common/request_extra_data.h" | 12 #include "content/common/request_extra_data.h" |
13 #include "content/common/resource_dispatcher.h" | 13 #include "content/common/resource_dispatcher.h" |
14 #include "content/common/resource_messages.h" | 14 #include "content/common/resource_messages.h" |
15 #include "content/common/resource_response.h" | 15 #include "content/public/common/resource_response.h" |
16 #include "net/base/upload_data.h" | 16 #include "net/base/upload_data.h" |
17 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "webkit/appcache/appcache_interfaces.h" | 19 #include "webkit/appcache/appcache_interfaces.h" |
20 | 20 |
21 using webkit_glue::ResourceLoaderBridge; | 21 using webkit_glue::ResourceLoaderBridge; |
22 using webkit_glue::ResourceResponseInfo; | 22 using webkit_glue::ResourceResponseInfo; |
23 | 23 |
24 static const char test_page_url[] = "http://www.google.com/"; | 24 static const char test_page_url[] = "http://www.google.com/"; |
25 static const char test_page_headers[] = | 25 static const char test_page_headers[] = |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 while (!message_queue_.empty()) { | 107 while (!message_queue_.empty()) { |
108 int request_id; | 108 int request_id; |
109 ResourceHostMsg_Request request; | 109 ResourceHostMsg_Request request; |
110 ASSERT_TRUE(ResourceHostMsg_RequestResource::Read( | 110 ASSERT_TRUE(ResourceHostMsg_RequestResource::Read( |
111 &message_queue_[0], &request_id, &request)); | 111 &message_queue_[0], &request_id, &request)); |
112 | 112 |
113 // check values | 113 // check values |
114 EXPECT_EQ(test_page_url, request.url.spec()); | 114 EXPECT_EQ(test_page_url, request.url.spec()); |
115 | 115 |
116 // received response message | 116 // received response message |
117 ResourceResponseHead response; | 117 content::ResourceResponseHead response; |
118 std::string raw_headers(test_page_headers); | 118 std::string raw_headers(test_page_headers); |
119 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0'); | 119 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0'); |
120 response.headers = new net::HttpResponseHeaders(raw_headers); | 120 response.headers = new net::HttpResponseHeaders(raw_headers); |
121 response.mime_type = test_page_mime_type; | 121 response.mime_type = test_page_mime_type; |
122 response.charset = test_page_charset; | 122 response.charset = test_page_charset; |
123 dispatcher_->OnReceivedResponse(request_id, response); | 123 dispatcher_->OnReceivedResponse(request_id, response); |
124 | 124 |
125 // received data message with the test contents | 125 // received data message with the test contents |
126 base::SharedMemory shared_mem; | 126 base::SharedMemory shared_mem; |
127 EXPECT_TRUE(shared_mem.CreateAndMapAnonymous(test_page_contents_len)); | 127 EXPECT_TRUE(shared_mem.CreateAndMapAnonymous(test_page_contents_len)); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 234 } |
235 | 235 |
236 virtual bool Send(IPC::Message* msg) { | 236 virtual bool Send(IPC::Message* msg) { |
237 delete msg; | 237 delete msg; |
238 return true; | 238 return true; |
239 } | 239 } |
240 | 240 |
241 void InitMessages() { | 241 void InitMessages() { |
242 set_defer_loading(true); | 242 set_defer_loading(true); |
243 | 243 |
244 ResourceResponseHead response_head; | 244 content::ResourceResponseHead response_head; |
245 response_head.status.set_status(net::URLRequestStatus::SUCCESS); | 245 response_head.status.set_status(net::URLRequestStatus::SUCCESS); |
246 | 246 |
247 IPC::Message* response_message = | 247 IPC::Message* response_message = |
248 new ResourceMsg_ReceivedResponse(0, 0, response_head); | 248 new ResourceMsg_ReceivedResponse(0, 0, response_head); |
249 | 249 |
250 dispatcher_->OnMessageReceived(*response_message); | 250 dispatcher_->OnMessageReceived(*response_message); |
251 | 251 |
252 delete response_message; | 252 delete response_message; |
253 | 253 |
254 // Duplicate the shared memory handle so both the test and the callee can | 254 // Duplicate the shared memory handle so both the test and the callee can |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 332 |
333 ResourceLoaderBridge* bridge = CreateBridge(); | 333 ResourceLoaderBridge* bridge = CreateBridge(); |
334 | 334 |
335 bridge->Start(this); | 335 bridge->Start(this); |
336 InitMessages(); | 336 InitMessages(); |
337 | 337 |
338 // Dispatch deferred messages. | 338 // Dispatch deferred messages. |
339 message_loop.RunAllPending(); | 339 message_loop.RunAllPending(); |
340 delete bridge; | 340 delete bridge; |
341 } | 341 } |
OLD | NEW |