Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: webkit/fileapi/remove_operation_delegate.cc

Issue 15859007: Move browser-specific FileAPI code from webkit/fileapi to webkit/browser/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dump_file_system build fix Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 "webkit/fileapi/remove_operation_delegate.h"
6
7 #include "base/bind.h"
8 #include "webkit/browser/fileapi/local_file_system_operation.h"
9 #include "webkit/fileapi/file_system_context.h"
10 #include "webkit/fileapi/file_system_operation_context.h"
11
12 namespace fileapi {
13
14 RemoveOperationDelegate::RemoveOperationDelegate(
15 FileSystemContext* file_system_context,
16 LocalFileSystemOperation* operation,
17 const FileSystemURL& url,
18 const StatusCallback& callback)
19 : RecursiveOperationDelegate(file_system_context, operation),
20 url_(url),
21 callback_(callback) {
22 }
23
24 RemoveOperationDelegate::~RemoveOperationDelegate() {}
25
26 void RemoveOperationDelegate::Run() {
27 NewNestedOperation()->RemoveFile(url_, base::Bind(
28 &RemoveOperationDelegate::DidTryRemoveFile, AsWeakPtr()));
29 }
30
31 void RemoveOperationDelegate::RunRecursively() {
32 StartRecursiveOperation(
33 url_,
34 base::Bind(&RemoveOperationDelegate::RemoveNextDirectory, AsWeakPtr()));
35 }
36
37 void RemoveOperationDelegate::ProcessFile(const FileSystemURL& url,
38 const StatusCallback& callback) {
39 if (to_remove_directories_.size() == 1u &&
40 to_remove_directories_.top() == url) {
41 // We seem to have been re-directed from ProcessDirectory.
42 to_remove_directories_.pop();
43 }
44 NewNestedOperation()->RemoveFile(url, base::Bind(
45 &RemoveOperationDelegate::DidRemoveFile, AsWeakPtr(), callback));
46 }
47
48 void RemoveOperationDelegate::ProcessDirectory(const FileSystemURL& url,
49 const StatusCallback& callback) {
50 to_remove_directories_.push(url);
51 callback.Run(base::PLATFORM_FILE_OK);
52 }
53
54 void RemoveOperationDelegate::DidTryRemoveFile(
55 base::PlatformFileError error) {
56 if (error == base::PLATFORM_FILE_OK ||
57 error != base::PLATFORM_FILE_ERROR_NOT_A_FILE) {
58 callback_.Run(error);
59 return;
60 }
61 NewNestedOperation()->RemoveDirectory(url_, callback_);
62 }
63
64 void RemoveOperationDelegate::DidRemoveFile(const StatusCallback& callback,
65 base::PlatformFileError error) {
66 if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND) {
67 callback.Run(base::PLATFORM_FILE_OK);
68 return;
69 }
70 callback.Run(error);
71 }
72
73 void RemoveOperationDelegate::RemoveNextDirectory(
74 base::PlatformFileError error) {
75 if (error != base::PLATFORM_FILE_OK ||
76 to_remove_directories_.empty()) {
77 callback_.Run(error);
78 return;
79 }
80 FileSystemURL url = to_remove_directories_.top();
81 to_remove_directories_.pop();
82 NewNestedOperation()->RemoveDirectory(url, base::Bind(
83 &RemoveOperationDelegate::RemoveNextDirectory,
84 AsWeakPtr()));
85 }
86
87 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/remove_operation_delegate.h ('k') | webkit/fileapi/sandbox_file_system_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698