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

Side by Side Diff: webkit/fileapi/file_writer_delegate_unittest.cc

Issue 10870060: Removed calls to URLRequest::URLRequest in favor of URLRequestContext::CreateRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 // Creates and sets up a FileWriterDelegate for writing the given |blob_url|, 108 // Creates and sets up a FileWriterDelegate for writing the given |blob_url|,
109 // and creates a new FileWriterDelegate for the file. 109 // and creates a new FileWriterDelegate for the file.
110 void PrepareForWrite(const GURL& blob_url, 110 void PrepareForWrite(const GURL& blob_url,
111 int64 offset, 111 int64 offset,
112 int64 allowed_growth) { 112 int64 allowed_growth) {
113 result_.reset(new Result()); 113 result_.reset(new Result());
114 file_writer_delegate_.reset( 114 file_writer_delegate_.reset(
115 CreateWriterDelegate("test", offset, allowed_growth, result_.get())); 115 CreateWriterDelegate("test", offset, allowed_growth, result_.get()));
116 request_.reset(new net::URLRequest(blob_url, 116 request_.reset(empty_context_.CreateRequest(
117 file_writer_delegate_.get(), 117 blob_url, file_writer_delegate_.get()));
118 &empty_context_));
119 } 118 }
120 119
121 static net::URLRequest::ProtocolFactory Factory; 120 static net::URLRequest::ProtocolFactory Factory;
122 121
123 // This should be alive until the very end of this instance. 122 // This should be alive until the very end of this instance.
124 MessageLoop loop_; 123 MessageLoop loop_;
125 124
126 net::URLRequestContext empty_context_; 125 net::URLRequestContext empty_context_;
127 scoped_ptr<FileWriterDelegate> file_writer_delegate_; 126 scoped_ptr<FileWriterDelegate> file_writer_delegate_;
128 scoped_ptr<net::URLRequest> request_; 127 scoped_ptr<net::URLRequest> request_;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 const GURL kBlobURL("blob:nolimitconcurrent"); 336 const GURL kBlobURL("blob:nolimitconcurrent");
338 const GURL kBlobURL2("blob:nolimitconcurrent2"); 337 const GURL kBlobURL2("blob:nolimitconcurrent2");
339 content_ = kData; 338 content_ = kData;
340 339
341 PrepareForWrite(kBlobURL, 0, quota::QuotaManager::kNoLimit); 340 PrepareForWrite(kBlobURL, 0, quota::QuotaManager::kNoLimit);
342 341
343 // Credate another FileWriterDelegate for concurrent write. 342 // Credate another FileWriterDelegate for concurrent write.
344 result2.reset(new Result()); 343 result2.reset(new Result());
345 file_writer_delegate2.reset(CreateWriterDelegate( 344 file_writer_delegate2.reset(CreateWriterDelegate(
346 "test2", 0, quota::QuotaManager::kNoLimit, result2.get())); 345 "test2", 0, quota::QuotaManager::kNoLimit, result2.get()));
347 request2.reset(new net::URLRequest(kBlobURL2, 346 request2.reset(empty_context_.CreateRequest(
348 file_writer_delegate2.get(), 347 kBlobURL2, file_writer_delegate2.get()));
349 &empty_context_));
350 348
351 ASSERT_EQ(0, test_helper_.GetCachedOriginUsage()); 349 ASSERT_EQ(0, test_helper_.GetCachedOriginUsage());
352 file_writer_delegate_->Start(request_.Pass()); 350 file_writer_delegate_->Start(request_.Pass());
353 file_writer_delegate2->Start(request2.Pass()); 351 file_writer_delegate2->Start(request2.Pass());
354 MessageLoop::current()->Run(); 352 MessageLoop::current()->Run();
355 if (!result_->complete() || !result2->complete()) 353 if (!result_->complete() || !result2->complete())
356 MessageLoop::current()->Run(); 354 MessageLoop::current()->Run();
357 355
358 ASSERT_TRUE(result_->complete()); 356 ASSERT_TRUE(result_->complete());
359 ASSERT_TRUE(result2->complete()); 357 ASSERT_TRUE(result2->complete());
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 file_writer_delegate_.reset(); 455 file_writer_delegate_.reset();
458 456
459 EXPECT_EQ(pre_write_usage + allowed_growth, 457 EXPECT_EQ(pre_write_usage + allowed_growth,
460 test_helper_.GetCachedOriginUsage()); 458 test_helper_.GetCachedOriginUsage());
461 EXPECT_EQ(ComputeCurrentOriginUsage(), test_helper_.GetCachedOriginUsage()); 459 EXPECT_EQ(ComputeCurrentOriginUsage(), test_helper_.GetCachedOriginUsage());
462 EXPECT_EQ(kOverlap + allowed_growth, result_->bytes_written()); 460 EXPECT_EQ(kOverlap + allowed_growth, result_->bytes_written());
463 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, result_->status()); 461 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, result_->status());
464 } 462 }
465 463
466 } // namespace fileapi 464 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_url_request_job_unittest.cc ('k') | webkit/fileapi/local_file_system_operation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698