Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: content/network/url_loader_unittest.cc

Issue 2893233002: Network traffic annotation added to URLLoaderImpl. (Closed)
Patch Set: Changed ParamTraits to StructTraits. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 72
72 void Load(const GURL& url, 73 void Load(const GURL& url,
73 TestURLLoaderClient* client, 74 TestURLLoaderClient* client,
74 uint32_t options = 0) { 75 uint32_t options = 0) {
75 mojom::URLLoaderAssociatedPtr loader; 76 mojom::URLLoaderAssociatedPtr loader;
76 77
77 ResourceRequest request = 78 ResourceRequest request =
78 CreateResourceRequest("GET", RESOURCE_TYPE_MAIN_FRAME, url); 79 CreateResourceRequest("GET", RESOURCE_TYPE_MAIN_FRAME, url);
79 80
80 URLLoaderImpl loader_impl(context(), mojo::MakeIsolatedRequest(&loader), 81 URLLoaderImpl loader_impl(context(), mojo::MakeIsolatedRequest(&loader),
81 options, request, client->CreateInterfacePtr()); 82 options, request, client->CreateInterfacePtr(),
83 TRAFFIC_ANNOTATION_FOR_TESTS);
82 84
83 client->RunUntilComplete(); 85 client->RunUntilComplete();
84 } 86 }
85 87
86 void LoadAndCompareFile(const std::string& path) { 88 void LoadAndCompareFile(const std::string& path) {
87 TestURLLoaderClient client; 89 TestURLLoaderClient client;
88 GURL url = test_server()->GetURL(std::string("/") + path); 90 GURL url = test_server()->GetURL(std::string("/") + path);
89 Load(url, &client); 91 Load(url, &client);
90 92
91 base::FilePath file; 93 base::FilePath file;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); 140 base::FilePath(FILE_PATH_LITERAL("content/test/data")));
139 ASSERT_TRUE(https_server.Start()); 141 ASSERT_TRUE(https_server.Start());
140 142
141 TestURLLoaderClient client; 143 TestURLLoaderClient client;
142 GURL url = https_server.GetURL("/simple_page.html"); 144 GURL url = https_server.GetURL("/simple_page.html");
143 Load(url, &client, 0); 145 Load(url, &client, 0);
144 ASSERT_FALSE(!!client.ssl_info()); 146 ASSERT_FALSE(!!client.ssl_info());
145 } 147 }
146 148
147 } // namespace content 149 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698