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 "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 void URLRequestFileJobEventsTest::RunRequest(const std::string& content, | 182 void URLRequestFileJobEventsTest::RunRequest(const std::string& content, |
183 const Range* range) { | 183 const Range* range) { |
184 base::ScopedTempDir directory; | 184 base::ScopedTempDir directory; |
185 ASSERT_TRUE(directory.CreateUniqueTempDir()); | 185 ASSERT_TRUE(directory.CreateUniqueTempDir()); |
186 base::FilePath path; | 186 base::FilePath path; |
187 ASSERT_TRUE(CreateTempFileWithContent(content, directory, &path)); | 187 ASSERT_TRUE(CreateTempFileWithContent(content, directory, &path)); |
188 CallbacksJobFactory factory(path, &observer_); | 188 CallbacksJobFactory factory(path, &observer_); |
189 context_.set_job_factory(&factory); | 189 context_.set_job_factory(&factory); |
190 | 190 |
191 scoped_ptr<URLRequest> request(context_.CreateRequest( | 191 scoped_ptr<URLRequest> request(context_.CreateRequest( |
192 FilePathToFileURL(path), DEFAULT_PRIORITY, &delegate_, NULL)); | 192 FilePathToFileURL(path), DEFAULT_PRIORITY, &delegate_)); |
193 if (range) { | 193 if (range) { |
194 ASSERT_GE(range->start, 0); | 194 ASSERT_GE(range->start, 0); |
195 ASSERT_GE(range->end, 0); | 195 ASSERT_GE(range->end, 0); |
196 ASSERT_LE(range->start, range->end); | 196 ASSERT_LE(range->start, range->end); |
197 ASSERT_LT(static_cast<unsigned int>(range->end), content.length()); | 197 ASSERT_LT(static_cast<unsigned int>(range->end), content.length()); |
198 std::string range_value = | 198 std::string range_value = |
199 base::StringPrintf("bytes=%d-%d", range->start, range->end); | 199 base::StringPrintf("bytes=%d-%d", range->start, range->end); |
200 request->SetExtraRequestHeaderByName( | 200 request->SetExtraRequestHeaderByName( |
201 HttpRequestHeaders::kRange, range_value, true /*overwrite*/); | 201 HttpRequestHeaders::kRange, range_value, true /*overwrite*/); |
202 } | 202 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // Use a 15KB content file and read a range chosen somewhat arbitrarily but | 260 // Use a 15KB content file and read a range chosen somewhat arbitrarily but |
261 // not aligned on any likely page boundaries. | 261 // not aligned on any likely page boundaries. |
262 int size = 15 * 1024; | 262 int size = 15 * 1024; |
263 Range range(1701, (6 * 1024) + 3); | 263 Range range(1701, (6 * 1024) + 3); |
264 RunRequest(MakeContentOfSize(size), &range); | 264 RunRequest(MakeContentOfSize(size), &range); |
265 } | 265 } |
266 | 266 |
267 } // namespace | 267 } // namespace |
268 | 268 |
269 } // namespace net | 269 } // namespace net |
OLD | NEW |