OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/child/url_response_body_consumer.h" | 5 #include "content/child/url_response_body_consumer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.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/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "content/child/request_extra_data.h" | 12 #include "content/child/request_extra_data.h" |
13 #include "content/child/resource_dispatcher.h" | 13 #include "content/child/resource_dispatcher.h" |
14 #include "content/common/resource_messages.h" | 14 #include "content/common/resource_messages.h" |
15 #include "content/common/resource_request.h" | 15 #include "content/common/resource_request.h" |
16 #include "content/common/resource_request_completion_status.h" | 16 #include "content/common/resource_request_completion_status.h" |
17 #include "content/common/service_worker/service_worker_types.h" | 17 #include "content/common/service_worker/service_worker_types.h" |
18 #include "content/public/child/request_peer.h" | 18 #include "content/public/child/request_peer.h" |
19 #include "content/public/common/request_context_frame_type.h" | 19 #include "content/public/common/request_context_frame_type.h" |
20 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 23 #include "url/origin.h" |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 class TestRequestPeer : public RequestPeer { | 29 class TestRequestPeer : public RequestPeer { |
29 public: | 30 public: |
30 struct Context; | 31 struct Context; |
31 explicit TestRequestPeer(Context* context) : context_(context) {} | 32 explicit TestRequestPeer(Context* context) : context_(context) {} |
32 | 33 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE; | 120 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE; |
120 options.element_num_bytes = 1; | 121 options.element_num_bytes = 1; |
121 options.capacity_num_bytes = 1024; | 122 options.capacity_num_bytes = 1024; |
122 return options; | 123 return options; |
123 } | 124 } |
124 | 125 |
125 // Returns the request id. | 126 // Returns the request id. |
126 int SetUpRequestPeer(std::unique_ptr<ResourceRequest> request, | 127 int SetUpRequestPeer(std::unique_ptr<ResourceRequest> request, |
127 TestRequestPeer::Context* context) { | 128 TestRequestPeer::Context* context) { |
128 return dispatcher_->StartAsync( | 129 return dispatcher_->StartAsync( |
129 std::move(request), 0, nullptr, GURL(), | 130 std::move(request), 0, nullptr, url::Origin(), |
130 base::MakeUnique<TestRequestPeer>(context), | 131 base::MakeUnique<TestRequestPeer>(context), |
131 blink::WebURLRequest::LoadingIPCType::ChromeIPC, nullptr, nullptr); | 132 blink::WebURLRequest::LoadingIPCType::ChromeIPC, nullptr, nullptr); |
132 } | 133 } |
133 | 134 |
134 void Run(TestRequestPeer::Context* context) { | 135 void Run(TestRequestPeer::Context* context) { |
135 base::RunLoop run_loop; | 136 base::RunLoop run_loop; |
136 context->run_loop_quit_closure = run_loop.QuitClosure(); | 137 context->run_loop_quit_closure = run_loop.QuitClosure(); |
137 run_loop.Run(); | 138 run_loop.Run(); |
138 } | 139 } |
139 | 140 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 Run(&context); | 221 Run(&context); |
221 | 222 |
222 EXPECT_TRUE(context.complete); | 223 EXPECT_TRUE(context.complete); |
223 EXPECT_EQ(net::ERR_FAILED, context.error_code); | 224 EXPECT_EQ(net::ERR_FAILED, context.error_code); |
224 EXPECT_EQ("", context.data); | 225 EXPECT_EQ("", context.data); |
225 } | 226 } |
226 | 227 |
227 } // namespace | 228 } // namespace |
228 | 229 |
229 } // namespace content | 230 } // namespace content |
OLD | NEW |