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

Side by Side Diff: content/browser/fileapi/file_writer_delegate_unittest.cc

Issue 51953002: [Net] Add a priority parameter to URLRequest's constructor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "content/public/test/test_file_system_context.h" 14 #include "content/public/test/test_file_system_context.h"
15 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
16 #include "net/base/request_priority.h"
16 #include "net/url_request/url_request.h" 17 #include "net/url_request/url_request.h"
17 #include "net/url_request/url_request_context.h" 18 #include "net/url_request/url_request_context.h"
18 #include "net/url_request/url_request_job.h" 19 #include "net/url_request/url_request_job.h"
19 #include "net/url_request/url_request_status.h" 20 #include "net/url_request/url_request_status.h"
20 #include "testing/platform_test.h" 21 #include "testing/platform_test.h"
21 #include "url/gurl.h" 22 #include "url/gurl.h"
22 #include "webkit/browser/fileapi/async_file_test_helper.h" 23 #include "webkit/browser/fileapi/async_file_test_helper.h"
23 #include "webkit/browser/fileapi/file_system_context.h" 24 #include "webkit/browser/fileapi/file_system_context.h"
24 #include "webkit/browser/fileapi/file_system_quota_util.h" 25 #include "webkit/browser/fileapi/file_system_quota_util.h"
25 #include "webkit/browser/fileapi/file_writer_delegate.h" 26 #include "webkit/browser/fileapi/file_writer_delegate.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 123 }
123 124
124 // Creates and sets up a FileWriterDelegate for writing the given |blob_url|, 125 // Creates and sets up a FileWriterDelegate for writing the given |blob_url|,
125 // and creates a new FileWriterDelegate for the file. 126 // and creates a new FileWriterDelegate for the file.
126 void PrepareForWrite(const char* test_file_path, 127 void PrepareForWrite(const char* test_file_path,
127 const GURL& blob_url, 128 const GURL& blob_url,
128 int64 offset, 129 int64 offset,
129 int64 allowed_growth) { 130 int64 allowed_growth) {
130 file_writer_delegate_.reset( 131 file_writer_delegate_.reset(
131 CreateWriterDelegate(test_file_path, offset, allowed_growth)); 132 CreateWriterDelegate(test_file_path, offset, allowed_growth));
132 request_.reset(empty_context_.CreateRequest( 133 request_ = empty_context_.CreateRequest(
133 blob_url, file_writer_delegate_.get())); 134 blob_url, net::DEFAULT_PRIORITY, file_writer_delegate_.get());
134 } 135 }
135 136
136 static net::URLRequest::ProtocolFactory Factory; 137 static net::URLRequest::ProtocolFactory Factory;
137 138
138 // This should be alive until the very end of this instance. 139 // This should be alive until the very end of this instance.
139 base::MessageLoopForIO loop_; 140 base::MessageLoopForIO loop_;
140 141
141 scoped_refptr<FileSystemContext> file_system_context_; 142 scoped_refptr<FileSystemContext> file_system_context_;
142 143
143 net::URLRequestContext empty_context_; 144 net::URLRequestContext empty_context_;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 file_system_context_, GetFileSystemURL("test2"))); 320 file_system_context_, GetFileSystemURL("test2")));
320 321
321 const GURL kBlobURL("blob:nolimitconcurrent"); 322 const GURL kBlobURL("blob:nolimitconcurrent");
322 const GURL kBlobURL2("blob:nolimitconcurrent2"); 323 const GURL kBlobURL2("blob:nolimitconcurrent2");
323 content_ = kData; 324 content_ = kData;
324 325
325 PrepareForWrite("test", kBlobURL, 0, kint64max); 326 PrepareForWrite("test", kBlobURL, 0, kint64max);
326 327
327 // Credate another FileWriterDelegate for concurrent write. 328 // Credate another FileWriterDelegate for concurrent write.
328 file_writer_delegate2.reset(CreateWriterDelegate("test2", 0, kint64max)); 329 file_writer_delegate2.reset(CreateWriterDelegate("test2", 0, kint64max));
329 request2.reset(empty_context_.CreateRequest( 330 request2 = empty_context_.CreateRequest(
330 kBlobURL2, file_writer_delegate2.get())); 331 kBlobURL2, net::DEFAULT_PRIORITY, file_writer_delegate2.get());
331 332
332 Result result, result2; 333 Result result, result2;
333 ASSERT_EQ(0, usage()); 334 ASSERT_EQ(0, usage());
334 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); 335 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result));
335 file_writer_delegate2->Start(request2.Pass(), GetWriteCallback(&result2)); 336 file_writer_delegate2->Start(request2.Pass(), GetWriteCallback(&result2));
336 base::MessageLoop::current()->Run(); 337 base::MessageLoop::current()->Run();
337 if (result.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING || 338 if (result.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING ||
338 result2.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING) 339 result2.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING)
339 base::MessageLoop::current()->Run(); 340 base::MessageLoop::current()->Run();
340 341
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 file_writer_delegate_.reset(); 446 file_writer_delegate_.reset();
446 447
447 EXPECT_EQ(pre_write_usage + allowed_growth, usage()); 448 EXPECT_EQ(pre_write_usage + allowed_growth, usage());
448 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); 449 EXPECT_EQ(GetFileSizeOnDisk("test"), usage());
449 EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written()); 450 EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written());
450 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, result.status()); 451 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, result.status());
451 } 452 }
452 } 453 }
453 454
454 } // namespace fileapi 455 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698