Index: content/browser/renderer_host/database_message_filter.cc |
diff --git a/content/browser/renderer_host/database_message_filter.cc b/content/browser/renderer_host/database_message_filter.cc |
index e2660593c0f47d5444e74a6601f119e192e630fc..66e14e09ec2435530d144825e1b4ff23415ccda0 100644 |
--- a/content/browser/renderer_host/database_message_filter.cc |
+++ b/content/browser/renderer_host/database_message_filter.cc |
@@ -119,6 +119,7 @@ void DatabaseMessageFilter::OnDatabaseOpenFile( |
int desired_flags, |
IPC::Message* reply_msg) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
+ base::File file; |
base::PlatformFile file_handle = base::kInvalidPlatformFileValue; |
std::string origin_identifier; |
base::string16 database_name; |
@@ -129,8 +130,8 @@ void DatabaseMessageFilter::OnDatabaseOpenFile( |
// open handles to them in the database tracker to make sure they're |
// around for as long as needed. |
if (vfs_file_name.empty()) { |
- VfsBackend::OpenTempFileInDirectory(db_tracker_->DatabaseDirectory(), |
- desired_flags, &file_handle); |
+ file = VfsBackend::OpenTempFileInDirectory(db_tracker_->DatabaseDirectory(), |
+ desired_flags); |
} else if (DatabaseUtil::CrackVfsFileName(vfs_file_name, &origin_identifier, |
&database_name, NULL) && |
!db_tracker_->IsDatabaseScheduledForDeletion(origin_identifier, |
@@ -138,27 +139,33 @@ void DatabaseMessageFilter::OnDatabaseOpenFile( |
base::FilePath db_file = DatabaseUtil::GetFullFilePathForVfsFile( |
db_tracker_.get(), vfs_file_name); |
if (!db_file.empty()) { |
- if (db_tracker_->IsIncognitoProfile()) { |
- db_tracker_->GetIncognitoFileHandle(vfs_file_name, &file_handle); |
- if (file_handle == base::kInvalidPlatformFileValue) { |
- VfsBackend::OpenFile(db_file, |
- desired_flags | SQLITE_OPEN_DELETEONCLOSE, |
- &file_handle); |
- if (!(desired_flags & SQLITE_OPEN_DELETEONCLOSE)) |
- db_tracker_->SaveIncognitoFileHandle(vfs_file_name, file_handle); |
+ if (db_tracker_->IsIncognitoProfile()) { |
+ db_tracker_->GetIncognitoFileHandle(vfs_file_name, &file_handle); |
+ if (file_handle == base::kInvalidPlatformFileValue) { |
+ file = |
+ VfsBackend::OpenFile(db_file, |
+ desired_flags | SQLITE_OPEN_DELETEONCLOSE); |
+ if (!(desired_flags & SQLITE_OPEN_DELETEONCLOSE)) { |
+ file_handle = file.TakePlatformFile(); |
+ db_tracker_->SaveIncognitoFileHandle(vfs_file_name, file_handle); |
} |
- } else { |
- VfsBackend::OpenFile(db_file, desired_flags, &file_handle); |
} |
+ } else { |
+ file = VfsBackend::OpenFile(db_file, desired_flags); |
} |
+ } |
} |
// Then we duplicate the file handle to make it useable in the renderer |
// process. The original handle is closed, unless we saved it in the |
// database tracker. |
- bool auto_close = !db_tracker_->HasSavedIncognitoFileHandle(vfs_file_name); |
- IPC::PlatformFileForTransit target_handle = |
- IPC::GetFileHandleForProcess(file_handle, PeerHandle(), auto_close); |
+ IPC::PlatformFileForTransit target_handle; |
+ if (file.IsValid()) { |
+ target_handle = IPC::TakeFileHandleForProcess(file.Pass(), PeerHandle()); |
michaeln
2014/03/24 18:57:20
What about the earlier calls to file.TakePlatformF
michaeln
2014/03/24 22:59:08
oh, i see the else clause dups file_handle directl
rvargas (doing something else)
2014/03/25 00:51:14
Pass() comes from MOVE_ONLY_TYPE_FOR_CPP_03 at the
michaeln
2014/03/25 01:21:12
duh, thnx
|
+ } else { |
+ target_handle = IPC::GetFileHandleForProcess(file_handle, PeerHandle(), |
+ false); |
+ } |
DatabaseHostMsg_OpenFile::WriteReplyParams(reply_msg, target_handle); |
Send(reply_msg); |