| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 dispatcher_->OnReceivedResponse(request_id, response); | 127 dispatcher_->OnReceivedResponse(request_id, response); |
| 128 | 128 |
| 129 // received data message with the test contents | 129 // received data message with the test contents |
| 130 base::SharedMemory shared_mem; | 130 base::SharedMemory shared_mem; |
| 131 EXPECT_TRUE(shared_mem.CreateAndMapAnonymous(test_page_contents_len)); | 131 EXPECT_TRUE(shared_mem.CreateAndMapAnonymous(test_page_contents_len)); |
| 132 char* put_data_here = static_cast<char*>(shared_mem.memory()); | 132 char* put_data_here = static_cast<char*>(shared_mem.memory()); |
| 133 memcpy(put_data_here, test_page_contents, test_page_contents_len); | 133 memcpy(put_data_here, test_page_contents, test_page_contents_len); |
| 134 base::SharedMemoryHandle dup_handle; | 134 base::SharedMemoryHandle dup_handle; |
| 135 EXPECT_TRUE(shared_mem.GiveToProcess( | 135 EXPECT_TRUE(shared_mem.GiveToProcess( |
| 136 base::Process::Current().handle(), &dup_handle)); | 136 base::Process::Current().handle(), &dup_handle)); |
| 137 dispatcher_->OnReceivedData( | 137 dispatcher_->OnSetDataBuffer(message_queue_[0], request_id, dup_handle, |
| 138 message_queue_[0], | 138 test_page_contents_len); |
| 139 request_id, | 139 dispatcher_->OnReceivedData(message_queue_[0], request_id, 0, |
| 140 dup_handle, | 140 test_page_contents_len, |
| 141 test_page_contents_len, | 141 test_page_contents_len); |
| 142 test_page_contents_len); | |
| 143 | 142 |
| 144 message_queue_.erase(message_queue_.begin()); | 143 message_queue_.erase(message_queue_.begin()); |
| 145 | 144 |
| 146 // read the ack message. | 145 // read the ack message. |
| 147 Tuple1<int> request_ack; | 146 Tuple1<int> request_ack; |
| 148 ASSERT_TRUE(ResourceHostMsg_DataReceived_ACK::Read( | 147 ASSERT_TRUE(ResourceHostMsg_DataReceived_ACK::Read( |
| 149 &message_queue_[0], &request_ack)); | 148 &message_queue_[0], &request_ack)); |
| 150 | 149 |
| 151 ASSERT_EQ(request_ack.a, request_id); | 150 ASSERT_EQ(request_ack.a, request_id); |
| 152 | 151 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 dispatcher_->OnMessageReceived( | 252 dispatcher_->OnMessageReceived( |
| 254 ResourceMsg_ReceivedResponse(0, 0, response_head)); | 253 ResourceMsg_ReceivedResponse(0, 0, response_head)); |
| 255 | 254 |
| 256 // Duplicate the shared memory handle so both the test and the callee can | 255 // Duplicate the shared memory handle so both the test and the callee can |
| 257 // close their copy. | 256 // close their copy. |
| 258 base::SharedMemoryHandle duplicated_handle; | 257 base::SharedMemoryHandle duplicated_handle; |
| 259 EXPECT_TRUE(shared_handle_.ShareToProcess(base::GetCurrentProcessHandle(), | 258 EXPECT_TRUE(shared_handle_.ShareToProcess(base::GetCurrentProcessHandle(), |
| 260 &duplicated_handle)); | 259 &duplicated_handle)); |
| 261 | 260 |
| 262 dispatcher_->OnMessageReceived( | 261 dispatcher_->OnMessageReceived( |
| 263 ResourceMsg_DataReceived(0, 0, duplicated_handle, 100, 100)); | 262 ResourceMsg_SetDataBuffer(0, 0, duplicated_handle, 100)); |
| 263 dispatcher_->OnMessageReceived( |
| 264 ResourceMsg_DataReceived(0, 0, 0, 100, 100)); |
| 264 | 265 |
| 265 set_defer_loading(false); | 266 set_defer_loading(false); |
| 266 } | 267 } |
| 267 | 268 |
| 268 // ResourceLoaderBridge::Peer methods. | 269 // ResourceLoaderBridge::Peer methods. |
| 269 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE { | 270 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE { |
| 270 } | 271 } |
| 271 | 272 |
| 272 virtual bool OnReceivedRedirect( | 273 virtual bool OnReceivedRedirect( |
| 273 const GURL& new_url, | 274 const GURL& new_url, |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 ResourceResponseHead response_head; | 428 ResourceResponseHead response_head; |
| 428 response_head.error_code = net::OK; | 429 response_head.error_code = net::OK; |
| 429 | 430 |
| 430 PerformTest(response_head); | 431 PerformTest(response_head); |
| 431 | 432 |
| 432 EXPECT_EQ(0, response_info().load_timing.base_ticks.ToInternalValue()); | 433 EXPECT_EQ(0, response_info().load_timing.base_ticks.ToInternalValue()); |
| 433 EXPECT_EQ(-1, response_info().load_timing.dns_start); | 434 EXPECT_EQ(-1, response_info().load_timing.dns_start); |
| 434 } | 435 } |
| 435 | 436 |
| 436 } // namespace content | 437 } // namespace content |
| OLD | NEW |