OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/drive/file_system/remove_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/drive/drive.pb.h" | 7 #include "chrome/browser/chromeos/drive/drive.pb.h" |
8 #include "chrome/browser/chromeos/drive/drive_cache.h" | 8 #include "chrome/browser/chromeos/drive/drive_cache.h" |
9 #include "chrome/browser/chromeos/drive/drive_file_system.h" | 9 #include "chrome/browser/chromeos/drive/drive_file_system.h" |
10 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | 10 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 void RemoveOperation::Remove( | 31 void RemoveOperation::Remove( |
32 const FilePath& file_path, | 32 const FilePath& file_path, |
33 bool is_recursive, | 33 bool is_recursive, |
34 const FileOperationCallback& callback) { | 34 const FileOperationCallback& callback) { |
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
36 DCHECK(!callback.is_null()); | 36 DCHECK(!callback.is_null()); |
37 | 37 |
38 // Get the edit URL of an entry at |file_path|. | 38 // Get the edit URL of an entry at |file_path|. |
39 file_system_->ResourceMetadata()->GetEntryInfoByPath( | 39 file_system_->GetResourceMetadata()->GetEntryInfoByPath( |
40 file_path, | 40 file_path, |
41 base::Bind( | 41 base::Bind( |
42 &RemoveOperation::RemoveAfterGetEntryInfo, | 42 &RemoveOperation::RemoveAfterGetEntryInfo, |
43 weak_ptr_factory_.GetWeakPtr(), | 43 weak_ptr_factory_.GetWeakPtr(), |
44 callback)); | 44 callback)); |
45 } | 45 } |
46 | 46 |
47 void RemoveOperation::RemoveAfterGetEntryInfo( | 47 void RemoveOperation::RemoveAfterGetEntryInfo( |
48 const FileOperationCallback& callback, | 48 const FileOperationCallback& callback, |
49 DriveFileError error, | 49 DriveFileError error, |
(...skipping 28 matching lines...) Expand all Loading... |
78 const GURL& /* document_url */) { | 78 const GURL& /* document_url */) { |
79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
80 DCHECK(!callback.is_null()); | 80 DCHECK(!callback.is_null()); |
81 | 81 |
82 DriveFileError error = util::GDataToDriveFileError(status); | 82 DriveFileError error = util::GDataToDriveFileError(status); |
83 if (error != DRIVE_FILE_OK) { | 83 if (error != DRIVE_FILE_OK) { |
84 callback.Run(error); | 84 callback.Run(error); |
85 return; | 85 return; |
86 } | 86 } |
87 | 87 |
88 file_system_->ResourceMetadata()->RemoveEntryFromParent( | 88 file_system_->GetResourceMetadata()->RemoveEntryFromParent( |
89 resource_id, | 89 resource_id, |
90 base::Bind(&RemoveOperation::NotifyDirectoryChanged, | 90 base::Bind(&RemoveOperation::NotifyDirectoryChanged, |
91 weak_ptr_factory_.GetWeakPtr(), | 91 weak_ptr_factory_.GetWeakPtr(), |
92 callback)); | 92 callback)); |
93 | 93 |
94 cache_->RemoveOnUIThread(resource_id, CacheOperationCallback()); | 94 cache_->RemoveOnUIThread(resource_id, CacheOperationCallback()); |
95 } | 95 } |
96 | 96 |
97 void RemoveOperation::NotifyDirectoryChanged( | 97 void RemoveOperation::NotifyDirectoryChanged( |
98 const FileOperationCallback& callback, | 98 const FileOperationCallback& callback, |
99 DriveFileError error, | 99 DriveFileError error, |
100 const FilePath& directory_path) { | 100 const FilePath& directory_path) { |
101 if (error == DRIVE_FILE_OK) | 101 if (error == DRIVE_FILE_OK) |
102 file_system_->OnDirectoryChanged(directory_path); | 102 file_system_->OnDirectoryChanged(directory_path); |
103 | 103 |
104 if (!callback.is_null()) | 104 if (!callback.is_null()) |
105 callback.Run(error); | 105 callback.Run(error); |
106 } | 106 } |
107 | 107 |
108 } // namespace file_system | 108 } // namespace file_system |
109 } // namespace drive | 109 } // namespace drive |
OLD | NEW |