1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/child/database_util.h"
7 #include "content/common/database_messages.h"
8 #include "ipc/ipc_sync_message_filter.h"
9 #include "third_party/WebKit/public/platform/WebString.h"
10 #include "third_party/sqlite/sqlite3.h"
12 using blink::Platform
;
13 using blink::WebString
;
17 Platform::FileHandle
DatabaseUtil::DatabaseOpenFile(
18 const WebString
& vfs_file_name
,
20 IPC::SyncMessageFilter
* sync_message_filter
) {
21 IPC::PlatformFileForTransit file_handle
=
22 IPC::InvalidPlatformFileForTransit();
24 sync_message_filter
->Send(new DatabaseHostMsg_OpenFile(
25 vfs_file_name
, desired_flags
, &file_handle
));
27 return IPC::PlatformFileForTransitToPlatformFile(file_handle
);
30 int DatabaseUtil::DatabaseDeleteFile(
31 const WebString
& vfs_file_name
,
33 IPC::SyncMessageFilter
* sync_message_filter
) {
34 int rv
= SQLITE_IOERR_DELETE
;
35 sync_message_filter
->Send(
36 new DatabaseHostMsg_DeleteFile(vfs_file_name
, sync_dir
, &rv
));
40 long DatabaseUtil::DatabaseGetFileAttributes(
41 const WebString
& vfs_file_name
,
42 IPC::SyncMessageFilter
* sync_message_filter
) {
44 sync_message_filter
->Send(
45 new DatabaseHostMsg_GetFileAttributes(vfs_file_name
, &rv
));
49 long long DatabaseUtil::DatabaseGetFileSize(
50 const WebString
& vfs_file_name
,
51 IPC::SyncMessageFilter
* sync_message_filter
) {
53 sync_message_filter
->Send(
54 new DatabaseHostMsg_GetFileSize(vfs_file_name
, &rv
));
58 long long DatabaseUtil::DatabaseGetSpaceAvailable(
59 const WebString
& origin_identifier
,
60 IPC::SyncMessageFilter
* sync_message_filter
) {
62 sync_message_filter
->Send(
63 new DatabaseHostMsg_GetSpaceAvailable(origin_identifier
.utf8(), &rv
));
67 bool DatabaseUtil::DatabaseSetFileSize(
68 const WebString
& vfs_file_name
,
70 IPC::SyncMessageFilter
* sync_message_filter
) {
72 sync_message_filter
->Send(
73 new DatabaseHostMsg_SetFileSize(vfs_file_name
, size
, &rv
));
77 } // namespace content