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

Side by Side Diff: content/browser/loader/navigation_url_loader_unittest.cc

Issue 2335133003: PlzNavigate: support the WebRequest API (Closed)
Patch Set: Rebase + addressed nit Created 4 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "content/browser/frame_host/navigation_request_info.h" 13 #include "content/browser/frame_host/navigation_request_info.h"
14 #include "content/browser/loader/navigation_url_loader_impl.h" 14 #include "content/browser/loader/navigation_url_loader_impl.h"
15 #include "content/browser/loader/resource_dispatcher_host_impl.h" 15 #include "content/browser/loader/resource_dispatcher_host_impl.h"
16 #include "content/browser/loader_delegate_impl.h" 16 #include "content/browser/loader_delegate_impl.h"
17 #include "content/browser/streams/stream.h" 17 #include "content/browser/streams/stream.h"
18 #include "content/browser/streams/stream_context.h" 18 #include "content/browser/streams/stream_context.h"
19 #include "content/browser/streams/stream_registry.h" 19 #include "content/browser/streams/stream_registry.h"
20 #include "content/browser/streams/stream_url_request_job.h" 20 #include "content/browser/streams/stream_url_request_job.h"
21 #include "content/common/navigation_params.h" 21 #include "content/common/navigation_params.h"
22 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
23 #include "content/public/browser/navigation_ui_data.h"
23 #include "content/public/browser/resource_context.h" 24 #include "content/public/browser/resource_context.h"
24 #include "content/public/browser/resource_dispatcher_host_delegate.h" 25 #include "content/public/browser/resource_dispatcher_host_delegate.h"
25 #include "content/public/browser/stream_handle.h" 26 #include "content/public/browser/stream_handle.h"
26 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
27 #include "content/public/common/resource_response.h" 28 #include "content/public/common/resource_response.h"
28 #include "content/public/test/test_browser_context.h" 29 #include "content/public/test/test_browser_context.h"
29 #include "content/public/test/test_browser_thread_bundle.h" 30 #include "content/public/test/test_browser_thread_bundle.h"
30 #include "content/test/test_navigation_url_loader_delegate.h" 31 #include "content/test/test_navigation_url_loader_delegate.h"
31 #include "net/base/load_flags.h" 32 #include "net/base/load_flags.h"
32 #include "net/base/net_errors.h" 33 #include "net/base/net_errors.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 const GURL& url, 107 const GURL& url,
107 NavigationURLLoaderDelegate* delegate) { 108 NavigationURLLoaderDelegate* delegate) {
108 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, false, 109 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, false,
109 false, REQUEST_CONTEXT_TYPE_LOCATION); 110 false, REQUEST_CONTEXT_TYPE_LOCATION);
110 CommonNavigationParams common_params; 111 CommonNavigationParams common_params;
111 common_params.url = url; 112 common_params.url = url;
112 std::unique_ptr<NavigationRequestInfo> request_info( 113 std::unique_ptr<NavigationRequestInfo> request_info(
113 new NavigationRequestInfo(common_params, begin_params, url, 114 new NavigationRequestInfo(common_params, begin_params, url,
114 url::Origin(url), true, false, false, -1)); 115 url::Origin(url), true, false, false, -1));
115 116
116 return NavigationURLLoader::Create( 117 return NavigationURLLoader::Create(browser_context_.get(),
117 browser_context_.get(), std::move(request_info), nullptr, delegate); 118 std::move(request_info), nullptr,
119 nullptr, delegate);
118 } 120 }
119 121
120 // Helper function for fetching the body of a URL to a string. 122 // Helper function for fetching the body of a URL to a string.
121 std::string FetchURL(const GURL& url) { 123 std::string FetchURL(const GURL& url) {
122 net::TestDelegate delegate; 124 net::TestDelegate delegate;
123 net::URLRequestContext* request_context = 125 net::URLRequestContext* request_context =
124 browser_context_->GetResourceContext()->GetRequestContext(); 126 browser_context_->GetResourceContext()->GetRequestContext();
125 std::unique_ptr<net::URLRequest> request( 127 std::unique_ptr<net::URLRequest> request(
126 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, &delegate)); 128 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, &delegate));
127 request->Start(); 129 request->Start();
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 332
331 // Release the body. 333 // Release the body.
332 delegate.ReleaseBody(); 334 delegate.ReleaseBody();
333 base::RunLoop().RunUntilIdle(); 335 base::RunLoop().RunUntilIdle();
334 336
335 // Verify that URLRequestTestJob no longer has anything paused. 337 // Verify that URLRequestTestJob no longer has anything paused.
336 EXPECT_FALSE(net::URLRequestTestJob::ProcessOnePendingMessage()); 338 EXPECT_FALSE(net::URLRequestTestJob::ProcessOnePendingMessage());
337 } 339 }
338 340
339 } // namespace content 341 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/navigation_url_loader_impl_core.cc ('k') | content/browser/loader/resource_dispatcher_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698