| 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" |
| 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/public/common/resource_response.h" | 15 #include "content/public/common/resource_response.h" |
| 16 #include "net/base/net_errors.h" |
| 16 #include "net/base/upload_data.h" | 17 #include "net/base/upload_data.h" |
| 17 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "webkit/appcache/appcache_interfaces.h" | 20 #include "webkit/appcache/appcache_interfaces.h" |
| 20 | 21 |
| 21 using webkit_glue::ResourceLoaderBridge; | 22 using webkit_glue::ResourceLoaderBridge; |
| 22 using webkit_glue::ResourceResponseInfo; | 23 using webkit_glue::ResourceResponseInfo; |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 61 } |
| 61 | 62 |
| 62 virtual void OnReceivedData(const char* data, | 63 virtual void OnReceivedData(const char* data, |
| 63 int data_length, | 64 int data_length, |
| 64 int encoded_data_length) { | 65 int encoded_data_length) { |
| 65 EXPECT_FALSE(complete_); | 66 EXPECT_FALSE(complete_); |
| 66 data_.append(data, data_length); | 67 data_.append(data, data_length); |
| 67 total_encoded_data_length_ += encoded_data_length; | 68 total_encoded_data_length_ += encoded_data_length; |
| 68 } | 69 } |
| 69 | 70 |
| 70 virtual void OnCompletedRequest(const net::URLRequestStatus& status, | 71 virtual void OnCompletedRequest(int error_code, |
| 72 bool handled_externally, |
| 71 const std::string& security_info, | 73 const std::string& security_info, |
| 72 const base::TimeTicks& completion_time) { | 74 const base::TimeTicks& completion_time) { |
| 73 EXPECT_FALSE(complete_); | 75 EXPECT_FALSE(complete_); |
| 74 complete_ = true; | 76 complete_ = true; |
| 75 } | 77 } |
| 76 | 78 |
| 77 bool complete() const { | 79 bool complete() const { |
| 78 return complete_; | 80 return complete_; |
| 79 } | 81 } |
| 80 const std::string& data() const { | 82 const std::string& data() const { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 240 |
| 239 virtual bool Send(IPC::Message* msg) { | 241 virtual bool Send(IPC::Message* msg) { |
| 240 delete msg; | 242 delete msg; |
| 241 return true; | 243 return true; |
| 242 } | 244 } |
| 243 | 245 |
| 244 void InitMessages() { | 246 void InitMessages() { |
| 245 set_defer_loading(true); | 247 set_defer_loading(true); |
| 246 | 248 |
| 247 ResourceResponseHead response_head; | 249 ResourceResponseHead response_head; |
| 248 response_head.status.set_status(net::URLRequestStatus::SUCCESS); | 250 response_head.error_code = net::OK; |
| 249 | 251 |
| 250 IPC::Message* response_message = | 252 IPC::Message* response_message = |
| 251 new ResourceMsg_ReceivedResponse(0, 0, response_head); | 253 new ResourceMsg_ReceivedResponse(0, 0, response_head); |
| 252 | 254 |
| 253 dispatcher_->OnMessageReceived(*response_message); | 255 dispatcher_->OnMessageReceived(*response_message); |
| 254 | 256 |
| 255 delete response_message; | 257 delete response_message; |
| 256 | 258 |
| 257 // Duplicate the shared memory handle so both the test and the callee can | 259 // Duplicate the shared memory handle so both the test and the callee can |
| 258 // close their copy. | 260 // close their copy. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 virtual void OnDownloadedData(int len) { | 293 virtual void OnDownloadedData(int len) { |
| 292 } | 294 } |
| 293 | 295 |
| 294 virtual void OnReceivedData(const char* data, | 296 virtual void OnReceivedData(const char* data, |
| 295 int data_length, | 297 int data_length, |
| 296 int encoded_data_length) { | 298 int encoded_data_length) { |
| 297 EXPECT_EQ(defer_loading_, false); | 299 EXPECT_EQ(defer_loading_, false); |
| 298 set_defer_loading(false); | 300 set_defer_loading(false); |
| 299 } | 301 } |
| 300 | 302 |
| 301 virtual void OnCompletedRequest(const net::URLRequestStatus& status, | 303 virtual void OnCompletedRequest(int error_code, |
| 304 bool handled_externally, |
| 302 const std::string& security_info, | 305 const std::string& security_info, |
| 303 const base::TimeTicks& completion_time) { | 306 const base::TimeTicks& completion_time) { |
| 304 } | 307 } |
| 305 | 308 |
| 306 protected: | 309 protected: |
| 307 virtual void SetUp() { | 310 virtual void SetUp() { |
| 308 ResourceDispatcherTest::SetUp(); | 311 ResourceDispatcherTest::SetUp(); |
| 309 shared_handle_.Delete(kShmemSegmentName); | 312 shared_handle_.Delete(kShmemSegmentName); |
| 310 EXPECT_TRUE(shared_handle_.CreateNamed(kShmemSegmentName, false, 100)); | 313 EXPECT_TRUE(shared_handle_.CreateNamed(kShmemSegmentName, false, 100)); |
| 311 } | 314 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 337 | 340 |
| 338 bridge->Start(this); | 341 bridge->Start(this); |
| 339 InitMessages(); | 342 InitMessages(); |
| 340 | 343 |
| 341 // Dispatch deferred messages. | 344 // Dispatch deferred messages. |
| 342 message_loop.RunAllPending(); | 345 message_loop.RunAllPending(); |
| 343 delete bridge; | 346 delete bridge; |
| 344 } | 347 } |
| 345 | 348 |
| 346 } // namespace content | 349 } // namespace content |
| OLD | NEW |