Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / storage / browser / fileapi / remove_operation_delegate.cc
blobc0de28abf8ef70de691aee692e1d1085b510ac87
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.
5 #include "storage/browser/fileapi/remove_operation_delegate.h"
7 #include "base/bind.h"
8 #include "storage/browser/fileapi/file_system_context.h"
9 #include "storage/browser/fileapi/file_system_operation_runner.h"
11 namespace storage {
13 RemoveOperationDelegate::RemoveOperationDelegate(
14 FileSystemContext* file_system_context,
15 const FileSystemURL& url,
16 const StatusCallback& callback)
17 : RecursiveOperationDelegate(file_system_context),
18 url_(url),
19 callback_(callback),
20 weak_factory_(this) {
23 RemoveOperationDelegate::~RemoveOperationDelegate() {}
25 void RemoveOperationDelegate::Run() {
26 operation_runner()->RemoveFile(url_, base::Bind(
27 &RemoveOperationDelegate::DidTryRemoveFile, weak_factory_.GetWeakPtr()));
30 void RemoveOperationDelegate::RunRecursively() {
31 StartRecursiveOperation(url_, FileSystemOperation::ERROR_BEHAVIOR_ABORT,
32 callback_);
35 void RemoveOperationDelegate::ProcessFile(const FileSystemURL& url,
36 const StatusCallback& callback) {
37 operation_runner()->RemoveFile(
38 url,
39 base::Bind(&RemoveOperationDelegate::DidRemoveFile,
40 weak_factory_.GetWeakPtr(), callback));
43 void RemoveOperationDelegate::ProcessDirectory(const FileSystemURL& url,
44 const StatusCallback& callback) {
45 callback.Run(base::File::FILE_OK);
48 void RemoveOperationDelegate::PostProcessDirectory(
49 const FileSystemURL& url, const StatusCallback& callback) {
50 operation_runner()->RemoveDirectory(url, callback);
53 void RemoveOperationDelegate::DidTryRemoveFile(base::File::Error error) {
54 if (error != base::File::FILE_ERROR_NOT_A_FILE &&
55 error != base::File::FILE_ERROR_SECURITY) {
56 callback_.Run(error);
57 return;
59 operation_runner()->RemoveDirectory(
60 url_,
61 base::Bind(&RemoveOperationDelegate::DidTryRemoveDirectory,
62 weak_factory_.GetWeakPtr(), error));
65 void RemoveOperationDelegate::DidTryRemoveDirectory(
66 base::File::Error remove_file_error,
67 base::File::Error remove_directory_error) {
68 callback_.Run(
69 remove_directory_error == base::File::FILE_ERROR_NOT_A_DIRECTORY ?
70 remove_file_error :
71 remove_directory_error);
74 void RemoveOperationDelegate::DidRemoveFile(const StatusCallback& callback,
75 base::File::Error error) {
76 if (error == base::File::FILE_ERROR_NOT_FOUND) {
77 callback.Run(base::File::FILE_OK);
78 return;
80 callback.Run(error);
83 } // namespace storage