| 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 "content/browser/renderer_host/resource_dispatcher_host.h" | 5 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 13 #include "content/browser/browser_thread_impl.h" |
| 13 #include "content/browser/child_process_security_policy.h" | 14 #include "content/browser/child_process_security_policy.h" |
| 14 #include "content/browser/download/download_id.h" | 15 #include "content/browser/download/download_id.h" |
| 15 #include "content/browser/download/download_id_factory.h" | 16 #include "content/browser/download/download_id_factory.h" |
| 16 #include "content/browser/mock_resource_context.h" | 17 #include "content/browser/mock_resource_context.h" |
| 17 #include "content/browser/renderer_host/dummy_resource_handler.h" | 18 #include "content/browser/renderer_host/dummy_resource_handler.h" |
| 18 #include "content/browser/renderer_host/global_request_id.h" | 19 #include "content/browser/renderer_host/global_request_id.h" |
| 19 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 20 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 20 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 21 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 21 #include "content/browser/renderer_host/resource_handler.h" | 22 #include "content/browser/renderer_host/resource_handler.h" |
| 22 #include "content/browser/renderer_host/resource_message_filter.h" | 23 #include "content/browser/renderer_host/resource_message_filter.h" |
| 23 #include "content/common/resource_messages.h" | 24 #include "content/common/resource_messages.h" |
| 24 #include "content/common/resource_response.h" | 25 #include "content/common/resource_response.h" |
| 25 #include "content/common/view_messages.h" | 26 #include "content/common/view_messages.h" |
| 26 #include "content/test/test_browser_thread.h" | |
| 27 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
| 28 #include "net/base/upload_data.h" | 28 #include "net/base/upload_data.h" |
| 29 #include "net/http/http_util.h" | 29 #include "net/http/http_util.h" |
| 30 #include "net/url_request/url_request.h" | 30 #include "net/url_request/url_request.h" |
| 31 #include "net/url_request/url_request_job.h" | 31 #include "net/url_request/url_request_job.h" |
| 32 #include "net/url_request/url_request_test_job.h" | 32 #include "net/url_request/url_request_test_job.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "webkit/appcache/appcache_interfaces.h" | 34 #include "webkit/appcache/appcache_interfaces.h" |
| 35 | 35 |
| 36 using content::BrowserThreadImpl; |
| 37 |
| 36 // TODO(eroman): Write unit tests for SafeBrowsing that exercise | 38 // TODO(eroman): Write unit tests for SafeBrowsing that exercise |
| 37 // SafeBrowsingResourceHandler. | 39 // SafeBrowsingResourceHandler. |
| 38 | 40 |
| 39 namespace { | 41 namespace { |
| 40 | 42 |
| 41 // Returns the resource response header structure for this request. | 43 // Returns the resource response header structure for this request. |
| 42 void GetResponseHead(const std::vector<IPC::Message>& messages, | 44 void GetResponseHead(const std::vector<IPC::Message>& messages, |
| 43 ResourceResponseHead* response_head) { | 45 ResourceResponseHead* response_head) { |
| 44 ASSERT_GE(messages.size(), 2U); | 46 ASSERT_GE(messages.size(), 2U); |
| 45 | 47 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 false); | 381 false); |
| 380 } | 382 } |
| 381 } | 383 } |
| 382 } | 384 } |
| 383 | 385 |
| 384 void SetDelayedStartJobGeneration(bool delay_job_start) { | 386 void SetDelayedStartJobGeneration(bool delay_job_start) { |
| 385 delay_start_ = delay_job_start; | 387 delay_start_ = delay_job_start; |
| 386 } | 388 } |
| 387 | 389 |
| 388 MessageLoopForIO message_loop_; | 390 MessageLoopForIO message_loop_; |
| 389 content::TestBrowserThread ui_thread_; | 391 BrowserThreadImpl ui_thread_; |
| 390 content::TestBrowserThread io_thread_; | 392 BrowserThreadImpl io_thread_; |
| 391 scoped_refptr<ForwardingFilter> filter_; | 393 scoped_refptr<ForwardingFilter> filter_; |
| 392 ResourceDispatcherHost host_; | 394 ResourceDispatcherHost host_; |
| 393 ResourceIPCAccumulator accum_; | 395 ResourceIPCAccumulator accum_; |
| 394 std::string response_headers_; | 396 std::string response_headers_; |
| 395 std::string response_data_; | 397 std::string response_data_; |
| 396 std::string scheme_; | 398 std::string scheme_; |
| 397 net::URLRequest::ProtocolFactory* old_factory_; | 399 net::URLRequest::ProtocolFactory* old_factory_; |
| 398 ResourceType::Type resource_type_; | 400 ResourceType::Type resource_type_; |
| 399 static ResourceDispatcherHostTest* test_fixture_; | 401 static ResourceDispatcherHostTest* test_fixture_; |
| 400 static bool delay_start_; | 402 static bool delay_start_; |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 EXPECT_EQ(1, host_.pending_requests()); | 1222 EXPECT_EQ(1, host_.pending_requests()); |
| 1221 | 1223 |
| 1222 // Cancelling by other methods shouldn't work either. | 1224 // Cancelling by other methods shouldn't work either. |
| 1223 host_.CancelRequestsForProcess(render_view_id); | 1225 host_.CancelRequestsForProcess(render_view_id); |
| 1224 EXPECT_EQ(1, host_.pending_requests()); | 1226 EXPECT_EQ(1, host_.pending_requests()); |
| 1225 | 1227 |
| 1226 // Cancelling by context should work. | 1228 // Cancelling by context should work. |
| 1227 host_.CancelRequestsForContext(&filter_->resource_context()); | 1229 host_.CancelRequestsForContext(&filter_->resource_context()); |
| 1228 EXPECT_EQ(0, host_.pending_requests()); | 1230 EXPECT_EQ(0, host_.pending_requests()); |
| 1229 } | 1231 } |
| OLD | NEW |