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

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

Issue 2646343007: [Mojo-Loading] Implement URLLoader::SetPriority (Closed)
Patch Set: fix Created 3 years, 11 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>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "content/browser/loader/mock_resource_loader.h" 18 #include "content/browser/loader/mock_resource_loader.h"
19 #include "content/browser/loader/resource_controller.h" 19 #include "content/browser/loader/resource_controller.h"
20 #include "content/browser/loader/resource_dispatcher_host_impl.h" 20 #include "content/browser/loader/resource_dispatcher_host_impl.h"
21 #include "content/browser/loader/resource_request_info_impl.h" 21 #include "content/browser/loader/resource_request_info_impl.h"
22 #include "content/browser/loader/resource_scheduler.h"
22 #include "content/browser/loader/test_url_loader_client.h" 23 #include "content/browser/loader/test_url_loader_client.h"
23 #include "content/common/resource_request_completion_status.h" 24 #include "content/common/resource_request_completion_status.h"
24 #include "content/common/url_loader.mojom.h" 25 #include "content/common/url_loader.mojom.h"
25 #include "content/public/browser/appcache_service.h" 26 #include "content/public/browser/appcache_service.h"
26 #include "content/public/browser/navigation_data.h" 27 #include "content/public/browser/navigation_data.h"
27 #include "content/public/browser/resource_context.h" 28 #include "content/public/browser/resource_context.h"
28 #include "content/public/browser/resource_dispatcher_host_delegate.h" 29 #include "content/public/browser/resource_dispatcher_host_delegate.h"
29 #include "content/public/browser/resource_throttle.h" 30 #include "content/public/browser/resource_throttle.h"
30 #include "content/public/browser/stream_info.h" 31 #include "content/public/browser/stream_info.h"
31 #include "content/public/common/previews_state.h" 32 #include "content/public/common/previews_state.h"
32 #include "content/public/common/resource_response.h" 33 #include "content/public/common/resource_response.h"
33 #include "content/public/common/resource_type.h" 34 #include "content/public/common/resource_type.h"
34 #include "content/public/test/test_browser_context.h" 35 #include "content/public/test/test_browser_context.h"
35 #include "content/public/test/test_browser_thread_bundle.h" 36 #include "content/public/test/test_browser_thread_bundle.h"
36 #include "mojo/public/c/system/data_pipe.h" 37 #include "mojo/public/c/system/data_pipe.h"
37 #include "mojo/public/c/system/types.h" 38 #include "mojo/public/c/system/types.h"
38 #include "mojo/public/cpp/bindings/strong_binding.h" 39 #include "mojo/public/cpp/bindings/strong_binding.h"
39 #include "mojo/public/cpp/system/data_pipe.h" 40 #include "mojo/public/cpp/system/data_pipe.h"
40 #include "net/base/auth.h" 41 #include "net/base/auth.h"
41 #include "net/base/net_errors.h" 42 #include "net/base/net_errors.h"
43 #include "net/base/request_priority.h"
42 #include "net/http/http_response_headers.h" 44 #include "net/http/http_response_headers.h"
43 #include "net/http/http_response_info.h" 45 #include "net/http/http_response_info.h"
44 #include "net/http/http_status_code.h" 46 #include "net/http/http_status_code.h"
45 #include "net/http/http_util.h" 47 #include "net/http/http_util.h"
46 #include "net/ssl/client_cert_store.h" 48 #include "net/ssl/client_cert_store.h"
47 #include "net/url_request/url_request.h" 49 #include "net/url_request/url_request.h"
48 #include "net/url_request/url_request_context.h" 50 #include "net/url_request/url_request_context.h"
49 #include "net/url_request/url_request_status.h" 51 #include "net/url_request/url_request_status.h"
50 #include "net/url_request/url_request_test_util.h" 52 #include "net/url_request/url_request_test_util.h"
51 #include "testing/gtest/include/gtest/gtest.h" 53 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 ASSERT_EQ(MOJO_RESULT_OK, result); 794 ASSERT_EQ(MOJO_RESULT_OK, result);
793 } 795 }
794 796
795 handler_->set_end_write_expectation(MOJO_RESULT_SHOULD_WAIT); 797 handler_->set_end_write_expectation(MOJO_RESULT_SHOULD_WAIT);
796 mock_loader_->WaitUntilIdleOrCanceled(); 798 mock_loader_->WaitUntilIdleOrCanceled();
797 EXPECT_FALSE(url_loader_client_.has_received_completion()); 799 EXPECT_FALSE(url_loader_client_.has_received_completion());
798 EXPECT_EQ(MockResourceLoader::Status::CANCELED, mock_loader_->status()); 800 EXPECT_EQ(MockResourceLoader::Status::CANCELED, mock_loader_->status());
799 EXPECT_EQ(net::ERR_FAILED, mock_loader_->error_code()); 801 EXPECT_EQ(net::ERR_FAILED, mock_loader_->error_code());
800 } 802 }
801 803
804 TEST_F(MojoAsyncResourceHandlerTest, SetPriority) {
805 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
806 std::unique_ptr<ResourceThrottle> throttle =
807 ResourceDispatcherHostImpl::Get()->scheduler()->ScheduleRequest(
808 4, 2, false, request_.get());
mmenke 2017/01/24 16:57:52 Should label the 4 and 2 with comments.
yhirano 2017/01/27 07:53:55 I gave names to these values.
809
810 EXPECT_EQ(net::LOWEST, request_->priority());
811
812 handler_->SetPriority(mojom::RequestPriority::kHighest, 4);
mmenke 2017/01/24 16:57:52 Please label this 4 as well.
yhirano 2017/01/27 07:53:55 I gave a name to the value.
813
814 EXPECT_EQ(net::HIGHEST, request_->priority());
815 }
816
802 TEST_P(MojoAsyncResourceHandlerWithAllocationSizeTest, 817 TEST_P(MojoAsyncResourceHandlerWithAllocationSizeTest,
803 OnWillReadWithLongContents) { 818 OnWillReadWithLongContents) {
804 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted()); 819 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
805 ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead(-1)); 820 ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead(-1));
806 std::string expected; 821 std::string expected;
807 for (int i = 0; i < 3 * mock_loader_->io_buffer_size() + 2; ++i) 822 for (int i = 0; i < 3 * mock_loader_->io_buffer_size() + 2; ++i)
808 expected += ('A' + i % 26); 823 expected += ('A' + i % 26);
809 824
810 ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnReadCompleted(0)); 825 ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnReadCompleted(0));
811 826
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 } 1131 }
1117 } 1132 }
1118 EXPECT_EQ("B", body); 1133 EXPECT_EQ("B", body);
1119 } 1134 }
1120 1135
1121 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest, 1136 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest,
1122 MojoAsyncResourceHandlerWithAllocationSizeTest, 1137 MojoAsyncResourceHandlerWithAllocationSizeTest,
1123 ::testing::Values(8, 32 * 2014)); 1138 ::testing::Values(8, 32 * 2014));
1124 } // namespace 1139 } // namespace
1125 } // namespace content 1140 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698