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

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

Issue 2954853002: Use Independent URLLoader
Patch Set: . Created 3 years, 5 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 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/browser/loader/mojo_async_resource_handler.h" 5 #include "content/browser/loader/mojo_async_resource_handler.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 private: 201 private:
202 DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcherHostDelegate); 202 DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcherHostDelegate);
203 }; 203 };
204 204
205 class MojoAsyncResourceHandlerWithStubOperations 205 class MojoAsyncResourceHandlerWithStubOperations
206 : public MojoAsyncResourceHandler { 206 : public MojoAsyncResourceHandler {
207 public: 207 public:
208 MojoAsyncResourceHandlerWithStubOperations( 208 MojoAsyncResourceHandlerWithStubOperations(
209 net::URLRequest* request, 209 net::URLRequest* request,
210 ResourceDispatcherHostImpl* rdh, 210 ResourceDispatcherHostImpl* rdh,
211 mojom::URLLoaderAssociatedRequest mojo_request, 211 mojom::URLLoaderRequest mojo_request,
212 mojom::URLLoaderClientPtr url_loader_client) 212 mojom::URLLoaderClientPtr url_loader_client)
213 : MojoAsyncResourceHandler(request, 213 : MojoAsyncResourceHandler(request,
214 rdh, 214 rdh,
215 std::move(mojo_request), 215 std::move(mojo_request),
216 std::move(url_loader_client), 216 std::move(url_loader_client),
217 RESOURCE_TYPE_MAIN_FRAME), 217 RESOURCE_TYPE_MAIN_FRAME),
218 task_runner_(new base::TestSimpleTaskRunner) {} 218 task_runner_(new base::TestSimpleTaskRunner) {}
219 ~MojoAsyncResourceHandlerWithStubOperations() override {} 219 ~MojoAsyncResourceHandlerWithStubOperations() override {}
220 220
221 void ResetBeginWriteExpectation() { is_begin_write_expectation_set_ = false; } 221 void ResetBeginWriteExpectation() { is_begin_write_expectation_set_ = false; }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 284 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
285 285
286 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandlerWithStubOperations); 286 DISALLOW_COPY_AND_ASSIGN(MojoAsyncResourceHandlerWithStubOperations);
287 }; 287 };
288 288
289 class TestURLLoaderFactory final : public mojom::URLLoaderFactory { 289 class TestURLLoaderFactory final : public mojom::URLLoaderFactory {
290 public: 290 public:
291 TestURLLoaderFactory() {} 291 TestURLLoaderFactory() {}
292 ~TestURLLoaderFactory() override {} 292 ~TestURLLoaderFactory() override {}
293 293
294 void CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest request, 294 void CreateLoaderAndStart(mojom::URLLoaderRequest request,
295 int32_t routing_id, 295 int32_t routing_id,
296 int32_t request_id, 296 int32_t request_id,
297 uint32_t options, 297 uint32_t options,
298 const ResourceRequest& url_request, 298 const ResourceRequest& url_request,
299 mojom::URLLoaderClientPtr client_ptr, 299 mojom::URLLoaderClientPtr client_ptr,
300 const net::MutableNetworkTrafficAnnotationTag& 300 const net::MutableNetworkTrafficAnnotationTag&
301 traffic_annotation) override { 301 traffic_annotation) override {
302 loader_request_ = std::move(request); 302 loader_request_ = std::move(request);
303 client_ptr_ = std::move(client_ptr); 303 client_ptr_ = std::move(client_ptr);
304 } 304 }
305 305
306 mojom::URLLoaderAssociatedRequest PassLoaderRequest() { 306 mojom::URLLoaderRequest PassLoaderRequest() {
307 return std::move(loader_request_); 307 return std::move(loader_request_);
308 } 308 }
309 309
310 mojom::URLLoaderClientPtr PassClientPtr() { return std::move(client_ptr_); } 310 mojom::URLLoaderClientPtr PassClientPtr() { return std::move(client_ptr_); }
311 311
312 void SyncLoad(int32_t routing_id, 312 void SyncLoad(int32_t routing_id,
313 int32_t request_id, 313 int32_t request_id,
314 const ResourceRequest& url_request, 314 const ResourceRequest& url_request,
315 SyncLoadCallback callback) override { 315 SyncLoadCallback callback) override {
316 NOTREACHED(); 316 NOTREACHED();
317 } 317 }
318 318
319 private: 319 private:
320 mojom::URLLoaderAssociatedRequest loader_request_; 320 mojom::URLLoaderRequest loader_request_;
321 mojom::URLLoaderClientPtr client_ptr_; 321 mojom::URLLoaderClientPtr client_ptr_;
322 322
323 DISALLOW_COPY_AND_ASSIGN(TestURLLoaderFactory); 323 DISALLOW_COPY_AND_ASSIGN(TestURLLoaderFactory);
324 }; 324 };
325 325
326 class MojoAsyncResourceHandlerTestBase { 326 class MojoAsyncResourceHandlerTestBase {
327 public: 327 public:
328 explicit MojoAsyncResourceHandlerTestBase( 328 explicit MojoAsyncResourceHandlerTestBase(
329 std::unique_ptr<net::UploadDataStream> upload_stream) 329 std::unique_ptr<net::UploadDataStream> upload_stream)
330 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), 330 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP),
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 handler_->upload_progress_tracker()->upload_progress_ = upload_progress; 415 handler_->upload_progress_tracker()->upload_progress_ = upload_progress;
416 } 416 }
417 void AdvanceCurrentTime(const base::TimeDelta& delta) { 417 void AdvanceCurrentTime(const base::TimeDelta& delta) {
418 handler_->upload_progress_tracker()->current_time_ += delta; 418 handler_->upload_progress_tracker()->current_time_ += delta;
419 } 419 }
420 420
421 TestBrowserThreadBundle thread_bundle_; 421 TestBrowserThreadBundle thread_bundle_;
422 TestResourceDispatcherHostDelegate rdh_delegate_; 422 TestResourceDispatcherHostDelegate rdh_delegate_;
423 ResourceDispatcherHostImpl rdh_; 423 ResourceDispatcherHostImpl rdh_;
424 mojom::URLLoaderFactoryPtr url_loader_factory_; 424 mojom::URLLoaderFactoryPtr url_loader_factory_;
425 mojom::URLLoaderAssociatedPtr url_loader_proxy_; 425 mojom::URLLoaderPtr url_loader_proxy_;
426 TestURLLoaderClient url_loader_client_; 426 TestURLLoaderClient url_loader_client_;
427 std::unique_ptr<TestBrowserContext> browser_context_; 427 std::unique_ptr<TestBrowserContext> browser_context_;
428 net::TestDelegate url_request_delegate_; 428 net::TestDelegate url_request_delegate_;
429 std::unique_ptr<net::URLRequest> request_; 429 std::unique_ptr<net::URLRequest> request_;
430 std::unique_ptr<MojoAsyncResourceHandlerWithStubOperations> handler_; 430 std::unique_ptr<MojoAsyncResourceHandlerWithStubOperations> handler_;
431 std::unique_ptr<MockResourceLoader> mock_loader_; 431 std::unique_ptr<MockResourceLoader> mock_loader_;
432 432
433 static constexpr int kChildId = 25; 433 static constexpr int kChildId = 25;
434 static constexpr int kRouteId = 12; 434 static constexpr int kRouteId = 12;
435 static constexpr int kRequestId = 41; 435 static constexpr int kRequestId = 41;
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 } 1362 }
1363 } 1363 }
1364 EXPECT_EQ("B", body); 1364 EXPECT_EQ("B", body);
1365 } 1365 }
1366 1366
1367 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest, 1367 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest,
1368 MojoAsyncResourceHandlerWithAllocationSizeTest, 1368 MojoAsyncResourceHandlerWithAllocationSizeTest,
1369 ::testing::Values(8, 32 * 2014)); 1369 ::testing::Values(8, 32 * 2014));
1370 } // namespace 1370 } // namespace
1371 } // namespace content 1371 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/mojo_async_resource_handler.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