OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "webkit/fileapi/file_system_file_util_proxy.h" | 5 #include "webkit/fileapi/file_system_file_util_proxy.h" |
6 | 6 |
7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "webkit/fileapi/file_system_context.h" | 8 #include "webkit/fileapi/file_system_context.h" |
9 #include "webkit/fileapi/file_system_file_util.h" | 9 #include "webkit/fileapi/file_system_file_util.h" |
10 #include "webkit/fileapi/file_system_operation_context.h" | 10 #include "webkit/fileapi/file_system_operation_context.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 class MessageLoopRelay | 14 class MessageLoopRelay |
15 : public base::RefCountedThreadSafe<MessageLoopRelay> { | 15 : public base::RefCountedThreadSafe<MessageLoopRelay> { |
16 public: | 16 public: |
17 // FileSystemOperationContext is passed by value from the IO thread to the | 17 // FileSystemOperationContext is passed by value from the IO thread to the |
18 // File thread. | 18 // File thread. |
19 explicit MessageLoopRelay(const fileapi::FileSystemOperationContext& context) | 19 explicit MessageLoopRelay(const fileapi::FileSystemOperationContext& context) |
20 : origin_message_loop_proxy_( | 20 : origin_message_loop_proxy_( |
21 base::MessageLoopProxy::current()), | 21 base::MessageLoopProxy::current()), |
22 error_code_(base::PLATFORM_FILE_OK), | 22 error_code_(base::PLATFORM_FILE_OK), |
23 context_(context), | 23 context_(context), |
24 file_system_file_util_(NULL) { | 24 file_util_(NULL) { |
25 } | 25 } |
26 | 26 |
27 bool Start(scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 27 bool Start(scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
28 const tracked_objects::Location& from_here) { | 28 const tracked_objects::Location& from_here) { |
29 return message_loop_proxy->PostTask( | 29 return message_loop_proxy->PostTask( |
30 from_here, | 30 from_here, |
31 NewRunnableMethod(this, &MessageLoopRelay::ProcessOnTargetThread)); | 31 NewRunnableMethod(this, &MessageLoopRelay::ProcessOnTargetThread)); |
32 } | 32 } |
33 | 33 |
34 protected: | 34 protected: |
(...skipping 11 matching lines...) Expand all Loading... |
46 } | 46 } |
47 | 47 |
48 base::PlatformFileError error_code() const { | 48 base::PlatformFileError error_code() const { |
49 return error_code_; | 49 return error_code_; |
50 } | 50 } |
51 | 51 |
52 fileapi::FileSystemOperationContext* context() { | 52 fileapi::FileSystemOperationContext* context() { |
53 return &context_; | 53 return &context_; |
54 } | 54 } |
55 | 55 |
56 fileapi::FileSystemFileUtil* file_system_file_util() const { | 56 fileapi::FileSystemFileUtil* file_util() const { |
57 // TODO(ericu): Support calls that have two different FSFU subclasses. | 57 // TODO(ericu): Support calls that have two different FSFU subclasses. |
58 return context_.src_file_system_file_util(); | 58 return context_.src_file_util(); |
59 } | 59 } |
60 | 60 |
61 private: | 61 private: |
62 void ProcessOnTargetThread() { | 62 void ProcessOnTargetThread() { |
63 RunWork(); | 63 RunWork(); |
64 origin_message_loop_proxy_->PostTask( | 64 origin_message_loop_proxy_->PostTask( |
65 FROM_HERE, | 65 FROM_HERE, |
66 NewRunnableMethod(this, &MessageLoopRelay::RunCallback)); | 66 NewRunnableMethod(this, &MessageLoopRelay::RunCallback)); |
67 } | 67 } |
68 | 68 |
69 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_; | 69 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_; |
70 base::PlatformFileError error_code_; | 70 base::PlatformFileError error_code_; |
71 fileapi::FileSystemOperationContext context_; | 71 fileapi::FileSystemOperationContext context_; |
72 fileapi::FileSystemFileUtil* file_system_file_util_; | 72 fileapi::FileSystemFileUtil* file_util_; |
73 }; | 73 }; |
74 | 74 |
75 class RelayCreateOrOpen : public MessageLoopRelay { | 75 class RelayCreateOrOpen : public MessageLoopRelay { |
76 public: | 76 public: |
77 RelayCreateOrOpen( | 77 RelayCreateOrOpen( |
78 const fileapi::FileSystemOperationContext& context, | 78 const fileapi::FileSystemOperationContext& context, |
79 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 79 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
80 const FilePath& file_path, | 80 const FilePath& file_path, |
81 int file_flags, | 81 int file_flags, |
82 fileapi::FileSystemFileUtilProxy::CreateOrOpenCallback* callback) | 82 fileapi::FileSystemFileUtilProxy::CreateOrOpenCallback* callback) |
83 : MessageLoopRelay(context), | 83 : MessageLoopRelay(context), |
84 message_loop_proxy_(message_loop_proxy), | 84 message_loop_proxy_(message_loop_proxy), |
85 file_path_(file_path), | 85 file_path_(file_path), |
86 file_flags_(file_flags), | 86 file_flags_(file_flags), |
87 callback_(callback), | 87 callback_(callback), |
88 file_handle_(base::kInvalidPlatformFileValue), | 88 file_handle_(base::kInvalidPlatformFileValue), |
89 created_(false) { | 89 created_(false) { |
90 DCHECK(callback); | 90 DCHECK(callback); |
91 } | 91 } |
92 | 92 |
93 protected: | 93 protected: |
94 virtual ~RelayCreateOrOpen() { | 94 virtual ~RelayCreateOrOpen() { |
95 if (file_handle_ != base::kInvalidPlatformFileValue) | 95 if (file_handle_ != base::kInvalidPlatformFileValue) |
96 fileapi::FileSystemFileUtilProxy::Close(*context(), | 96 fileapi::FileSystemFileUtilProxy::Close(*context(), |
97 message_loop_proxy_, file_handle_, NULL); | 97 message_loop_proxy_, file_handle_, NULL); |
98 } | 98 } |
99 | 99 |
100 virtual void RunWork() { | 100 virtual void RunWork() { |
101 set_error_code( | 101 set_error_code(file_util()->CreateOrOpen( |
102 file_system_file_util()->CreateOrOpen( | 102 context(), file_path_, file_flags_, &file_handle_, &created_)); |
103 context(), file_path_, file_flags_, &file_handle_, &created_)); | |
104 } | 103 } |
105 | 104 |
106 virtual void RunCallback() { | 105 virtual void RunCallback() { |
107 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_), | 106 callback_->Run(error_code(), base::PassPlatformFile(&file_handle_), |
108 created_); | 107 created_); |
109 delete callback_; | 108 delete callback_; |
110 } | 109 } |
111 | 110 |
112 private: | 111 private: |
113 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 112 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 public: | 144 public: |
146 RelayClose(const fileapi::FileSystemOperationContext& context, | 145 RelayClose(const fileapi::FileSystemOperationContext& context, |
147 base::PlatformFile file_handle, | 146 base::PlatformFile file_handle, |
148 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) | 147 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) |
149 : RelayWithStatusCallback(context, callback), | 148 : RelayWithStatusCallback(context, callback), |
150 file_handle_(file_handle) { | 149 file_handle_(file_handle) { |
151 } | 150 } |
152 | 151 |
153 protected: | 152 protected: |
154 virtual void RunWork() { | 153 virtual void RunWork() { |
155 set_error_code( | 154 set_error_code(file_util()->Close(context(), file_handle_)); |
156 file_system_file_util()->Close(context(), file_handle_)); | |
157 } | 155 } |
158 | 156 |
159 private: | 157 private: |
160 base::PlatformFile file_handle_; | 158 base::PlatformFile file_handle_; |
161 }; | 159 }; |
162 | 160 |
163 class RelayEnsureFileExists : public MessageLoopRelay { | 161 class RelayEnsureFileExists : public MessageLoopRelay { |
164 public: | 162 public: |
165 RelayEnsureFileExists( | 163 RelayEnsureFileExists( |
166 const fileapi::FileSystemOperationContext& context, | 164 const fileapi::FileSystemOperationContext& context, |
167 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 165 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
168 const FilePath& file_path, | 166 const FilePath& file_path, |
169 fileapi::FileSystemFileUtilProxy::EnsureFileExistsCallback* callback) | 167 fileapi::FileSystemFileUtilProxy::EnsureFileExistsCallback* callback) |
170 : MessageLoopRelay(context), | 168 : MessageLoopRelay(context), |
171 message_loop_proxy_(message_loop_proxy), | 169 message_loop_proxy_(message_loop_proxy), |
172 file_path_(file_path), | 170 file_path_(file_path), |
173 callback_(callback), | 171 callback_(callback), |
174 created_(false) { | 172 created_(false) { |
175 DCHECK(callback); | 173 DCHECK(callback); |
176 } | 174 } |
177 | 175 |
178 protected: | 176 protected: |
179 virtual void RunWork() { | 177 virtual void RunWork() { |
180 set_error_code( | 178 set_error_code(file_util()->EnsureFileExists( |
181 file_system_file_util()->EnsureFileExists( | 179 context(), file_path_, &created_)); |
182 context(), file_path_, &created_)); | |
183 } | 180 } |
184 | 181 |
185 virtual void RunCallback() { | 182 virtual void RunCallback() { |
186 callback_->Run(error_code(), created_); | 183 callback_->Run(error_code(), created_); |
187 delete callback_; | 184 delete callback_; |
188 } | 185 } |
189 | 186 |
190 private: | 187 private: |
191 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 188 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
192 FilePath file_path_; | 189 FilePath file_path_; |
193 fileapi::FileSystemFileUtilProxy::EnsureFileExistsCallback* callback_; | 190 fileapi::FileSystemFileUtilProxy::EnsureFileExistsCallback* callback_; |
194 bool created_; | 191 bool created_; |
195 }; | 192 }; |
196 | 193 |
197 | 194 |
198 class RelayGetLocalPath : public MessageLoopRelay { | 195 class RelayGetLocalPath : public MessageLoopRelay { |
199 public: | 196 public: |
200 RelayGetLocalPath( | 197 RelayGetLocalPath( |
201 const fileapi::FileSystemOperationContext& context, | 198 const fileapi::FileSystemOperationContext& context, |
202 const FilePath& virtual_path, | 199 const FilePath& virtual_path, |
203 fileapi::FileSystemFileUtilProxy::GetLocalPathCallback* callback) | 200 fileapi::FileSystemFileUtilProxy::GetLocalPathCallback* callback) |
204 : MessageLoopRelay(context), | 201 : MessageLoopRelay(context), |
205 callback_(callback), | 202 callback_(callback), |
206 virtual_path_(virtual_path) { | 203 virtual_path_(virtual_path) { |
207 DCHECK(callback); | 204 DCHECK(callback); |
208 } | 205 } |
209 | 206 |
210 protected: | 207 protected: |
211 virtual void RunWork() { | 208 virtual void RunWork() { |
212 set_error_code( | 209 set_error_code(file_util()->GetLocalFilePath( |
213 file_system_file_util()->GetLocalFilePath( | 210 context(), virtual_path_, &local_path_)); |
214 context(), virtual_path_, &local_path_)); | |
215 } | 211 } |
216 | 212 |
217 virtual void RunCallback() { | 213 virtual void RunCallback() { |
218 callback_->Run(error_code(), local_path_); | 214 callback_->Run(error_code(), local_path_); |
219 delete callback_; | 215 delete callback_; |
220 } | 216 } |
221 | 217 |
222 private: | 218 private: |
223 fileapi::FileSystemFileUtilProxy::GetLocalPathCallback* callback_; | 219 fileapi::FileSystemFileUtilProxy::GetLocalPathCallback* callback_; |
224 FilePath virtual_path_; | 220 FilePath virtual_path_; |
225 FilePath local_path_; | 221 FilePath local_path_; |
226 }; | 222 }; |
227 | 223 |
228 class RelayGetFileInfo : public MessageLoopRelay { | 224 class RelayGetFileInfo : public MessageLoopRelay { |
229 public: | 225 public: |
230 RelayGetFileInfo( | 226 RelayGetFileInfo( |
231 const fileapi::FileSystemOperationContext& context, | 227 const fileapi::FileSystemOperationContext& context, |
232 const FilePath& file_path, | 228 const FilePath& file_path, |
233 fileapi::FileSystemFileUtilProxy::GetFileInfoCallback* callback) | 229 fileapi::FileSystemFileUtilProxy::GetFileInfoCallback* callback) |
234 : MessageLoopRelay(context), | 230 : MessageLoopRelay(context), |
235 callback_(callback), | 231 callback_(callback), |
236 file_path_(file_path) { | 232 file_path_(file_path) { |
237 DCHECK(callback); | 233 DCHECK(callback); |
238 } | 234 } |
239 | 235 |
240 protected: | 236 protected: |
241 virtual void RunWork() { | 237 virtual void RunWork() { |
242 set_error_code( | 238 set_error_code(file_util()->GetFileInfo( |
243 file_system_file_util()->GetFileInfo( | 239 context(), file_path_, &file_info_, &platform_path_)); |
244 context(), file_path_, &file_info_, &platform_path_)); | |
245 } | 240 } |
246 | 241 |
247 virtual void RunCallback() { | 242 virtual void RunCallback() { |
248 callback_->Run(error_code(), file_info_, platform_path_); | 243 callback_->Run(error_code(), file_info_, platform_path_); |
249 delete callback_; | 244 delete callback_; |
250 } | 245 } |
251 | 246 |
252 private: | 247 private: |
253 fileapi::FileSystemFileUtilProxy::GetFileInfoCallback* callback_; | 248 fileapi::FileSystemFileUtilProxy::GetFileInfoCallback* callback_; |
254 FilePath file_path_; | 249 FilePath file_path_; |
255 base::PlatformFileInfo file_info_; | 250 base::PlatformFileInfo file_info_; |
256 FilePath platform_path_; | 251 FilePath platform_path_; |
257 }; | 252 }; |
258 | 253 |
259 class RelayReadDirectory : public MessageLoopRelay { | 254 class RelayReadDirectory : public MessageLoopRelay { |
260 public: | 255 public: |
261 RelayReadDirectory( | 256 RelayReadDirectory( |
262 const fileapi::FileSystemOperationContext& context, | 257 const fileapi::FileSystemOperationContext& context, |
263 const FilePath& file_path, | 258 const FilePath& file_path, |
264 fileapi::FileSystemFileUtilProxy::ReadDirectoryCallback* callback) | 259 fileapi::FileSystemFileUtilProxy::ReadDirectoryCallback* callback) |
265 : MessageLoopRelay(context), | 260 : MessageLoopRelay(context), |
266 callback_(callback), file_path_(file_path) { | 261 callback_(callback), file_path_(file_path) { |
267 DCHECK(callback); | 262 DCHECK(callback); |
268 } | 263 } |
269 | 264 |
270 protected: | 265 protected: |
271 virtual void RunWork() { | 266 virtual void RunWork() { |
272 // TODO(kkanetkar): Implement directory read in multiple chunks. | 267 // TODO(kkanetkar): Implement directory read in multiple chunks. |
273 set_error_code( | 268 set_error_code(file_util()->ReadDirectory( |
274 file_system_file_util()->ReadDirectory( | 269 context(), file_path_, &entries_)); |
275 context(), file_path_, &entries_)); | |
276 } | 270 } |
277 | 271 |
278 virtual void RunCallback() { | 272 virtual void RunCallback() { |
279 callback_->Run(error_code(), entries_); | 273 callback_->Run(error_code(), entries_); |
280 delete callback_; | 274 delete callback_; |
281 } | 275 } |
282 | 276 |
283 private: | 277 private: |
284 fileapi::FileSystemFileUtilProxy::ReadDirectoryCallback* callback_; | 278 fileapi::FileSystemFileUtilProxy::ReadDirectoryCallback* callback_; |
285 FilePath file_path_; | 279 FilePath file_path_; |
286 std::vector<base::FileUtilProxy::Entry> entries_; | 280 std::vector<base::FileUtilProxy::Entry> entries_; |
287 }; | 281 }; |
288 | 282 |
289 class RelayCreateDirectory : public RelayWithStatusCallback { | 283 class RelayCreateDirectory : public RelayWithStatusCallback { |
290 public: | 284 public: |
291 RelayCreateDirectory( | 285 RelayCreateDirectory( |
292 const fileapi::FileSystemOperationContext& context, | 286 const fileapi::FileSystemOperationContext& context, |
293 const FilePath& file_path, | 287 const FilePath& file_path, |
294 bool exclusive, | 288 bool exclusive, |
295 bool recursive, | 289 bool recursive, |
296 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) | 290 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) |
297 : RelayWithStatusCallback(context, callback), | 291 : RelayWithStatusCallback(context, callback), |
298 file_path_(file_path), | 292 file_path_(file_path), |
299 exclusive_(exclusive), | 293 exclusive_(exclusive), |
300 recursive_(recursive) { | 294 recursive_(recursive) { |
301 } | 295 } |
302 | 296 |
303 protected: | 297 protected: |
304 virtual void RunWork() { | 298 virtual void RunWork() { |
305 set_error_code( | 299 set_error_code(file_util()->CreateDirectory( |
306 file_system_file_util()->CreateDirectory( | 300 context(), file_path_, exclusive_, recursive_)); |
307 context(), file_path_, exclusive_, recursive_)); | |
308 } | 301 } |
309 | 302 |
310 private: | 303 private: |
311 FilePath file_path_; | 304 FilePath file_path_; |
312 bool exclusive_; | 305 bool exclusive_; |
313 bool recursive_; | 306 bool recursive_; |
314 }; | 307 }; |
315 | 308 |
316 class RelayCopy : public RelayWithStatusCallback { | 309 class RelayCopy : public RelayWithStatusCallback { |
317 public: | 310 public: |
318 RelayCopy(const fileapi::FileSystemOperationContext& context, | 311 RelayCopy(const fileapi::FileSystemOperationContext& context, |
319 const FilePath& src_file_path, | 312 const FilePath& src_file_path, |
320 const FilePath& dest_file_path, | 313 const FilePath& dest_file_path, |
321 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) | 314 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) |
322 : RelayWithStatusCallback(context, callback), | 315 : RelayWithStatusCallback(context, callback), |
323 src_file_path_(src_file_path), | 316 src_file_path_(src_file_path), |
324 dest_file_path_(dest_file_path) { | 317 dest_file_path_(dest_file_path) { |
325 } | 318 } |
326 | 319 |
327 protected: | 320 protected: |
328 virtual void RunWork() { | 321 virtual void RunWork() { |
329 set_error_code( | 322 set_error_code(file_util()->Copy( |
330 file_system_file_util()->Copy( | 323 context(), src_file_path_, dest_file_path_)); |
331 context(), src_file_path_, dest_file_path_)); | |
332 } | 324 } |
333 | 325 |
334 private: | 326 private: |
335 FilePath src_file_path_; | 327 FilePath src_file_path_; |
336 FilePath dest_file_path_; | 328 FilePath dest_file_path_; |
337 }; | 329 }; |
338 | 330 |
339 class RelayMove : public RelayWithStatusCallback { | 331 class RelayMove : public RelayWithStatusCallback { |
340 public: | 332 public: |
341 RelayMove(const fileapi::FileSystemOperationContext& context, | 333 RelayMove(const fileapi::FileSystemOperationContext& context, |
342 const FilePath& src_file_path, | 334 const FilePath& src_file_path, |
343 const FilePath& dest_file_path, | 335 const FilePath& dest_file_path, |
344 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) | 336 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) |
345 : RelayWithStatusCallback(context, callback), | 337 : RelayWithStatusCallback(context, callback), |
346 src_file_path_(src_file_path), | 338 src_file_path_(src_file_path), |
347 dest_file_path_(dest_file_path) { | 339 dest_file_path_(dest_file_path) { |
348 } | 340 } |
349 | 341 |
350 protected: | 342 protected: |
351 virtual void RunWork() { | 343 virtual void RunWork() { |
352 set_error_code( | 344 set_error_code(file_util()->Move( |
353 file_system_file_util()->Move( | 345 context(), src_file_path_, dest_file_path_)); |
354 context(), src_file_path_, dest_file_path_)); | |
355 } | 346 } |
356 | 347 |
357 private: | 348 private: |
358 FilePath src_file_path_; | 349 FilePath src_file_path_; |
359 FilePath dest_file_path_; | 350 FilePath dest_file_path_; |
360 }; | 351 }; |
361 | 352 |
362 class RelayDelete : public RelayWithStatusCallback { | 353 class RelayDelete : public RelayWithStatusCallback { |
363 public: | 354 public: |
364 RelayDelete(const fileapi::FileSystemOperationContext& context, | 355 RelayDelete(const fileapi::FileSystemOperationContext& context, |
365 const FilePath& file_path, | 356 const FilePath& file_path, |
366 bool recursive, | 357 bool recursive, |
367 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) | 358 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) |
368 : RelayWithStatusCallback(context, callback), | 359 : RelayWithStatusCallback(context, callback), |
369 file_path_(file_path), | 360 file_path_(file_path), |
370 recursive_(recursive) { | 361 recursive_(recursive) { |
371 } | 362 } |
372 | 363 |
373 protected: | 364 protected: |
374 virtual void RunWork() { | 365 virtual void RunWork() { |
375 set_error_code( | 366 set_error_code(file_util()->Delete(context(), file_path_, recursive_)); |
376 file_system_file_util()->Delete( | |
377 context(), file_path_, recursive_)); | |
378 } | 367 } |
379 | 368 |
380 private: | 369 private: |
381 FilePath file_path_; | 370 FilePath file_path_; |
382 bool recursive_; | 371 bool recursive_; |
383 }; | 372 }; |
384 | 373 |
385 class RelayTouchFilePath : public RelayWithStatusCallback { | 374 class RelayTouchFilePath : public RelayWithStatusCallback { |
386 public: | 375 public: |
387 RelayTouchFilePath(const fileapi::FileSystemOperationContext& context, | 376 RelayTouchFilePath(const fileapi::FileSystemOperationContext& context, |
388 const FilePath& file_path, | 377 const FilePath& file_path, |
389 const base::Time& last_access_time, | 378 const base::Time& last_access_time, |
390 const base::Time& last_modified_time, | 379 const base::Time& last_modified_time, |
391 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) | 380 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) |
392 : RelayWithStatusCallback(context, callback), | 381 : RelayWithStatusCallback(context, callback), |
393 file_path_(file_path), | 382 file_path_(file_path), |
394 last_access_time_(last_access_time), | 383 last_access_time_(last_access_time), |
395 last_modified_time_(last_modified_time) { | 384 last_modified_time_(last_modified_time) { |
396 } | 385 } |
397 | 386 |
398 protected: | 387 protected: |
399 virtual void RunWork() { | 388 virtual void RunWork() { |
400 set_error_code( | 389 set_error_code(file_util()->Touch( |
401 file_system_file_util()->Touch( | 390 context(), file_path_, last_access_time_, last_modified_time_)); |
402 context(), file_path_, last_access_time_, last_modified_time_)); | |
403 } | 391 } |
404 | 392 |
405 private: | 393 private: |
406 FilePath file_path_; | 394 FilePath file_path_; |
407 base::Time last_access_time_; | 395 base::Time last_access_time_; |
408 base::Time last_modified_time_; | 396 base::Time last_modified_time_; |
409 }; | 397 }; |
410 | 398 |
411 class RelayTruncate : public RelayWithStatusCallback { | 399 class RelayTruncate : public RelayWithStatusCallback { |
412 public: | 400 public: |
413 RelayTruncate(const fileapi::FileSystemOperationContext& context, | 401 RelayTruncate(const fileapi::FileSystemOperationContext& context, |
414 const FilePath& file_path, | 402 const FilePath& file_path, |
415 int64 length, | 403 int64 length, |
416 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) | 404 fileapi::FileSystemFileUtilProxy::StatusCallback* callback) |
417 : RelayWithStatusCallback(context, callback), | 405 : RelayWithStatusCallback(context, callback), |
418 file_path_(file_path), | 406 file_path_(file_path), |
419 length_(length) { | 407 length_(length) { |
420 } | 408 } |
421 | 409 |
422 protected: | 410 protected: |
423 virtual void RunWork() { | 411 virtual void RunWork() { |
424 set_error_code( | 412 set_error_code(file_util()->Truncate(context(), file_path_, length_)); |
425 file_system_file_util()->Truncate(context(), file_path_, length_)); | |
426 } | 413 } |
427 | 414 |
428 private: | 415 private: |
429 FilePath file_path_; | 416 FilePath file_path_; |
430 int64 length_; | 417 int64 length_; |
431 }; | 418 }; |
432 | 419 |
433 bool Start(const tracked_objects::Location& from_here, | 420 bool Start(const tracked_objects::Location& from_here, |
434 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 421 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
435 scoped_refptr<MessageLoopRelay> relay) { | 422 scoped_refptr<MessageLoopRelay> relay) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 const FileSystemOperationContext& context, | 552 const FileSystemOperationContext& context, |
566 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 553 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
567 const FilePath& path, | 554 const FilePath& path, |
568 int64 length, | 555 int64 length, |
569 StatusCallback* callback) { | 556 StatusCallback* callback) { |
570 return Start(FROM_HERE, message_loop_proxy, | 557 return Start(FROM_HERE, message_loop_proxy, |
571 new RelayTruncate(context, path, length, callback)); | 558 new RelayTruncate(context, path, length, callback)); |
572 } | 559 } |
573 | 560 |
574 } // namespace fileapi | 561 } // namespace fileapi |
OLD | NEW |