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

Side by Side Diff: storage/browser/fileapi/obfuscated_file_util.cc

Issue 1546243002: Convert Pass()→std::move() in //storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 (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 "storage/browser/fileapi/obfuscated_file_util.h" 5 #include "storage/browser/fileapi/obfuscated_file_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 base::File ObfuscatedFileUtil::CreateOrOpen( 275 base::File ObfuscatedFileUtil::CreateOrOpen(
276 FileSystemOperationContext* context, 276 FileSystemOperationContext* context,
277 const FileSystemURL& url, int file_flags) { 277 const FileSystemURL& url, int file_flags) {
278 base::File file = CreateOrOpenInternal(context, url, file_flags); 278 base::File file = CreateOrOpenInternal(context, url, file_flags);
279 if (file.IsValid() && file_flags & base::File::FLAG_WRITE && 279 if (file.IsValid() && file_flags & base::File::FLAG_WRITE &&
280 context->quota_limit_type() == storage::kQuotaLimitTypeUnlimited && 280 context->quota_limit_type() == storage::kQuotaLimitTypeUnlimited &&
281 sandbox_delegate_) { 281 sandbox_delegate_) {
282 sandbox_delegate_->StickyInvalidateUsageCache(url.origin(), url.type()); 282 sandbox_delegate_->StickyInvalidateUsageCache(url.origin(), url.type());
283 } 283 }
284 return file.Pass(); 284 return file;
285 } 285 }
286 286
287 base::File::Error ObfuscatedFileUtil::EnsureFileExists( 287 base::File::Error ObfuscatedFileUtil::EnsureFileExists(
288 FileSystemOperationContext* context, 288 FileSystemOperationContext* context,
289 const FileSystemURL& url, 289 const FileSystemURL& url,
290 bool* created) { 290 bool* created) {
291 SandboxDirectoryDatabase* db = GetDirectoryDatabase(url, true); 291 SandboxDirectoryDatabase* db = GetDirectoryDatabase(url, true);
292 if (!db) 292 if (!db)
293 return base::File::FILE_ERROR_FAILED; 293 return base::File::FILE_ERROR_FAILED;
294 294
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 1057
1058 if (base::PathExists(dest_local_path)) { 1058 if (base::PathExists(dest_local_path)) {
1059 if (!base::DeleteFile(dest_local_path, false /* recursive */)) 1059 if (!base::DeleteFile(dest_local_path, false /* recursive */))
1060 return base::File(base::File::FILE_ERROR_FAILED); 1060 return base::File(base::File::FILE_ERROR_FAILED);
1061 LOG(WARNING) << "A stray file detected"; 1061 LOG(WARNING) << "A stray file detected";
1062 InvalidateUsageCache(context, dest_url.origin(), dest_url.type()); 1062 InvalidateUsageCache(context, dest_url.origin(), dest_url.type());
1063 } 1063 }
1064 1064
1065 base::File file = NativeFileUtil::CreateOrOpen(dest_local_path, file_flags); 1065 base::File file = NativeFileUtil::CreateOrOpen(dest_local_path, file_flags);
1066 if (!file.IsValid()) 1066 if (!file.IsValid())
1067 return file.Pass(); 1067 return file;
1068 1068
1069 if (!file.created()) { 1069 if (!file.created()) {
1070 file.Close(); 1070 file.Close();
1071 base::DeleteFile(dest_local_path, false /* recursive */); 1071 base::DeleteFile(dest_local_path, false /* recursive */);
1072 return base::File(base::File::FILE_ERROR_FAILED); 1072 return base::File(base::File::FILE_ERROR_FAILED);
1073 } 1073 }
1074 1074
1075 error = CommitCreateFile(root, dest_local_path, db, dest_file_info); 1075 error = CommitCreateFile(root, dest_local_path, db, dest_file_info);
1076 if (error != base::File::FILE_OK) { 1076 if (error != base::File::FILE_OK) {
1077 file.Close(); 1077 file.Close();
1078 base::DeleteFile(dest_local_path, false /* recursive */); 1078 base::DeleteFile(dest_local_path, false /* recursive */);
1079 return base::File(error); 1079 return base::File(error);
1080 } 1080 }
1081 1081
1082 return file.Pass(); 1082 return file;
1083 } 1083 }
1084 1084
1085 base::File::Error ObfuscatedFileUtil::CreateFile( 1085 base::File::Error ObfuscatedFileUtil::CreateFile(
1086 FileSystemOperationContext* context, 1086 FileSystemOperationContext* context,
1087 const base::FilePath& src_file_path, 1087 const base::FilePath& src_file_path,
1088 const FileSystemURL& dest_url, 1088 const FileSystemURL& dest_url,
1089 FileInfo* dest_file_info) { 1089 FileInfo* dest_file_info) {
1090 SandboxDirectoryDatabase* db = GetDirectoryDatabase(dest_url, true); 1090 SandboxDirectoryDatabase* db = GetDirectoryDatabase(dest_url, true);
1091 1091
1092 base::FilePath root, dest_local_path; 1092 base::FilePath root, dest_local_path;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 1367
1368 int64_t growth = UsageForPath(file_info.name.size()); 1368 int64_t growth = UsageForPath(file_info.name.size());
1369 if (!AllocateQuota(context, growth)) 1369 if (!AllocateQuota(context, growth))
1370 return base::File(base::File::FILE_ERROR_NO_SPACE); 1370 return base::File(base::File::FILE_ERROR_NO_SPACE);
1371 base::File file = CreateAndOpenFile(context, url, &file_info, file_flags); 1371 base::File file = CreateAndOpenFile(context, url, &file_info, file_flags);
1372 if (file.IsValid()) { 1372 if (file.IsValid()) {
1373 UpdateUsage(context, url, growth); 1373 UpdateUsage(context, url, growth);
1374 context->change_observers()->Notify( 1374 context->change_observers()->Notify(
1375 &FileChangeObserver::OnCreateFile, base::MakeTuple(url)); 1375 &FileChangeObserver::OnCreateFile, base::MakeTuple(url));
1376 } 1376 }
1377 return file.Pass(); 1377 return file;
1378 } 1378 }
1379 1379
1380 if (file_flags & base::File::FLAG_CREATE) 1380 if (file_flags & base::File::FLAG_CREATE)
1381 return base::File(base::File::FILE_ERROR_EXISTS); 1381 return base::File(base::File::FILE_ERROR_EXISTS);
1382 1382
1383 base::File::Info platform_file_info; 1383 base::File::Info platform_file_info;
1384 base::FilePath local_path; 1384 base::FilePath local_path;
1385 FileInfo file_info; 1385 FileInfo file_info;
1386 base::File::Error error = GetFileInfoInternal( 1386 base::File::Error error = GetFileInfoInternal(
1387 db, context, url, file_id, &file_info, &platform_file_info, &local_path); 1387 db, context, url, file_id, &file_info, &platform_file_info, &local_path);
(...skipping 13 matching lines...) Expand all
1401 base::File file = NativeFileUtil::CreateOrOpen(local_path, file_flags); 1401 base::File file = NativeFileUtil::CreateOrOpen(local_path, file_flags);
1402 if (!file.IsValid()) { 1402 if (!file.IsValid()) {
1403 error = file.error_details(); 1403 error = file.error_details();
1404 if (error == base::File::FILE_ERROR_NOT_FOUND) { 1404 if (error == base::File::FILE_ERROR_NOT_FOUND) {
1405 // TODO(tzik): Also invalidate on-memory usage cache in UsageTracker. 1405 // TODO(tzik): Also invalidate on-memory usage cache in UsageTracker.
1406 // TODO(tzik): Delete database entry after ensuring the file lost. 1406 // TODO(tzik): Delete database entry after ensuring the file lost.
1407 InvalidateUsageCache(context, url.origin(), url.type()); 1407 InvalidateUsageCache(context, url.origin(), url.type());
1408 LOG(WARNING) << "Lost a backing file."; 1408 LOG(WARNING) << "Lost a backing file.";
1409 return base::File(base::File::FILE_ERROR_FAILED); 1409 return base::File(base::File::FILE_ERROR_FAILED);
1410 } 1410 }
1411 return file.Pass(); 1411 return file;
1412 } 1412 }
1413 1413
1414 // If truncating we need to update the usage. 1414 // If truncating we need to update the usage.
1415 if (delta) { 1415 if (delta) {
1416 UpdateUsage(context, url, delta); 1416 UpdateUsage(context, url, delta);
1417 context->change_observers()->Notify( 1417 context->change_observers()->Notify(
1418 &FileChangeObserver::OnModifyFile, base::MakeTuple(url)); 1418 &FileChangeObserver::OnModifyFile, base::MakeTuple(url));
1419 } 1419 }
1420 return file.Pass(); 1420 return file;
1421 } 1421 }
1422 1422
1423 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { 1423 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) {
1424 return special_storage_policy_.get() && 1424 return special_storage_policy_.get() &&
1425 special_storage_policy_->HasIsolatedStorage(origin); 1425 special_storage_policy_->HasIsolatedStorage(origin);
1426 } 1426 }
1427 1427
1428 } // namespace storage 1428 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/fileapi/file_writer_delegate.cc ('k') | storage/browser/fileapi/plugin_private_file_system_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698