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 scoped_refptr
<IPC::SyncMessageFilter
> filter(sync_message_filter
);
25 filter
->Send(new DatabaseHostMsg_OpenFile(
26 vfs_file_name
, desired_flags
, &file_handle
));
28 return IPC::PlatformFileForTransitToPlatformFile(file_handle
);
31 int DatabaseUtil::DatabaseDeleteFile(
32 const WebString
& vfs_file_name
,
34 IPC::SyncMessageFilter
* sync_message_filter
) {
35 int rv
= SQLITE_IOERR_DELETE
;
36 scoped_refptr
<IPC::SyncMessageFilter
> filter(sync_message_filter
);
37 filter
->Send(new DatabaseHostMsg_DeleteFile(
38 vfs_file_name
, sync_dir
, &rv
));
42 long DatabaseUtil::DatabaseGetFileAttributes(
43 const WebString
& vfs_file_name
,
44 IPC::SyncMessageFilter
* sync_message_filter
) {
46 scoped_refptr
<IPC::SyncMessageFilter
> filter(sync_message_filter
);
47 filter
->Send(new DatabaseHostMsg_GetFileAttributes(vfs_file_name
, &rv
));
51 long long DatabaseUtil::DatabaseGetFileSize(
52 const WebString
& vfs_file_name
,
53 IPC::SyncMessageFilter
* sync_message_filter
) {
55 scoped_refptr
<IPC::SyncMessageFilter
> filter(sync_message_filter
);
56 filter
->Send(new DatabaseHostMsg_GetFileSize(vfs_file_name
, &rv
));
60 long long DatabaseUtil::DatabaseGetSpaceAvailable(
61 const WebString
& origin_identifier
,
62 IPC::SyncMessageFilter
* sync_message_filter
) {
64 scoped_refptr
<IPC::SyncMessageFilter
> filter(sync_message_filter
);
65 filter
->Send(new DatabaseHostMsg_GetSpaceAvailable(origin_identifier
.utf8(),
70 } // namespace content