OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/renderer_host/database_dispatcher_host.h" | 5 #include "chrome/browser/renderer_host/database_dispatcher_host.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #if defined(USE_SYSTEM_SQLITE) | 11 #if defined(USE_SYSTEM_SQLITE) |
12 #include <sqlite3.h> | 12 #include <sqlite3.h> |
13 #else | 13 #else |
14 #include "third_party/sqlite/preprocessed/sqlite3.h" | 14 #include "third_party/sqlite/preprocessed/sqlite3.h" |
15 #endif | 15 #endif |
16 | 16 |
17 #include "base/file_path.h" | |
18 #include "base/file_util.h" | |
19 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
20 #include "base/platform_file.h" | 18 #include "base/platform_file.h" |
21 #include "base/process.h" | 19 #include "base/process.h" |
22 #include "base/scoped_ptr.h" | |
23 #include "base/task.h" | 20 #include "base/task.h" |
24 #include "base/thread.h" | 21 #include "base/thread.h" |
25 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
26 #include "chrome/browser/renderer_host/resource_message_filter.h" | 23 #include "chrome/browser/renderer_host/resource_message_filter.h" |
27 #include "chrome/common/render_messages.h" | 24 #include "chrome/common/render_messages.h" |
28 #include "ipc/ipc_message.h" | 25 #include "ipc/ipc_message.h" |
| 26 #include "webkit/database/vfs_backend.h" |
29 | 27 |
30 #if defined(OS_POSIX) | 28 #if defined(OS_POSIX) |
31 #include "base/file_descriptor_posix.h" | 29 #include "base/file_descriptor_posix.h" |
32 #endif | 30 #endif |
33 | 31 |
34 const int kNumDeleteRetries = 5; | 32 using webkit_database::VfsBackend; |
| 33 |
| 34 const int kNumDeleteRetries = 3; |
35 const int kDelayDeleteRetryMs = 100; | 35 const int kDelayDeleteRetryMs = 100; |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 struct OpenFileParams { | 39 struct OpenFileParams { |
40 FilePath db_dir; // directory where all DB files are stored | 40 FilePath db_dir; |
41 FilePath file_name; // DB file | 41 FilePath file_name; |
42 int desired_flags; // flags to be used to open the file | 42 int desired_flags; |
43 base::ProcessHandle handle; // the handle of the renderer process | 43 base::ProcessHandle handle; |
44 }; | 44 }; |
45 | 45 |
46 struct DeleteFileParams { | 46 struct DeleteFileParams { |
47 FilePath db_dir; // directory where all DB files are stored | 47 FilePath db_dir; |
48 FilePath file_name; // DB file | 48 FilePath file_name; |
49 bool sync_dir; // sync DB directory after the file is deleted? | 49 bool sync_dir; |
50 }; | 50 }; |
51 | 51 |
52 // Scheduled by the file Thread on the IO thread. | 52 // Scheduled by the file Thread on the IO thread. |
53 // Sends back to the renderer process the given message. | 53 // Sends back to the renderer process the given message. |
54 static void SendMessage(ResourceMessageFilter* sender, | 54 static void SendMessage(ResourceMessageFilter* sender, |
55 IPC::Message* message) { | 55 IPC::Message* message) { |
56 sender->Send(message); | 56 sender->Send(message); |
57 | 57 |
58 // Every time we get a DB-related message, we AddRef() the resource | 58 // Every time we get a DB-related message, we AddRef() the resource |
59 // message filterto make sure it doesn't get destroyed before we have | 59 // message filterto make sure it doesn't get destroyed before we have |
60 // a chance to send the reply back. So we need to Release() is here | 60 // a chance to send the reply back. So we need to Release() is here |
61 // and allow it to be destroyed if needed. | 61 // and allow it to be destroyed if needed. |
62 sender->Release(); | 62 sender->Release(); |
63 } | 63 } |
64 | 64 |
65 // Make sure the flags used to open a DB file are consistent. | |
66 static bool OpenFileFlagsAreConsistent(const OpenFileParams& params) { | |
67 // Is this a request for a temp file? | |
68 // We should be able to delete temp files when they're closed | |
69 // and create them as needed | |
70 if ((params.file_name == params.db_dir) && | |
71 (!(params.desired_flags & SQLITE_OPEN_DELETEONCLOSE) || | |
72 !(params.desired_flags & SQLITE_OPEN_CREATE))) { | |
73 return false; | |
74 } | |
75 | |
76 const int file_type = params.desired_flags & 0x00007F00; | |
77 const bool is_exclusive = | |
78 (params.desired_flags & SQLITE_OPEN_EXCLUSIVE) != 0; | |
79 const bool is_delete = | |
80 (params.desired_flags & SQLITE_OPEN_DELETEONCLOSE) != 0; | |
81 const bool is_create = | |
82 (params.desired_flags & SQLITE_OPEN_CREATE) != 0; | |
83 const bool is_read_only = | |
84 (params.desired_flags & SQLITE_OPEN_READONLY) != 0; | |
85 const bool is_read_write = | |
86 (params.desired_flags & SQLITE_OPEN_READWRITE) != 0; | |
87 | |
88 // All files should be opened either read-write or read-only. | |
89 if (!(is_read_only ^ is_read_write)) { | |
90 return false; | |
91 } | |
92 | |
93 // If a new file is created, it must also be writtable. | |
94 if (is_create && !is_read_write) { | |
95 return false; | |
96 } | |
97 | |
98 // We must be able to create a new file, if exclusive access is desired. | |
99 if (is_exclusive && !is_create) { | |
100 return false; | |
101 } | |
102 | |
103 // We cannot delete the files that we expect to already exist. | |
104 if (is_delete && !is_create) { | |
105 return false; | |
106 } | |
107 | |
108 // The main DB, main journal and master journal cannot be auto-deleted. | |
109 if (((file_type == SQLITE_OPEN_MAIN_DB) || | |
110 (file_type == SQLITE_OPEN_MAIN_JOURNAL) || | |
111 (file_type == SQLITE_OPEN_MASTER_JOURNAL)) && | |
112 is_delete) { | |
113 return false; | |
114 } | |
115 | |
116 // Make sure we're opening the DB directory or that a file type is set. | |
117 if ((file_type != SQLITE_OPEN_MAIN_DB) && | |
118 (file_type != SQLITE_OPEN_TEMP_DB) && | |
119 (file_type != SQLITE_OPEN_MAIN_JOURNAL) && | |
120 (file_type != SQLITE_OPEN_TEMP_JOURNAL) && | |
121 (file_type != SQLITE_OPEN_SUBJOURNAL) && | |
122 (file_type != SQLITE_OPEN_MASTER_JOURNAL) && | |
123 (file_type != SQLITE_OPEN_TRANSIENT_DB)) { | |
124 return false; | |
125 } | |
126 | |
127 return true; | |
128 } | |
129 | |
130 // Scheduled by the IO thread on the file thread. | 65 // Scheduled by the IO thread on the file thread. |
131 // Opens the given database file, then schedules | 66 // Opens the given database file, then schedules |
132 // a task on the IO thread's message loop to send an IPC back to | 67 // a task on the IO thread's message loop to send an IPC back to |
133 // corresponding renderer process with the file handle. | 68 // corresponding renderer process with the file handle. |
134 static void DatabaseOpenFile(MessageLoop* io_thread_message_loop, | 69 static void DatabaseOpenFile(MessageLoop* io_thread_message_loop, |
135 const OpenFileParams& params, | 70 const OpenFileParams& params, |
136 int32 message_id, | 71 int32 message_id, |
137 ResourceMessageFilter* sender) { | 72 ResourceMessageFilter* sender) { |
138 base::PlatformFile target_handle = base::kInvalidPlatformFileValue; | 73 base::PlatformFile target_handle = base::kInvalidPlatformFileValue; |
139 #if defined(OS_POSIX) | |
140 base::PlatformFile target_dir_handle = base::kInvalidPlatformFileValue; | 74 base::PlatformFile target_dir_handle = base::kInvalidPlatformFileValue; |
141 #endif | 75 VfsBackend::OpenFile( |
142 | 76 params.file_name, params.db_dir, params.desired_flags, |
143 // Verify the flags for consistency and create the database | 77 params.handle, &target_handle, &target_dir_handle); |
144 // directory if it doesn't exist. | |
145 if (OpenFileFlagsAreConsistent(params) && | |
146 file_util::CreateDirectory(params.db_dir)) { | |
147 int flags = 0; | |
148 flags |= base::PLATFORM_FILE_READ; | |
149 if (params.desired_flags & SQLITE_OPEN_READWRITE) { | |
150 flags |= base::PLATFORM_FILE_WRITE; | |
151 } | |
152 | |
153 if (!(params.desired_flags & SQLITE_OPEN_MAIN_DB)) { | |
154 flags |= base::PLATFORM_FILE_EXCLUSIVE_READ | | |
155 base::PLATFORM_FILE_EXCLUSIVE_WRITE; | |
156 } | |
157 | |
158 if (params.desired_flags & SQLITE_OPEN_CREATE) { | |
159 flags |= base::PLATFORM_FILE_OPEN_ALWAYS; | |
160 } else { | |
161 flags |= base::PLATFORM_FILE_OPEN; | |
162 } | |
163 | |
164 if (params.desired_flags & SQLITE_OPEN_EXCLUSIVE) { | |
165 flags |= base::PLATFORM_FILE_EXCLUSIVE_READ | | |
166 base::PLATFORM_FILE_EXCLUSIVE_WRITE; | |
167 } | |
168 | |
169 if (params.desired_flags & SQLITE_OPEN_DELETEONCLOSE) { | |
170 flags |= base::PLATFORM_FILE_TEMPORARY | base::PLATFORM_FILE_HIDDEN | | |
171 base::PLATFORM_FILE_DELETE_ON_CLOSE; | |
172 } | |
173 | |
174 // If this is a request for a handle to a temp file, get a unique file name | |
175 FilePath file_name; | |
176 if (params.file_name == params.db_dir) { | |
177 if (!file_util::CreateTemporaryFileInDir(params.db_dir, &file_name)) { | |
178 file_name = FilePath(); | |
179 } | |
180 } else { | |
181 file_name = params.file_name; | |
182 } | |
183 | |
184 // Try to open/create the DB file. | |
185 base::PlatformFile file_handle = | |
186 (file_name.empty() ? base::kInvalidPlatformFileValue : | |
187 base::CreatePlatformFile(file_name.ToWStringHack(), flags, NULL)); | |
188 if (file_handle != base::kInvalidPlatformFileValue) { | |
189 #if defined(OS_WIN) | |
190 // Duplicate the file handle. | |
191 if (!DuplicateHandle(GetCurrentProcess(), file_handle, | |
192 params.handle, &target_handle, 0, false, | |
193 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { | |
194 // file_handle is closed whether or not DuplicateHandle succeeds. | |
195 target_handle = INVALID_HANDLE_VALUE; | |
196 } | |
197 #elif defined(OS_POSIX) | |
198 target_handle = file_handle; | |
199 | |
200 int file_type = params.desired_flags & 0x00007F00; | |
201 bool creating_new_file = (params.desired_flags & SQLITE_OPEN_CREATE); | |
202 if (creating_new_file && ((file_type == SQLITE_OPEN_MASTER_JOURNAL) || | |
203 (file_type == SQLITE_OPEN_MAIN_JOURNAL))) { | |
204 // We return a handle to the containing directory because on POSIX | |
205 // systems the VFS might want to fsync it after changing a file. | |
206 // By returning it here, we avoid an extra IPC call. | |
207 target_dir_handle = base::CreatePlatformFile( | |
208 params.db_dir.ToWStringHack(), | |
209 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, NULL); | |
210 if (target_dir_handle == base::kInvalidPlatformFileValue) { | |
211 base::ClosePlatformFile(target_handle); | |
212 target_handle = base::kInvalidPlatformFileValue; | |
213 } | |
214 } | |
215 #endif | |
216 } | |
217 } | |
218 | 78 |
219 ViewMsg_DatabaseOpenFileResponse_Params response_params; | 79 ViewMsg_DatabaseOpenFileResponse_Params response_params; |
220 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
221 response_params.file_handle = target_handle; | 81 response_params.file_handle = target_handle; |
222 #elif defined(OS_POSIX) | 82 #elif defined(OS_POSIX) |
223 response_params.file_handle = base::FileDescriptor(target_handle, true); | 83 response_params.file_handle = base::FileDescriptor(target_handle, true); |
224 response_params.dir_handle = base::FileDescriptor(target_dir_handle, true); | 84 response_params.dir_handle = base::FileDescriptor(target_dir_handle, true); |
225 #endif | 85 #endif |
226 | |
227 io_thread_message_loop->PostTask(FROM_HERE, | 86 io_thread_message_loop->PostTask(FROM_HERE, |
228 NewRunnableFunction(SendMessage, sender, | 87 NewRunnableFunction(SendMessage, sender, |
229 new ViewMsg_DatabaseOpenFileResponse(message_id, response_params))); | 88 new ViewMsg_DatabaseOpenFileResponse(message_id, response_params))); |
230 } | 89 } |
231 | 90 |
232 // Scheduled by the IO thread on the file thread. | 91 // Scheduled by the IO thread on the file thread. |
233 // Deletes the given database file, then schedules | 92 // Deletes the given database file, then schedules |
234 // a task on the IO thread's message loop to send an IPC back to | 93 // a task on the IO thread's message loop to send an IPC back to |
235 // corresponding renderer process with the error code. | 94 // corresponding renderer process with the error code. |
236 static void DatabaseDeleteFile( | 95 static void DatabaseDeleteFile( |
237 MessageLoop* io_thread_message_loop, | 96 MessageLoop* io_thread_message_loop, |
238 const DeleteFileParams& params, | 97 const DeleteFileParams& params, |
239 int32 message_id, | 98 int32 message_id, |
240 int reschedule_count, | 99 int reschedule_count, |
241 ResourceMessageFilter* sender) { | 100 ResourceMessageFilter* sender) { |
242 // Return an error if the file could not be deleted | 101 // Return an error if the file could not be deleted |
243 // after kNumDeleteRetries times. | 102 // after kNumDeleteRetries times. |
244 if (!reschedule_count) { | 103 if (!reschedule_count) { |
245 io_thread_message_loop->PostTask(FROM_HERE, | 104 io_thread_message_loop->PostTask(FROM_HERE, |
246 NewRunnableFunction(SendMessage, sender, | 105 NewRunnableFunction(SendMessage, sender, |
247 new ViewMsg_DatabaseDeleteFileResponse( | 106 new ViewMsg_DatabaseDeleteFileResponse( |
248 message_id, SQLITE_IOERR_DELETE))); | 107 message_id, SQLITE_IOERR_DELETE))); |
249 return; | 108 return; |
250 } | 109 } |
251 | 110 |
252 // If the file does not exist, we're done. | 111 int error_code = VfsBackend::DeleteFile( |
253 if (!file_util::PathExists(params.file_name)) { | 112 params.file_name, params.db_dir, params.sync_dir); |
254 io_thread_message_loop->PostTask(FROM_HERE, | 113 if (error_code == SQLITE_IOERR_DELETE) { |
255 NewRunnableFunction(SendMessage, sender, | 114 // If the file could not be deleted, try again. |
256 new ViewMsg_DatabaseDeleteFileResponse(message_id, SQLITE_OK))); | |
257 return; | |
258 } | |
259 | |
260 | |
261 // If the file could not be deleted, try again. | |
262 if (!file_util::Delete(params.file_name, false)) { | |
263 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 115 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
264 NewRunnableFunction(DatabaseDeleteFile, io_thread_message_loop, | 116 NewRunnableFunction(DatabaseDeleteFile, io_thread_message_loop, |
265 params, message_id, reschedule_count - 1, sender), | 117 params, message_id, reschedule_count - 1, sender), |
266 kDelayDeleteRetryMs); | 118 kDelayDeleteRetryMs); |
267 return; | 119 return; |
268 } | 120 } |
269 | 121 |
270 // File existed and it was successfully deleted | |
271 int error_code = SQLITE_OK; | |
272 #if defined(OS_POSIX) | |
273 // sync the DB directory if needed | |
274 if (params.sync_dir) { | |
275 base::PlatformFile dir_fd = base::CreatePlatformFile( | |
276 params.db_dir.ToWStringHack(), base::PLATFORM_FILE_READ, NULL); | |
277 if (dir_fd == base::kInvalidPlatformFileValue) { | |
278 error_code = SQLITE_CANTOPEN; | |
279 } else { | |
280 if (fsync(dir_fd)) { | |
281 error_code = SQLITE_IOERR_DIR_FSYNC; | |
282 } | |
283 base::ClosePlatformFile(dir_fd); | |
284 } | |
285 } | |
286 #endif | |
287 | |
288 io_thread_message_loop->PostTask(FROM_HERE, | 122 io_thread_message_loop->PostTask(FROM_HERE, |
289 NewRunnableFunction(SendMessage, sender, | 123 NewRunnableFunction(SendMessage, sender, |
290 new ViewMsg_DatabaseDeleteFileResponse(message_id, error_code))); | 124 new ViewMsg_DatabaseDeleteFileResponse(message_id, error_code))); |
291 } | 125 } |
292 | 126 |
293 // Scheduled by the IO thread on the file thread. | 127 // Scheduled by the IO thread on the file thread. |
294 // Gets the attributes of the given database file, then schedules | 128 // Gets the attributes of the given database file, then schedules |
295 // a task on the IO thread's message loop to send an IPC back to | 129 // a task on the IO thread's message loop to send an IPC back to |
296 // corresponding renderer process. | 130 // corresponding renderer process. |
297 static void DatabaseGetFileAttributes( | 131 static void DatabaseGetFileAttributes( |
298 MessageLoop* io_thread_message_loop, | 132 MessageLoop* io_thread_message_loop, |
299 const FilePath& file_name, | 133 const FilePath& file_name, |
300 int32 message_id, | 134 int32 message_id, |
301 ResourceMessageFilter* sender) { | 135 ResourceMessageFilter* sender) { |
302 #if defined(OS_WIN) | 136 uint32 attributes = VfsBackend::GetFileAttributes(file_name); |
303 uint32 attributes = GetFileAttributes(file_name.value().c_str()); | |
304 #elif defined(OS_POSIX) | |
305 uint32 attributes = 0; | |
306 if (!access(file_name.value().c_str(), R_OK)) { | |
307 attributes |= static_cast<uint32>(R_OK); | |
308 } | |
309 if (!access(file_name.value().c_str(), W_OK)) { | |
310 attributes |= static_cast<uint32>(W_OK); | |
311 } | |
312 if (!attributes) { | |
313 attributes = -1; | |
314 } | |
315 #endif | |
316 | |
317 io_thread_message_loop->PostTask(FROM_HERE, | 137 io_thread_message_loop->PostTask(FROM_HERE, |
318 NewRunnableFunction(SendMessage, sender, | 138 NewRunnableFunction(SendMessage, sender, |
319 new ViewMsg_DatabaseGetFileAttributesResponse( | 139 new ViewMsg_DatabaseGetFileAttributesResponse( |
320 message_id, attributes))); | 140 message_id, attributes))); |
321 } | 141 } |
322 | 142 |
323 // Scheduled by the IO thread on the file thread. | 143 // Scheduled by the IO thread on the file thread. |
324 // Gets the size of the given file, then schedules a task | 144 // Gets the size of the given file, then schedules a task |
325 // on the IO thread's message loop to send an IPC back to | 145 // on the IO thread's message loop to send an IPC back to |
326 // the corresponding renderer process. | 146 // the corresponding renderer process. |
327 static void DatabaseGetFileSize( | 147 static void DatabaseGetFileSize( |
328 MessageLoop* io_thread_message_loop, | 148 MessageLoop* io_thread_message_loop, |
329 const FilePath& file_name, | 149 const FilePath& file_name, |
330 int32 message_id, | 150 int32 message_id, |
331 ResourceMessageFilter* sender) { | 151 ResourceMessageFilter* sender) { |
332 int64 size = 0; | 152 int64 size = VfsBackend::GetFileSize(file_name); |
333 if (!file_util::GetFileSize(file_name, &size)) { | |
334 size = 0; | |
335 } | |
336 | |
337 io_thread_message_loop->PostTask(FROM_HERE, | 153 io_thread_message_loop->PostTask(FROM_HERE, |
338 NewRunnableFunction(SendMessage, sender, | 154 NewRunnableFunction(SendMessage, sender, |
339 new ViewMsg_DatabaseGetFileSizeResponse(message_id, size))); | 155 new ViewMsg_DatabaseGetFileSizeResponse(message_id, size))); |
340 } | 156 } |
341 | 157 |
342 } // namespace | 158 } // namespace |
343 | 159 |
344 DatabaseDispatcherHost::DatabaseDispatcherHost( | 160 DatabaseDispatcherHost::DatabaseDispatcherHost( |
345 const FilePath& profile_path, | 161 const FilePath& profile_path, |
346 ResourceMessageFilter* resource_message_filter) | 162 ResourceMessageFilter* resource_message_filter) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 response_params.file_handle = | 228 response_params.file_handle = |
413 base::FileDescriptor(base::kInvalidPlatformFileValue, true); | 229 base::FileDescriptor(base::kInvalidPlatformFileValue, true); |
414 response_params.dir_handle = | 230 response_params.dir_handle = |
415 base::FileDescriptor(base::kInvalidPlatformFileValue, true); | 231 base::FileDescriptor(base::kInvalidPlatformFileValue, true); |
416 #endif | 232 #endif |
417 resource_message_filter_->Send(new ViewMsg_DatabaseOpenFileResponse( | 233 resource_message_filter_->Send(new ViewMsg_DatabaseOpenFileResponse( |
418 message_id, response_params)); | 234 message_id, response_params)); |
419 return; | 235 return; |
420 } | 236 } |
421 | 237 |
422 OpenFileParams params = { GetDBDir(), db_file_name, desired_flags, | 238 OpenFileParams params; |
423 resource_message_filter_->handle() }; | 239 params.db_dir = GetDBDir(); |
| 240 params.file_name = db_file_name; |
| 241 params.desired_flags = desired_flags; |
| 242 params.handle = resource_message_filter_->handle(); |
424 resource_message_filter_->AddRef(); | 243 resource_message_filter_->AddRef(); |
425 file_thread_message_loop_->PostTask(FROM_HERE, | 244 file_thread_message_loop_->PostTask(FROM_HERE, |
426 NewRunnableFunction(DatabaseOpenFile, MessageLoop::current(), | 245 NewRunnableFunction(DatabaseOpenFile, MessageLoop::current(), |
427 params, message_id, resource_message_filter_)); | 246 params, message_id, resource_message_filter_)); |
428 } | 247 } |
429 | 248 |
430 void DatabaseDispatcherHost::OnDatabaseDeleteFile( | 249 void DatabaseDispatcherHost::OnDatabaseDeleteFile( |
431 const FilePath& file_name, const bool& sync_dir, int32 message_id) { | 250 const FilePath& file_name, const bool& sync_dir, int32 message_id) { |
432 FilePath db_file_name = GetDBFileFullPath(file_name); | 251 FilePath db_file_name = GetDBFileFullPath(file_name); |
433 if (db_file_name.empty()) { | 252 if (db_file_name.empty()) { |
434 resource_message_filter_->Send(new ViewMsg_DatabaseDeleteFileResponse( | 253 resource_message_filter_->Send(new ViewMsg_DatabaseDeleteFileResponse( |
435 message_id, SQLITE_IOERR_DELETE)); | 254 message_id, SQLITE_IOERR_DELETE)); |
436 return; | 255 return; |
437 } | 256 } |
438 | 257 |
439 DeleteFileParams params = { GetDBDir(), db_file_name, sync_dir }; | 258 DeleteFileParams params; |
| 259 params.db_dir = GetDBDir(); |
| 260 params.file_name = db_file_name; |
| 261 params.sync_dir = sync_dir; |
440 resource_message_filter_->AddRef(); | 262 resource_message_filter_->AddRef(); |
441 file_thread_message_loop_->PostTask(FROM_HERE, | 263 file_thread_message_loop_->PostTask(FROM_HERE, |
442 NewRunnableFunction(DatabaseDeleteFile, MessageLoop::current(), | 264 NewRunnableFunction(DatabaseDeleteFile, MessageLoop::current(), |
443 params, message_id, kNumDeleteRetries, resource_message_filter_)); | 265 params, message_id, kNumDeleteRetries, resource_message_filter_)); |
444 } | 266 } |
445 | 267 |
446 void DatabaseDispatcherHost::OnDatabaseGetFileAttributes( | 268 void DatabaseDispatcherHost::OnDatabaseGetFileAttributes( |
447 const FilePath& file_name, int32 message_id) { | 269 const FilePath& file_name, int32 message_id) { |
448 FilePath db_file_name = GetDBFileFullPath(file_name); | 270 FilePath db_file_name = GetDBFileFullPath(file_name); |
449 if (db_file_name.empty()) { | 271 if (db_file_name.empty()) { |
(...skipping 16 matching lines...) Expand all Loading... |
466 resource_message_filter_->Send(new ViewMsg_DatabaseGetFileSizeResponse( | 288 resource_message_filter_->Send(new ViewMsg_DatabaseGetFileSizeResponse( |
467 message_id, 0)); | 289 message_id, 0)); |
468 return; | 290 return; |
469 } | 291 } |
470 | 292 |
471 resource_message_filter_->AddRef(); | 293 resource_message_filter_->AddRef(); |
472 file_thread_message_loop_->PostTask(FROM_HERE, | 294 file_thread_message_loop_->PostTask(FROM_HERE, |
473 NewRunnableFunction(DatabaseGetFileSize, MessageLoop::current(), | 295 NewRunnableFunction(DatabaseGetFileSize, MessageLoop::current(), |
474 db_file_name, message_id, resource_message_filter_)); | 296 db_file_name, message_id, resource_message_filter_)); |
475 } | 297 } |
OLD | NEW |