Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / child / database_util.cc
blob3a0e80b266a45a964343ab4af1827a76262a31d1
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;
15 namespace content {
17 Platform::FileHandle DatabaseUtil::DatabaseOpenFile(
18 const WebString& vfs_file_name,
19 int desired_flags,
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,
32 bool sync_dir,
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));
37 return rv;
40 long DatabaseUtil::DatabaseGetFileAttributes(
41 const WebString& vfs_file_name,
42 IPC::SyncMessageFilter* sync_message_filter) {
43 int32 rv = -1;
44 sync_message_filter->Send(
45 new DatabaseHostMsg_GetFileAttributes(vfs_file_name, &rv));
46 return rv;
49 long long DatabaseUtil::DatabaseGetFileSize(
50 const WebString& vfs_file_name,
51 IPC::SyncMessageFilter* sync_message_filter) {
52 int64 rv = 0LL;
53 sync_message_filter->Send(
54 new DatabaseHostMsg_GetFileSize(vfs_file_name, &rv));
55 return rv;
58 long long DatabaseUtil::DatabaseGetSpaceAvailable(
59 const WebString& origin_identifier,
60 IPC::SyncMessageFilter* sync_message_filter) {
61 int64 rv = 0LL;
62 sync_message_filter->Send(
63 new DatabaseHostMsg_GetSpaceAvailable(origin_identifier.utf8(), &rv));
64 return rv;
67 bool DatabaseUtil::DatabaseSetFileSize(
68 const WebString& vfs_file_name,
69 int64 size,
70 IPC::SyncMessageFilter* sync_message_filter) {
71 bool rv = false;
72 sync_message_filter->Send(
73 new DatabaseHostMsg_SetFileSize(vfs_file_name, size, &rv));
74 return rv;
77 } // namespace content