| 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 "content/public/renderer/resource_fetcher.h" | 5 #include "content/public/renderer/resource_fetcher.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "build/build_config.h" |
| 14 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
| 15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 17 #include "content/public/common/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
| 18 #include "content/public/renderer/render_view.h" | 19 #include "content/public/renderer/render_view.h" |
| 19 #include "content/public/test/content_browser_test.h" | 20 #include "content/public/test/content_browser_test.h" |
| 20 #include "content/public/test/content_browser_test_utils.h" | 21 #include "content/public/test/content_browser_test_utils.h" |
| 21 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
| 22 #include "content/shell/browser/shell.h" | 23 #include "content/shell/browser/shell.h" |
| 23 #include "net/test/embedded_test_server/embedded_test_server.h" | 24 #include "net/test/embedded_test_server/embedded_test_server.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 WebURLRequest::FrameTypeNone, | 280 WebURLRequest::FrameTypeNone, |
| 280 ResourceFetcher::PLATFORM_LOADER, | 281 ResourceFetcher::PLATFORM_LOADER, |
| 281 delegate->NewCallback()); | 282 delegate->NewCallback()); |
| 282 | 283 |
| 283 delegate->WaitForResponse(); | 284 delegate->WaitForResponse(); |
| 284 ASSERT_TRUE(delegate->completed()); | 285 ASSERT_TRUE(delegate->completed()); |
| 285 EXPECT_EQ(delegate->response().httpStatusCode(), 200); | 286 EXPECT_EQ(delegate->response().httpStatusCode(), 200); |
| 286 EXPECT_EQ(kHeader, delegate->data()); | 287 EXPECT_EQ(kHeader, delegate->data()); |
| 287 } | 288 } |
| 288 | 289 |
| 289 int32 render_view_routing_id_; | 290 int32_t render_view_routing_id_; |
| 290 }; | 291 }; |
| 291 | 292 |
| 292 // Test a fetch from the test server. | 293 // Test a fetch from the test server. |
| 293 // If this flakes, use http://crbug.com/51622. | 294 // If this flakes, use http://crbug.com/51622. |
| 294 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherDownload) { | 295 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherDownload) { |
| 295 // Need to spin up the renderer. | 296 // Need to spin up the renderer. |
| 296 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); | 297 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); |
| 297 | 298 |
| 298 ASSERT_TRUE(embedded_test_server()->Start()); | 299 ASSERT_TRUE(embedded_test_server()->Start()); |
| 299 GURL url(embedded_test_server()->GetURL("/simple_page.html")); | 300 GURL url(embedded_test_server()->GetURL("/simple_page.html")); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 ASSERT_TRUE(embedded_test_server()->Start()); | 382 ASSERT_TRUE(embedded_test_server()->Start()); |
| 382 GURL url(embedded_test_server()->GetURL("/echoheader?header")); | 383 GURL url(embedded_test_server()->GetURL("/echoheader?header")); |
| 383 | 384 |
| 384 PostTaskToInProcessRendererAndWait( | 385 PostTaskToInProcessRendererAndWait( |
| 385 base::Bind( | 386 base::Bind( |
| 386 &ResourceFetcherTests::ResourceFetcherSetHeader, | 387 &ResourceFetcherTests::ResourceFetcherSetHeader, |
| 387 base::Unretained(this), url)); | 388 base::Unretained(this), url)); |
| 388 } | 389 } |
| 389 | 390 |
| 390 } // namespace content | 391 } // namespace content |
| OLD | NEW |