OLD | NEW |
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 "net/url_request/url_request_file_job.h" | 5 #include "net/url_request/url_request_file_job.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
17 #include "net/base/filename_util.h" | 17 #include "net/base/filename_util.h" |
18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 19 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
19 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
20 #include "net/url_request/url_request_test_util.h" | 21 #include "net/url_request/url_request_test_util.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 namespace net { | 24 namespace net { |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 // A URLRequestFileJob for testing values passed to OnSeekComplete and | 28 // A URLRequestFileJob for testing values passed to OnSeekComplete and |
28 // OnReadComplete. | 29 // OnReadComplete. |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 const base::FilePath& path, | 288 const base::FilePath& path, |
288 const std::string& range, | 289 const std::string& range, |
289 int* open_result, | 290 int* open_result, |
290 int64_t* seek_position, | 291 int64_t* seek_position, |
291 bool* done_reading, | 292 bool* done_reading, |
292 std::string* observed_content) { | 293 std::string* observed_content) { |
293 TestJobFactory factory(path, open_result, seek_position, done_reading, | 294 TestJobFactory factory(path, open_result, seek_position, done_reading, |
294 observed_content); | 295 observed_content); |
295 context_.set_job_factory(&factory); | 296 context_.set_job_factory(&factory); |
296 | 297 |
297 std::unique_ptr<URLRequest> request(context_.CreateRequest( | 298 std::unique_ptr<URLRequest> request( |
298 FilePathToFileURL(path), DEFAULT_PRIORITY, &delegate_)); | 299 context_.CreateRequest(FilePathToFileURL(path), DEFAULT_PRIORITY, |
| 300 &delegate_, TRAFFIC_ANNOTATION_FOR_TESTS)); |
299 if (!range.empty()) { | 301 if (!range.empty()) { |
300 request->SetExtraRequestHeaderByName(HttpRequestHeaders::kRange, range, | 302 request->SetExtraRequestHeaderByName(HttpRequestHeaders::kRange, range, |
301 true /*overwrite*/); | 303 true /*overwrite*/); |
302 } | 304 } |
303 request->Start(); | 305 request->Start(); |
304 | 306 |
305 base::RunLoop().Run(); | 307 base::RunLoop().Run(); |
306 } | 308 } |
307 | 309 |
308 // Helper function to make a character array filled with |size| bytes of | 310 // Helper function to make a character array filled with |size| bytes of |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 EXPECT_EQ(OK, open_result); | 428 EXPECT_EQ(OK, open_result); |
427 EXPECT_EQ(0, seek_position); | 429 EXPECT_EQ(0, seek_position); |
428 EXPECT_EQ("hello\n", observed_content); | 430 EXPECT_EQ("hello\n", observed_content); |
429 EXPECT_TRUE(done_reading); | 431 EXPECT_TRUE(done_reading); |
430 EXPECT_FALSE(delegate_.request_failed()); | 432 EXPECT_FALSE(delegate_.request_failed()); |
431 } | 433 } |
432 | 434 |
433 } // namespace | 435 } // namespace |
434 | 436 |
435 } // namespace net | 437 } // namespace net |
OLD | NEW |