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

Side by Side Diff: content/browser/storage_partition_impl_unittest.cc

Issue 2256173002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace a WrapUnique() nested inside a MakeUnique() Created 4 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 // Opens the file created for ClearKey (in kOrigin1) for writing. Caller 295 // Opens the file created for ClearKey (in kOrigin1) for writing. Caller
296 // needs to verify if the file was opened or not. 296 // needs to verify if the file was opened or not.
297 base::File OpenClearKeyFileForWrite() { 297 base::File OpenClearKeyFileForWrite() {
298 AwaitCompletionHelper await_completion; 298 AwaitCompletionHelper await_completion;
299 base::File file; 299 base::File file;
300 storage::AsyncFileUtil* async_file_util = 300 storage::AsyncFileUtil* async_file_util =
301 filesystem_context_->GetAsyncFileUtil( 301 filesystem_context_->GetAsyncFileUtil(
302 storage::kFileSystemTypePluginPrivate); 302 storage::kFileSystemTypePluginPrivate);
303 std::unique_ptr<storage::FileSystemOperationContext> operation_context = 303 std::unique_ptr<storage::FileSystemOperationContext> operation_context =
304 base::WrapUnique( 304 base::MakeUnique<storage::FileSystemOperationContext>(
305 new storage::FileSystemOperationContext(filesystem_context_)); 305 filesystem_context_);
306 async_file_util->CreateOrOpen( 306 async_file_util->CreateOrOpen(
307 std::move(operation_context), clearkey_file_, 307 std::move(operation_context), clearkey_file_,
308 base::File::FLAG_OPEN | base::File::FLAG_WRITE, 308 base::File::FLAG_OPEN | base::File::FLAG_WRITE,
309 base::Bind(&RemovePluginPrivateDataTester::OnFileOpened, 309 base::Bind(&RemovePluginPrivateDataTester::OnFileOpened,
310 base::Unretained(this), &file, &await_completion)); 310 base::Unretained(this), &file, &await_completion));
311 await_completion.BlockUntilNotified(); 311 await_completion.BlockUntilNotified();
312 return file; 312 return file;
313 } 313 }
314 314
315 private: 315 private:
(...skipping 24 matching lines...) Expand all
340 const std::string& fsid, 340 const std::string& fsid,
341 const std::string& file_name) { 341 const std::string& file_name) {
342 AwaitCompletionHelper await_completion; 342 AwaitCompletionHelper await_completion;
343 std::string root = storage::GetIsolatedFileSystemRootURIString( 343 std::string root = storage::GetIsolatedFileSystemRootURIString(
344 origin, fsid, ppapi::kPluginPrivateRootName); 344 origin, fsid, ppapi::kPluginPrivateRootName);
345 storage::FileSystemURL file_url = 345 storage::FileSystemURL file_url =
346 filesystem_context_->CrackURL(GURL(root + file_name)); 346 filesystem_context_->CrackURL(GURL(root + file_name));
347 storage::AsyncFileUtil* file_util = filesystem_context_->GetAsyncFileUtil( 347 storage::AsyncFileUtil* file_util = filesystem_context_->GetAsyncFileUtil(
348 storage::kFileSystemTypePluginPrivate); 348 storage::kFileSystemTypePluginPrivate);
349 std::unique_ptr<storage::FileSystemOperationContext> operation_context = 349 std::unique_ptr<storage::FileSystemOperationContext> operation_context =
350 base::WrapUnique( 350 base::MakeUnique<storage::FileSystemOperationContext>(
351 new storage::FileSystemOperationContext(filesystem_context_)); 351 filesystem_context_);
352 operation_context->set_allowed_bytes_growth( 352 operation_context->set_allowed_bytes_growth(
353 storage::QuotaManager::kNoLimit); 353 storage::QuotaManager::kNoLimit);
354 file_util->EnsureFileExists( 354 file_util->EnsureFileExists(
355 std::move(operation_context), file_url, 355 std::move(operation_context), file_url,
356 base::Bind(&RemovePluginPrivateDataTester::OnFileCreated, 356 base::Bind(&RemovePluginPrivateDataTester::OnFileCreated,
357 base::Unretained(this), &await_completion)); 357 base::Unretained(this), &await_completion));
358 await_completion.BlockUntilNotified(); 358 await_completion.BlockUntilNotified();
359 return file_url; 359 return file_url;
360 } 360 }
361 361
362 // Sets the last_access_time and last_modified_time to |time_stamp| on the 362 // Sets the last_access_time and last_modified_time to |time_stamp| on the
363 // file specified by |file_url|. The file must already exist. 363 // file specified by |file_url|. The file must already exist.
364 void SetFileTimestamp(const storage::FileSystemURL& file_url, 364 void SetFileTimestamp(const storage::FileSystemURL& file_url,
365 const base::Time& time_stamp) { 365 const base::Time& time_stamp) {
366 AwaitCompletionHelper await_completion; 366 AwaitCompletionHelper await_completion;
367 storage::AsyncFileUtil* file_util = filesystem_context_->GetAsyncFileUtil( 367 storage::AsyncFileUtil* file_util = filesystem_context_->GetAsyncFileUtil(
368 storage::kFileSystemTypePluginPrivate); 368 storage::kFileSystemTypePluginPrivate);
369 std::unique_ptr<storage::FileSystemOperationContext> operation_context = 369 std::unique_ptr<storage::FileSystemOperationContext> operation_context =
370 base::WrapUnique( 370 base::MakeUnique<storage::FileSystemOperationContext>(
371 new storage::FileSystemOperationContext(filesystem_context_)); 371 filesystem_context_);
372 file_util->Touch(std::move(operation_context), file_url, time_stamp, 372 file_util->Touch(std::move(operation_context), file_url, time_stamp,
373 time_stamp, 373 time_stamp,
374 base::Bind(&RemovePluginPrivateDataTester::OnFileTouched, 374 base::Bind(&RemovePluginPrivateDataTester::OnFileTouched,
375 base::Unretained(this), &await_completion)); 375 base::Unretained(this), &await_completion));
376 await_completion.BlockUntilNotified(); 376 await_completion.BlockUntilNotified();
377 } 377 }
378 378
379 void OnFileSystemOpened(AwaitCompletionHelper* await_completion, 379 void OnFileSystemOpened(AwaitCompletionHelper* await_completion,
380 base::File::Error result) { 380 base::File::Error result) {
381 EXPECT_EQ(base::File::FILE_OK, result) << base::File::ErrorToString(result); 381 EXPECT_EQ(base::File::FILE_OK, result) << base::File::ErrorToString(result);
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 CanonicalCookie::Create(url2, "A=B;domain=.example.com", now, options)); 1312 CanonicalCookie::Create(url2, "A=B;domain=.example.com", now, options));
1313 invalid_cookies.push_back(CanonicalCookie::Create(url3, "A=B", now, options)); 1313 invalid_cookies.push_back(CanonicalCookie::Create(url3, "A=B", now, options));
1314 1314
1315 for (const auto& cookie : valid_cookies) 1315 for (const auto& cookie : valid_cookies)
1316 EXPECT_TRUE(predicate.Run(*cookie)) << cookie->DebugString(); 1316 EXPECT_TRUE(predicate.Run(*cookie)) << cookie->DebugString();
1317 for (const auto& cookie : invalid_cookies) 1317 for (const auto& cookie : invalid_cookies)
1318 EXPECT_FALSE(predicate.Run(*cookie)) << cookie->DebugString(); 1318 EXPECT_FALSE(predicate.Run(*cookie)) << cookie->DebugString();
1319 } 1319 }
1320 1320
1321 } // namespace content 1321 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698