| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "content/browser/loader/test_url_loader_client.h" | 10 #include "content/browser/loader/test_url_loader_client.h" |
| 11 #include "content/network/network_context.h" | 11 #include "content/network/network_context.h" |
| 12 #include "content/network/url_loader_impl.h" | 12 #include "content/network/url_loader_impl.h" |
| 13 #include "content/public/common/content_paths.h" | 13 #include "content/public/common/content_paths.h" |
| 14 #include "mojo/public/c/system/data_pipe.h" | 14 #include "mojo/public/c/system/data_pipe.h" |
| 15 #include "mojo/public/cpp/system/wait.h" | 15 #include "mojo/public/cpp/system/wait.h" |
| 16 #include "net/test/embedded_test_server/embedded_test_server.h" | 16 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 17 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 static ResourceRequest CreateResourceRequest(const char* method, | 24 static ResourceRequest CreateResourceRequest(const char* method, |
| 24 ResourceType type, | 25 ResourceType type, |
| 25 const GURL& url) { | 26 const GURL& url) { |
| 26 ResourceRequest request; | 27 ResourceRequest request; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 77 |
| 77 void Load(const GURL& url, | 78 void Load(const GURL& url, |
| 78 TestURLLoaderClient* client, | 79 TestURLLoaderClient* client, |
| 79 uint32_t options = 0) { | 80 uint32_t options = 0) { |
| 80 mojom::URLLoaderAssociatedPtr loader; | 81 mojom::URLLoaderAssociatedPtr loader; |
| 81 | 82 |
| 82 ResourceRequest request = | 83 ResourceRequest request = |
| 83 CreateResourceRequest("GET", RESOURCE_TYPE_MAIN_FRAME, url); | 84 CreateResourceRequest("GET", RESOURCE_TYPE_MAIN_FRAME, url); |
| 84 | 85 |
| 85 URLLoaderImpl loader_impl(context(), mojo::MakeIsolatedRequest(&loader), | 86 URLLoaderImpl loader_impl(context(), mojo::MakeIsolatedRequest(&loader), |
| 86 options, request, client->CreateInterfacePtr()); | 87 options, request, client->CreateInterfacePtr(), |
| 88 TRAFFIC_ANNOTATION_FOR_TESTS); |
| 87 | 89 |
| 88 client->RunUntilComplete(); | 90 client->RunUntilComplete(); |
| 89 } | 91 } |
| 90 | 92 |
| 91 void LoadAndCompareFile(const std::string& path) { | 93 void LoadAndCompareFile(const std::string& path) { |
| 92 TestURLLoaderClient client; | 94 TestURLLoaderClient client; |
| 93 GURL url = test_server()->GetURL(std::string("/") + path); | 95 GURL url = test_server()->GetURL(std::string("/") + path); |
| 94 Load(url, &client); | 96 Load(url, &client); |
| 95 | 97 |
| 96 base::FilePath file; | 98 base::FilePath file; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 149 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
| 148 ASSERT_TRUE(https_server.Start()); | 150 ASSERT_TRUE(https_server.Start()); |
| 149 | 151 |
| 150 TestURLLoaderClient client; | 152 TestURLLoaderClient client; |
| 151 GURL url = https_server.GetURL("/simple_page.html"); | 153 GURL url = https_server.GetURL("/simple_page.html"); |
| 152 Load(url, &client, 0); | 154 Load(url, &client, 0); |
| 153 ASSERT_FALSE(!!client.ssl_info()); | 155 ASSERT_FALSE(!!client.ssl_info()); |
| 154 } | 156 } |
| 155 | 157 |
| 156 } // namespace content | 158 } // namespace content |
| OLD | NEW |