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

Side by Side Diff: storage/browser/fileapi/remove_operation_delegate.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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/browser/fileapi/remove_operation_delegate.h" 5 #include "storage/browser/fileapi/remove_operation_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "webkit/browser/fileapi/file_system_context.h" 8 #include "storage/browser/fileapi/file_system_context.h"
9 #include "webkit/browser/fileapi/file_system_operation_runner.h" 9 #include "storage/browser/fileapi/file_system_operation_runner.h"
10 10
11 namespace fileapi { 11 namespace storage {
12 12
13 RemoveOperationDelegate::RemoveOperationDelegate( 13 RemoveOperationDelegate::RemoveOperationDelegate(
14 FileSystemContext* file_system_context, 14 FileSystemContext* file_system_context,
15 const FileSystemURL& url, 15 const FileSystemURL& url,
16 const StatusCallback& callback) 16 const StatusCallback& callback)
17 : RecursiveOperationDelegate(file_system_context), 17 : RecursiveOperationDelegate(file_system_context),
18 url_(url), 18 url_(url),
19 callback_(callback), 19 callback_(callback),
20 weak_factory_(this) { 20 weak_factory_(this) {
21 } 21 }
22 22
23 RemoveOperationDelegate::~RemoveOperationDelegate() {} 23 RemoveOperationDelegate::~RemoveOperationDelegate() {
24 }
24 25
25 void RemoveOperationDelegate::Run() { 26 void RemoveOperationDelegate::Run() {
26 operation_runner()->RemoveFile(url_, base::Bind( 27 operation_runner()->RemoveFile(
27 &RemoveOperationDelegate::DidTryRemoveFile, weak_factory_.GetWeakPtr())); 28 url_,
29 base::Bind(&RemoveOperationDelegate::DidTryRemoveFile,
30 weak_factory_.GetWeakPtr()));
28 } 31 }
29 32
30 void RemoveOperationDelegate::RunRecursively() { 33 void RemoveOperationDelegate::RunRecursively() {
31 StartRecursiveOperation(url_, callback_); 34 StartRecursiveOperation(url_, callback_);
32 } 35 }
33 36
34 void RemoveOperationDelegate::ProcessFile(const FileSystemURL& url, 37 void RemoveOperationDelegate::ProcessFile(const FileSystemURL& url,
35 const StatusCallback& callback) { 38 const StatusCallback& callback) {
36 operation_runner()->RemoveFile( 39 operation_runner()->RemoveFile(
37 url, 40 url,
38 base::Bind(&RemoveOperationDelegate::DidRemoveFile, 41 base::Bind(&RemoveOperationDelegate::DidRemoveFile,
39 weak_factory_.GetWeakPtr(), callback)); 42 weak_factory_.GetWeakPtr(),
43 callback));
40 } 44 }
41 45
42 void RemoveOperationDelegate::ProcessDirectory(const FileSystemURL& url, 46 void RemoveOperationDelegate::ProcessDirectory(const FileSystemURL& url,
43 const StatusCallback& callback) { 47 const StatusCallback& callback) {
44 callback.Run(base::File::FILE_OK); 48 callback.Run(base::File::FILE_OK);
45 } 49 }
46 50
47 void RemoveOperationDelegate::PostProcessDirectory( 51 void RemoveOperationDelegate::PostProcessDirectory(
48 const FileSystemURL& url, const StatusCallback& callback) { 52 const FileSystemURL& url,
53 const StatusCallback& callback) {
49 operation_runner()->RemoveDirectory(url, callback); 54 operation_runner()->RemoveDirectory(url, callback);
50 } 55 }
51 56
52 void RemoveOperationDelegate::DidTryRemoveFile(base::File::Error error) { 57 void RemoveOperationDelegate::DidTryRemoveFile(base::File::Error error) {
53 if (error != base::File::FILE_ERROR_NOT_A_FILE && 58 if (error != base::File::FILE_ERROR_NOT_A_FILE &&
54 error != base::File::FILE_ERROR_SECURITY) { 59 error != base::File::FILE_ERROR_SECURITY) {
55 callback_.Run(error); 60 callback_.Run(error);
56 return; 61 return;
57 } 62 }
58 operation_runner()->RemoveDirectory( 63 operation_runner()->RemoveDirectory(
59 url_, 64 url_,
60 base::Bind(&RemoveOperationDelegate::DidTryRemoveDirectory, 65 base::Bind(&RemoveOperationDelegate::DidTryRemoveDirectory,
61 weak_factory_.GetWeakPtr(), error)); 66 weak_factory_.GetWeakPtr(),
67 error));
62 } 68 }
63 69
64 void RemoveOperationDelegate::DidTryRemoveDirectory( 70 void RemoveOperationDelegate::DidTryRemoveDirectory(
65 base::File::Error remove_file_error, 71 base::File::Error remove_file_error,
66 base::File::Error remove_directory_error) { 72 base::File::Error remove_directory_error) {
67 callback_.Run( 73 callback_.Run(remove_directory_error == base::File::FILE_ERROR_NOT_A_DIRECTORY
68 remove_directory_error == base::File::FILE_ERROR_NOT_A_DIRECTORY ? 74 ? remove_file_error
69 remove_file_error : 75 : remove_directory_error);
70 remove_directory_error);
71 } 76 }
72 77
73 void RemoveOperationDelegate::DidRemoveFile(const StatusCallback& callback, 78 void RemoveOperationDelegate::DidRemoveFile(const StatusCallback& callback,
74 base::File::Error error) { 79 base::File::Error error) {
75 if (error == base::File::FILE_ERROR_NOT_FOUND) { 80 if (error == base::File::FILE_ERROR_NOT_FOUND) {
76 callback.Run(base::File::FILE_OK); 81 callback.Run(base::File::FILE_OK);
77 return; 82 return;
78 } 83 }
79 callback.Run(error); 84 callback.Run(error);
80 } 85 }
81 86
82 } // namespace fileapi 87 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/fileapi/remove_operation_delegate.h ('k') | storage/browser/fileapi/sandbox_directory_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698