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

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

Issue 1545243002: Convert Pass()→std::move() in //content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 scoped_ptr<disk_cache::Backend> CreateInMemoryDiskCache() { 76 scoped_ptr<disk_cache::Backend> CreateInMemoryDiskCache() {
77 scoped_ptr<disk_cache::Backend> cache; 77 scoped_ptr<disk_cache::Backend> cache;
78 net::TestCompletionCallback callback; 78 net::TestCompletionCallback callback;
79 int rv = disk_cache::CreateCacheBackend(net::MEMORY_CACHE, 79 int rv = disk_cache::CreateCacheBackend(net::MEMORY_CACHE,
80 net::CACHE_BACKEND_DEFAULT, 80 net::CACHE_BACKEND_DEFAULT,
81 base::FilePath(), 0, 81 base::FilePath(), 0,
82 false, nullptr, nullptr, &cache, 82 false, nullptr, nullptr, &cache,
83 callback.callback()); 83 callback.callback());
84 EXPECT_EQ(net::OK, callback.GetResult(rv)); 84 EXPECT_EQ(net::OK, callback.GetResult(rv));
85 85
86 return cache.Pass(); 86 return cache;
87 } 87 }
88 88
89 disk_cache::ScopedEntryPtr CreateDiskCacheEntry(disk_cache::Backend* cache, 89 disk_cache::ScopedEntryPtr CreateDiskCacheEntry(disk_cache::Backend* cache,
90 const char* key, 90 const char* key,
91 const std::string& data) { 91 const std::string& data) {
92 disk_cache::Entry* temp_entry = nullptr; 92 disk_cache::Entry* temp_entry = nullptr;
93 net::TestCompletionCallback callback; 93 net::TestCompletionCallback callback;
94 int rv = cache->CreateEntry(key, &temp_entry, callback.callback()); 94 int rv = cache->CreateEntry(key, &temp_entry, callback.callback());
95 if (callback.GetResult(rv) != net::OK) 95 if (callback.GetResult(rv) != net::OK)
96 return nullptr; 96 return nullptr;
97 disk_cache::ScopedEntryPtr entry(temp_entry); 97 disk_cache::ScopedEntryPtr entry(temp_entry);
98 98
99 scoped_refptr<net::StringIOBuffer> iobuffer = new net::StringIOBuffer(data); 99 scoped_refptr<net::StringIOBuffer> iobuffer = new net::StringIOBuffer(data);
100 rv = entry->WriteData(kTestDiskCacheStreamIndex, 0, iobuffer.get(), 100 rv = entry->WriteData(kTestDiskCacheStreamIndex, 0, iobuffer.get(),
101 iobuffer->size(), callback.callback(), false); 101 iobuffer->size(), callback.callback(), false);
102 EXPECT_EQ(static_cast<int>(data.size()), callback.GetResult(rv)); 102 EXPECT_EQ(static_cast<int>(data.size()), callback.GetResult(rv));
103 return entry.Pass(); 103 return entry;
104 } 104 }
105 105
106 } // namespace 106 } // namespace
107 107
108 class BlobURLRequestJobTest : public testing::Test { 108 class BlobURLRequestJobTest : public testing::Test {
109 public: 109 public:
110 // A simple ProtocolHandler implementation to create BlobURLRequestJob. 110 // A simple ProtocolHandler implementation to create BlobURLRequestJob.
111 class MockProtocolHandler : 111 class MockProtocolHandler :
112 public net::URLRequestJobFactory::ProtocolHandler { 112 public net::URLRequestJobFactory::ProtocolHandler {
113 public: 113 public:
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 blob_data_->AppendFile(temp_file2_, 5, 6, temp_file_modification_time2_); 281 blob_data_->AppendFile(temp_file2_, 5, 6, temp_file_modification_time2_);
282 *expected_result += std::string(kTestFileData2 + 5, 6); 282 *expected_result += std::string(kTestFileData2 + 5, 6);
283 283
284 blob_data_->AppendFileSystemFile(temp_file_system_file2_, 6, 7, 284 blob_data_->AppendFileSystemFile(temp_file_system_file2_, 6, 7,
285 temp_file_system_file_modification_time2_); 285 temp_file_system_file_modification_time2_);
286 *expected_result += std::string(kTestFileSystemFileData2 + 6, 7); 286 *expected_result += std::string(kTestFileSystemFileData2 + 6, 7);
287 } 287 }
288 288
289 storage::BlobDataHandle* GetHandleFromBuilder() { 289 storage::BlobDataHandle* GetHandleFromBuilder() {
290 if (!blob_handle_) { 290 if (!blob_handle_) {
291 blob_handle_ = blob_context_.AddFinishedBlob(blob_data_.get()).Pass(); 291 blob_handle_ = blob_context_.AddFinishedBlob(blob_data_.get());
292 } 292 }
293 return blob_handle_.get(); 293 return blob_handle_.get();
294 } 294 }
295 295
296 // This only works if all the Blob items have a definite pre-computed length. 296 // This only works if all the Blob items have a definite pre-computed length.
297 // Otherwise, this will fail a CHECK. 297 // Otherwise, this will fail a CHECK.
298 int64_t GetTotalBlobLength() { 298 int64_t GetTotalBlobLength() {
299 int64_t total = 0; 299 int64_t total = 0;
300 scoped_ptr<BlobDataSnapshot> data = 300 scoped_ptr<BlobDataSnapshot> data =
301 GetHandleFromBuilder()->CreateSnapshot(); 301 GetHandleFromBuilder()->CreateSnapshot();
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type)); 535 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type));
536 EXPECT_EQ(kTestContentType, content_type); 536 EXPECT_EQ(kTestContentType, content_type);
537 void* iter = NULL; 537 void* iter = NULL;
538 std::string content_disposition; 538 std::string content_disposition;
539 EXPECT_TRUE(request_->response_headers()->EnumerateHeader( 539 EXPECT_TRUE(request_->response_headers()->EnumerateHeader(
540 &iter, "Content-Disposition", &content_disposition)); 540 &iter, "Content-Disposition", &content_disposition));
541 EXPECT_EQ(kTestContentDisposition, content_disposition); 541 EXPECT_EQ(kTestContentDisposition, content_disposition);
542 } 542 }
543 543
544 } // namespace content 544 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/fileapi/blob_storage_context_unittest.cc ('k') | content/browser/fileapi/browser_file_system_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698