OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "content/common/database_util.h" | |
6 | |
7 #include "content/common/child_thread.h" | |
8 #include "content/common/database_messages.h" | |
9 #include "ipc/ipc_sync_message_filter.h" | |
10 #include "third_party/WebKit/public/platform/WebString.h" | |
11 #include "third_party/sqlite/sqlite3.h" | |
12 | |
13 using WebKit::Platform; | |
14 using WebKit::WebString; | |
15 | |
16 namespace content { | |
17 | |
18 Platform::FileHandle DatabaseUtil::DatabaseOpenFile( | |
19 const WebString& vfs_file_name, int desired_flags) { | |
20 IPC::PlatformFileForTransit file_handle = | |
21 IPC::InvalidPlatformFileForTransit(); | |
22 | |
23 scoped_refptr<IPC::SyncMessageFilter> filter( | |
24 ChildThread::current()->sync_message_filter()); | |
25 filter->Send(new DatabaseHostMsg_OpenFile( | |
26 vfs_file_name, desired_flags, &file_handle)); | |
27 | |
28 return IPC::PlatformFileForTransitToPlatformFile(file_handle); | |
29 } | |
30 | |
31 int DatabaseUtil::DatabaseDeleteFile( | |
32 const WebString& vfs_file_name, bool sync_dir) { | |
33 int rv = SQLITE_IOERR_DELETE; | |
34 scoped_refptr<IPC::SyncMessageFilter> filter( | |
35 ChildThread::current()->sync_message_filter()); | |
36 filter->Send(new DatabaseHostMsg_DeleteFile( | |
37 vfs_file_name, sync_dir, &rv)); | |
38 return rv; | |
39 } | |
40 | |
41 long DatabaseUtil::DatabaseGetFileAttributes(const WebString& vfs_file_name) { | |
42 int32 rv = -1; | |
43 scoped_refptr<IPC::SyncMessageFilter> filter( | |
44 ChildThread::current()->sync_message_filter()); | |
45 filter->Send(new DatabaseHostMsg_GetFileAttributes(vfs_file_name, &rv)); | |
46 return rv; | |
47 } | |
48 | |
49 long long DatabaseUtil::DatabaseGetFileSize(const WebString& vfs_file_name) { | |
50 int64 rv = 0LL; | |
51 scoped_refptr<IPC::SyncMessageFilter> filter( | |
52 ChildThread::current()->sync_message_filter()); | |
53 filter->Send(new DatabaseHostMsg_GetFileSize(vfs_file_name, &rv)); | |
54 return rv; | |
55 } | |
56 | |
57 long long DatabaseUtil::DatabaseGetSpaceAvailable( | |
58 const WebString& origin_identifier) { | |
59 int64 rv = 0LL; | |
60 scoped_refptr<IPC::SyncMessageFilter> filter( | |
61 ChildThread::current()->sync_message_filter()); | |
62 filter->Send(new DatabaseHostMsg_GetSpaceAvailable(origin_identifier, &rv)); | |
63 return rv; | |
64 } | |
65 | |
66 } // namespace content | |
OLD | NEW |